Using Lucene for event searches

This topic has been a common thorn in my side since someone wanted to search events on the web using date ranges. 
Supposing you were looking for events in a city for while you were on vacation, you have a start and and end date and want to know what is going on while you are there on vacation.  You would be interested in any events, as long as they started before you left your vacation, and they did not end before you arrive.
This was a toughie for me and took a few false starts to resolve.  However, there was a easy and elegant solution as evidenced in the following lucene query which worked.  To summarize my solution, i constructed 2 range queries, using the "beginning of time" and the "end of time" as the alternative values of my range.  This query will return to you all events that are going on.
 
Query is +(+OBJECT_TYPE:Event +(+END_DATE:[20090319 TO 2922789940817] +START_DATE:[19700101 TO 20091113]))

Comments

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options