lucenenet-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Digy" <digyd...@gmail.com>
Subject RE: My Lucene queries only ever return one hit
Date Sun, 09 May 2010 11:29:57 GMT
Because you recreate(purge) the index.
	New IndexWriter(indexDir, New Standard.StandardAnalyzer(), >>>> True
<<<<)
Last Boolean parameter can be something like "Not
System.IO.Directory.Exists(indexDir)"

DIGY

-----Original Message-----
From: Bob Eastbrook [mailto:baconeater789@gmail.com] 
Sent: Sunday, May 09, 2010 7:34 AM
To: lucene-net-user@lucene.apache.org
Subject: My Lucene queries only ever return one hit

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?

Bob


Mime
View raw message