I am using Lucene .net to index eml file with eml content, id and localdate field and later firing a daterange query on localdate to get the list of eml id satisfying the localdate to and from query. I have scanned about 8000 eml file and making a search, which works fine for limited set of queries. If fire a query by keeping from date less than 30 April, 2010 then query fails if the from date is after 30 April, 2010 then the query return me the result. I am really surprised to see the behaviour, the query should work with all date range. Following is the piece of code used.
DateTime from = DateTime.Parse("3/30/2010 11:00:00 AM");// DateTime.Now.AddMonths(-12);
DateTime to = DateTime.Now;
String sFrom = DateTools.DateToString(from, DateTools.Resolution.SECOND);
String sTo = DateTools.DateToString(to, DateTools.Resolution.SECOND);
Lucene.Net.Index.Term date1 = new Lucene.Net.Index.Term("LOCALDATE", sFrom + "*");
Lucene.Net.Index.Term date2 = new Lucene.Net.Index.Term("LOCALDATE", sTo + "*");
Lucene.Net.Search.Query dateRangeQuery = new Lucene.Net.Search.RangeQuery(date1, date2, true);
Hits hits = searcher.Search(dateRangeQuery);
It throws the following exception on Search:
System error.
at Lucene.Net.Search.BooleanQuery.Add(BooleanClause clause)
at Lucene.Net.Search.BooleanQuery.Add(Query query, Occur occur)
at Lucene.Net.Search.RangeQuery.Rewrite(IndexReader reader)
at Lucene.Net.Search.IndexSearcher.Rewrite(Query original)
at Lucene.Net.Search.Query.Weight(Searcher searcher)
at Lucene.Net.Search.Hits..ctor(Searcher s, Query q, Filter f)
at Lucene.Net.Search.Searcher.Search(Query query, Filter filter)
at Lucene.Net.Search.Searcher.Search(Query query)
at LuceneIndexTestApp.Form1.Search(String text, IndexSearcher searcher, QueryParser parser)
Any help will be appreciated!!
Thanks,
Haseena
The problem was solved using BooleanQuery.SetMaxClauseCount(Int32.MaxValue);