NET不返回的搜索结果

NET不返回的搜索结果

本文介绍了Lucene的.NET不返回的搜索结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因Lucene是不返回任何结果时,是应该的。这里是'搜索'code

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)

有没有scoreDocs(结果)的topDocs。我知道一个事实,那就是在该指数,其中id字段等于346但由于某种原因,搜索是没有找到它的文件。这里是如何的ID字段被创建

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)

推荐答案

SimpleAnalyzer使用LetterTokenizer,只返回字母。

SimpleAnalyzer uses LetterTokenizer, which only returns letters.

考虑使用KeywordAnalyzer而不是为 ID 字段。

Consider using the KeywordAnalyzer instead for the id field.

这篇关于Lucene的.NET不返回的搜索结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 11:00