Very inspirating, great thanks!

Idea with indexing last number of year is very good and covers current
requirements. But one day there could be requirement for (as you said)
3-years anniversaries.

So I do this:
Index: For every required X-year anniversary there will be field
"year_mod_X" with "YEAR mod X" value.
Search: Compute "Y = CURRENT_YEAR mod X" and find "year_mod_X:Y".
For example:
3-year anniversary and years
1999 -> year_mod_3 = 1
2000 -> year_mod_3 = 2
2001 -> year_mod_3 = 0
2002 -> year_mod_3 = 1
2003 -> year_mod_3 = 2
2004 -> year_mod_3 = 0
2005 -> year_mod_3 = 1
...
Current year: 2011 -> 2011 mod 3 = 1
Solr query: year_mod_3:1
Results: 1999, 2002, 2005,  ... 

Pretty, simple and all with one solr query :)

--
View this message in context: 
http://lucene.472066.n3.nabble.com/Periodic-search-in-date-field-tp3260793p3264786.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to