1

I'm keeping a record of the contents of 100 refrigerators (named fridgeA. fridgeB, etc.) on a daily basis. Everyday the contents change, so one may have Milk, Eggs, and Soda today, but tomorrow might have Milk, Soda, Celery, and Apples.

I need to be able to perform a search for all fridges that contains Eggs on a specific date or date range.

What is the best way to store this data in Solr?

cwings
  • 51
  • 5
  • Are you just storing a presence of milk? Like a binary flag? Or do you have additional information, such as number of milk bottles, etc. This affects the shape of data. Also, are your date ranges always the same (e.g. today/this week/this month) or variable each time? – Alexandre Rafalovitch Jul 25 '14 at 01:15

1 Answers1

3

Make sure you store the current date in your data.

Then you can use a date range when you query:

creationDate:[2013-11-25T23:59:59.999Z/DAY TO 2013-11-26T23:59:59.999Z+1YEAR/DAY]

Or you can query a specific day:

creationDate:[2013-11-29T23:59:59.999Z/DAY]

See the wiki or this other helpful answer

Community
  • 1
  • 1
qux
  • 1,155
  • 7
  • 17
  • Just to specify: this means having one document for each day in the index, just if that wasn't clear to @cwings. – MatsLindh Jul 23 '14 at 17:47