My Lucene queries only ever find one hit

Posted by Bob on Stack Overflow See other posts from Stack Overflow or by Bob
Published on 2010-05-09T04:12:02Z Indexed on 2010/05/09 4:18 UTC
Read the original article Hit count: 245

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about lucene

Related posts about lucene.net