2014-03-26 100 views
0

我用户LUCENE_30为我的搜索引擎,但我无法进行模糊搜索。如何让它工作? 我尝试使用GetFuzzyQuery,但没有任何反应。因为我看不到支持。Lucene 30模糊搜索

这里我的代码:

if (searchQuery.Length < 3) 
      { 
       throw new ArgumentException("none"); 
      } 
      FSDirectory dir = FSDirectory.Open(new DirectoryInfo(_indexFileLocation)); 

      var searcher = new IndexSearcher(dir, true); 
      var analyzer = new RussianAnalyzer(Lucene.Net.Util.Version.LUCENE_29); 

      var query = MultiFieldQueryParser.Parse(Lucene.Net.Util.Version.LUCENE_30, searchQuery, new[] {"Title" }, new[] { Occur.SHOULD }, analyzer); 



      var hits = searcher.Search(query, 11110); 
      var dto = new PerformSearchResultDto(); 
      dto.SearchResults = new List<SearchResult>(); 
      dto.Total = hits.TotalHits; 

      for (int i = pagesize * page; i < hits.TotalHits && i < pagesize * page + pagesize; i++) 
      { 
       // Document doc = hits.Doc(i); 
       int docId = hits.ScoreDocs[i].Doc; 
       var doc = searcher.Doc(docId); 
       var result = new SearchResult(); 
       result.Title = doc.Get("Title"); 
       result.Type = doc.Get("Type"); 
       result.Href = doc.Get("Href"); 
       result.LastModified = doc.Get("LastModified"); 
       result.Site = doc.Get("Site"); 
       result.City = doc.Get("City"); 
       //result.Region = doc.Get("Region"); 
       result.Content = doc.Get("Content"); 
       result.NoIndex = Convert.ToBoolean(doc.Get("NoIndex")); 
       dto.SearchResults.Add(result); 
      } 

回答