出于某种原因,lucene应该没有返回任何结果。这是'搜索'代码
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)
topDocs中没有scoreDocs(结果)。我知道索引中有一个文件,其中id字段等于346但是由于某种原因搜索没有找到它。以下是“id”字段的创建方式
doc.Add(New Field("id", ID, Field.Store.YES, Field.Index.ANALYZED)) //ID is an integer
我还有其他字段可以搜索并且工作正常(例如,如果我搜索主题字段,我会得到我应该得到的结果)