My Lucene queries only ever find one hit
- by Bob
I'm getting started with Lucene.Net (stuck on version 2.3.1). I add sample documents with this:
Dim indexWriter = New IndexWriter(indexDir, New Standard.StandardAnalyzer(), True)
Dim doc = Document()
doc.Add(New Field("Title", "foo", Field.Store.YES, Field.Index.TOKENIZED, Field.TermVector.NO))
doc.Add(New Field("Date", DateTime.UtcNow.ToString, Field.Store.YES, Field.Index.TOKENIZED, Field.TermVector.NO))
indexWriter.AddDocument(doc)
indexWriter.Close()
I search for documents matching "foo" with this:
Dim searcher = New IndexSearcher(indexDir)
Dim parser = New QueryParser("Title", New StandardAnalyzer())
Dim Query = parser.Parse("foo")
Dim hits = searcher.Search(Query)
Console.WriteLine("Number of hits = " + hits.Length.ToString)
No matter how many times I run this, I only ever get one result. Any ideas?