Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you query a ravendb index containing dates using Lucene?

Tags:

lucene

ravendb

I am using the http api to query ravendb (so a LINQ query is not the solution to my question). My Product document looks like this:

{
  "editDate": "2012-08-29T15:00:00.846Z"
}

and I have the index:

from doc in docs.Product
select new { doc.editDate }

I want to query all documents before a certain date AND time. I can query on the DATE using this syntax:

editDate: [NULL TO 2012-09-17]

however I can't figure out how to query the time component as well. Any ideas?

like image 969
Derek Ekins Avatar asked Oct 06 '22 14:10

Derek Ekins


1 Answers

You can query that using:

 editDate: [NULL TO 2012-09-17T15:00:00.846Z]

If you care for a part of that, use:

 editDate: [NULL TO 2012-09-17T15:00]

Note that you might have to escape parts of the query, like so:

 editDate: [NULL TO 2012\-09\-17T15\:00]

For this to work you also need to ensure that the field is analysed. In Raven Studio - Add Field -> editDate, and set Indexing to Analyzed.

like image 104
Ayende Rahien Avatar answered Oct 10 '22 01:10

Ayende Rahien