Mam problemy poszukiwaniu dokładnej frazy używając Lucene.NET 2.0.0.4Dokładna fraza wyszukiwania używając Lucene.net
Na przykład szukam „atrybut zakres ustawia zmienną” (w tym cytaty), ale nie otrzymują mecze, potwierdziłem w 100%, że fraza istnieje.
Czy ktoś może zasugerować, gdzie idę źle? Czy to jest nawet obsługiwane przez Lucene.NET? Jak zwykle dokumentacja API nie jest zbyt pomocna, a kilka artykułów CodeProject, które przeczytałem, nie porusza tego tematu.
Korzystanie poniższy kod, aby utworzyć indeks:
Directory dir = Lucene.Net.Store.FSDirectory.GetDirectory("Index", true);
Analyzer analyzer = new Lucene.Net.Analysis.SimpleAnalyzer();
IndexWriter indexWriter = new Lucene.Net.Index.IndexWriter(dir, analyzer,true);
//create a document, add in a single field
Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
Lucene.Net.Documents.Field fldContent = new Lucene.Net.Documents.Field(
"content", File.ReadAllText(@"Documents\100.txt"),
Lucene.Net.Documents.Field.Store.YES,
Lucene.Net.Documents.Field.Index.TOKENIZED);
doc.Add(fldContent);
//write the document to the index
indexWriter.AddDocument(doc);
Następnie wyszukać frazę używając:
//state the file location of the index
Directory dir = Lucene.Net.Store.FSDirectory.GetDirectory("Index", false);
//create an index searcher that will perform the search
IndexSearcher searcher = new Lucene.Net.Search.IndexSearcher(dir);
QueryParser qp = new QueryParser("content", new SimpleAnalyzer());
// txtSearch.Text Contains a phrase such as "this is a phrase"
Query q=qp.Parse(txtSearch.Text);
//execute the query
Lucene.Net.Search.Hits hits = searcher.Search(q);
Dokument docelowy wynosi około 7 MB zwykły tekst.
Widziałem to previous question, ale nie chcę wyszukiwania bliskości, tylko dokładne wyszukiwanie fraz.