public List <LuceneResult <T> > Search(String[] fields, String querystring) { //querystring = "\"" + querystring + "\""; log.Debug("start new search for multiple fields " + querystring); Searcher searcher = new IndexSearcher(reader); Analyzer analyzer = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30); MultiFieldQueryParser parser = new MultiFieldQueryParser(Lucene.Net.Util.Version.LUCENE_30, fields, analyzer); parser.DefaultOperator = QueryParser.Operator.AND; Query query = parser.Parse(querystring); AnonymousClassCollector streamingHitCollector = new AnonymousClassCollector(searcher); searcher.Search(query, streamingHitCollector); parser = null; query = null; List <LuceneResult <T> > ret = streamingHitCollector.GetSortedResult(); log.Debug("resultcount: " + ret.Count); return(ret); }
public List <LuceneResult <T> > Search(String[] fields, String querystring, String datecol, String lowerdate, String uppderdate) { log.Debug("start new search for multiple fields and range"); //RangeFilter filter = new RangeFilter(datecol, lowerDate, upperDate, true, true); Searcher searcher = new IndexSearcher(reader); Analyzer analyzer = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30); String low = lowerdate; String up = uppderdate; DateTime dt1 = DateTime.MinValue; if (DateTime.TryParse(lowerdate, out dt1)) { low = Sharpend.Utils.Utils.getDateTimeForIndex(dt1); } DateTime dt2 = DateTime.MinValue; if (DateTime.TryParse(uppderdate, out dt2)) { up = Sharpend.Utils.Utils.getDateTimeForIndex(dt2); } Query query; if (String.IsNullOrEmpty(querystring)) { query = new TermRangeQuery(datecol, low, up, true, true); } else { MultiFieldQueryParser parser = new MultiFieldQueryParser(Lucene.Net.Util.Version.LUCENE_30, fields, analyzer); parser.DefaultOperator = QueryParser.Operator.AND; query = parser.Parse(querystring); } AnonymousClassCollector streamingHitCollector = new AnonymousClassCollector(searcher); if (String.IsNullOrEmpty(querystring)) { searcher.Search(query, streamingHitCollector); } else { TermRangeFilter filter = new TermRangeFilter(datecol, low, up, true, true); searcher.Search(query, filter, streamingHitCollector); } query = null; List <LuceneResult <T> > ret = streamingHitCollector.GetSortedResult(); log.Debug("resultcount: " + ret.Count); return(ret); }
public List <LuceneResult <T> > Search(String field, String querystring) { log.Debug("start new search for field " + field + " query: " + querystring); Searcher searcher = new IndexSearcher(reader); Analyzer analyzer = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30); QueryParser parser = new QueryParser(Lucene.Net.Util.Version.LUCENE_30, field, analyzer); Query query = parser.Parse(querystring); AnonymousClassCollector streamingHitCollector = new AnonymousClassCollector(searcher); searcher.Search(query, streamingHitCollector); parser = null; query = null; List <LuceneResult <T> > ret = streamingHitCollector.GetSortedResult(); log.Debug("resultcount: " + ret.Count); return(ret); }