Reputation: 846
For some reason lucene is not returning any results when it should be. Here is the 'search' code
Dim util As New IndexerUtil()
Dim dir As Lucene.Net.Store.Directory = FSDirectory.Open(New DirectoryInfo(util.getIndexDir()))
Dim indexSearcher As New IndexSearcher(dir, False)
Dim indexWriter As New IndexWriter(dir, New SimpleAnalyzer(), False, indexWriter.MaxFieldLength.UNLIMITED)
Dim term As New Term("id", "346")
Dim query As New TermQuery(term)
Dim topDocs As TopDocs = indexSearcher.Search(query, 100)
There are no scoreDocs (results) in topDocs. I know for a fact that there is a document in the index where the id field is equal to 346 however for some reason the search is not finding it. Here is how the "id" field is being created
doc.Add(New Field("id", ID, Field.Store.YES, Field.Index.ANALYZED)) //ID is an integer
I have other fields to search on and those work fine (e.g. if I search on the subject field I get the results I should)
Upvotes: 2
Views: 1155
Reputation: 27943
SimpleAnalyzer uses LetterTokenizer, which only returns letters.
Consider using the KeywordAnalyzer instead for the id
field.
Upvotes: 6