Lucene query with both wildcard and NOT - lucene

I try to run a Lucene query to include some dates and exclude some dates.
But I notice that combination wildcards and NOT seems dose not work. I checked the query syntax and searched sometime in the internet, but got no luck. Am I missing anything? My request is to get the other dates of the month except first day. And my query is as below:
(field1:foo*) AND (field2:2019-* NOT 2019-*-01)
And the query without NOT works:
(field1:foo*) AND (field2:2019-09-*)

Related

Lucene data range search

I'm using Umbraco v7.2 for a site, and have run into a highly entertaining issue trying to search for things using the External Searcher by a date of ranges.
If I perform a Lucene search using the examine management search tools in the backoffice, I get results using this query:
{(+__NodeTypeAlias:bookingperiod)} AND startDate:2016-03-01T00\:00\:00
Subsequently, I KNOW that I can get results that include this date in a range. However, what's highly entertaining, quite puzzling and really rather frustrating, is that if I use a range query, I get no results. Here's the syntax:
{(+__NodeTypeAlias:bookingperiod)} AND +(startDate:[2016-02-28T00:00:00 TO 2016-03-20T00:00:00])
Now, in the interests of clarity, I've tried escaping the colon characters in the dates, the dashes in the dates and both, but it makes no difference at all. Can anyone explain to me where I'm going wrong?
Thanks!
I ran into this issue a while back, not sure why though, but changing to the format :"yyyyMMddHHmmss" helped, might be something with the parser.
So the query becomes:
+__NodeTypeAlias:bookingperiod AND +startDate:[20160228000000 TO 20160320000000]

Access SQL Query using BETWEEN Statement and dates from a form

I'm probably missing something basic here, but I can't for the life of me get this working.
I have a database that is tracking when certain projects are completed, and I want to be able to show in a list the completed projects between a date range.
The date range to check between is set by the user on a form.
I have built a query in Access:
SELECT Logs.Completed
FROM Logs
WHERE Logs.Completed BETWEEN Forms!UIBrowseCompleted!Text53 AND Forms!UIBrowseCompleted!Text55
ORDER BY Logs.Completed;
I have got the dates formatted in the text box so they are in #MM/DD/YYYY# format (I have manually put these dates direct in the query and this works) but when I run the query I get the following error:
This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables.
I have tried modifying the query to take the # out of the text fields in the form, and including ' around the Forms!UIBrowseCompleted!Text53 but I've still not got any joy from it.
has anyone had this issue before, or can anyone point me in the right direction.
Thanks
Do you want MS Access query or SQL query?
If you want MS Access query then you can try with following
SELECT Logs.Completed
FROM Logs
WHERE Logs.Completed >= Forms!UIBrowseCompleted!Text53 AND Logs.Completed <= Forms!UIBrowseCompleted!Text55
ORDER BY Logs.Completed;
between query will take time normally we use >= and <= to check date range
like
>= Forms!UIBrowseCompleted!Text53 AND Logs.Completed <= Forms!UIBrowseCompleted

Constructing an sql Query to get records betwen two dates

I'm trying to filter out and report records in a database that fall between a specified date range. I'm there are other threads here on how to do something similar, but my dates are stored as date timestamps (which is why I think the issue is arising)
My current query is as follows:
"SELECT * FROM JOURNAL WHERE Date_Time>'10/10/2013 00:00:00'"
(Note that journal is the name of the table I'm pulling the data from and date_time is the field in which the date is stored. I'm aware the query doesn't quite do what I want it to yet, but I was just testing out a simpler case at first.)
When I run this query (as part of an excel macro), excel reports that it can't find any records even though I know their are records past this date. Does anyone know how to do this properly?
Edit: I've got it, it was an issue unrelated to the query (something else in the macro) Thanks so much for the help (changing the date format worked)
have you tried other date format? like this:
"SELECT * FROM JOURNAL WHERE Date_Time>'2013-10-10:00:00:00'"
A simple between statement is what you need:
SELECT * FROM JOURNAL WHERE Date_Time between '10/10/2013 00:00:00' and '[otherdate]'
You need to run this to check for one important thing: If the server is running the BETWEEN as inclusive or not. If it's inclusive, both dates are included. If not, the range will begin either before or after one or both.
I've seen SQL servers that are the same in every respect actually treat this condition differently. So it's a good idea to check that.

Apache Solr - Wrong facet count

Are there any known issues in Solr 3.6, where when grouping, filter query (fq) is applied with faceting, the facet counts are coming back wrong.
If I have a query:
..indent=on&wt=json&start=0&rows=500&q=*:*&group=true&group.truncate=true&group.ngroups=true&group.field=Id&facet=true&facet.mincount=1&facet.field={!ex=filed1}field1&
facet.field={!ex=filed2}field2
if user filters on field1, then I have following query:
...indent=on&wt=json&start=0&rows=500&q=*:*&fq={!tag=dt}field1:value&group=true&group.truncate=true&group.ngroups=true&group.field=Id&facet=true&facet.mincount=1&facet.field={!ex=dt}field1&facet.field={!ex=dt}field2
I'm noticing that the facet counts for are different in the results coming back from each query.
thanks,
There seem to be two problems here:
You are misspelling field1 as filed1 in your !ex queries.
You are using !ex local parameter but without corresponding !tag parameter.

solr query with ruby - need to compare date time

My Lucene/Solr database contains a date column (created_at) that I need to use as a condition in a query.
I'm new to RoR and assume that RoR automatically uses its own date object upon anyObject.save, and that Solr in turn reindexes that column in its own way.
Regardless, the date is in this format: "2008-06-03 11:15:20"
I can write a quick parser to parse my query string into the above format, but when I query
Object.find(keyword:foo created_at >= '2008-06-03 11:15:20')
Solr throws a parsing error. I've tried several standard variations on this without success. Any suggestions?
I hate to ask the obvious, but have you checked the solr docs for the query language for dates?
http://wiki.apache.org/solr/SolrQuerySyntax
and experience suggests that ">=" is not a valid solr operator. You can do range queries on date fields, but using the correct format with your example query would be:
Object.find("keyword:foo AND created_at:[2008-06-03T11:15:20.000Z TO *]")