- Events are running from one date to another.
- User can search for all active Events from one date to another.
- If Event is active between user selected date range, it should return event(s).
I am using Lucene (Umbraco)
Example
Sample DB Table with one record in it.
---------------------------------------
eventStartDate eventEndDate EventName
"23-Nov-2015" "31-Dec-2015" "test Event"
User Criteria
var fromDate = "01-Dec-2015"
var toDate = "31-Dec-2015"
//Scenario one with eventStartDate
var searcher = Examine.ExamineManager.Instance.SearchProviderCollection["Searcher"];
var searchCriteria = searcher.CreateSearchCriteria();
.......
var query = searchCriteria.RawQuery(luceneString).OrderBy("eventStartDate");
query.And().Range("eventStartDate", fromDate, toDate, true, true);
Output Result
{Return nothing}
//Scenario two with eventEndDate
var searcher = Examine.ExamineManager.Instance.SearchProviderCollection["Searcher"];
var searchCriteria = searcher.CreateSearchCriteria();
.......
var query = searchCriteria.RawQuery(luceneString).OrderBy("eventStartDate");
query.And().Range("eventEndDate", fromDate, toDate, true, true); // change is here
Output Result
-------------
"23-Nov-2015" "31-Dec-2015" "test Event"
I need to combine both above Scenarios if either of them is matched. Something like this but not sure exact Lucene code.
query.And().(Range("eventStartDate", fromDate, toDate, true, true) OR Range("eventEndDate", fromDate, toDate, true, true))
var result = searcher.Search(query.Compile());