Reputation: 391
I want to find some data of a application which allows using Apache Lucene syntax for search queries. I search data by date and want to find data from concrete date - concrete day. How can I do that?
Queries:
date: [2010-10-4 TO 2010-10-4]
or
date: 2010-10-4
does not work.
Upvotes: 1
Views: 12563
Reputation: 632
I put the date range without the hyphens and It worked for me.
date: [20210901 TO 20211101 ]
See the doc Range Searches
Upvotes: 0
Reputation: 391
I found the solution. For searching by one conrete day, query:
date: [2010-10-4T00:00:00 TO 2010-10-4T23:59:59]
is correct
Upvotes: 1
Reputation: 26733
Short answer: there is no "standard" for date query syntax in Lucene. You need to find out the format(s) your app supports.
Long answer: For the last couple years or so, Lucene keeps the numeric data specially encoded. Most likely, the date in the index is kept in the timestamp format. This means the query parser needs to take in the query, chew it and spit out the timestamp. Querying against a raw timestamp is not very practical - at least for humans - and your query parser likely has some pre-defined format it is able to understand.
For example, Solr has a pre-defined set of supported date/time formats and is able to parse those into timestamps.
Don't forget Lucene is just a library and each application (including Solr and the one you are using) is meant to use it the way they like.
Upvotes: 1