【发布时间】:2013-08-15 23:30:54
【问题描述】:
我正在尝试查找包含首字母缩略词“IT”的文档。
我尝试使用 StandardAnalyzer、SimpleAnalyzer 和 KeywordAnalyzer 进行搜索 - 结果相同(没有任何命中)。
据我所知,“它”不是默认停用词的一部分?
我可以使用通配符搜索找到文档,所以我知道它们在索引中。
非常感谢任何帮助!干杯!
【问题讨论】:
标签: lucene lucene.net
我正在尝试查找包含首字母缩略词“IT”的文档。
我尝试使用 StandardAnalyzer、SimpleAnalyzer 和 KeywordAnalyzer 进行搜索 - 结果相同(没有任何命中)。
据我所知,“它”不是默认停用词的一部分?
我可以使用通配符搜索找到文档,所以我知道它们在索引中。
非常感谢任何帮助!干杯!
【问题讨论】:
标签: lucene lucene.net
默认停用词集确实包含单词“it”。在StopAnalyzer中定义,它是:
final List<String> stopWords = Arrays.asList(
"a", "an", "and", "are", "as", "at", "be", "but", "by",
"for", "if", "in", "into", "is", "it",
"no", "not", "of", "on", "or", "such",
"that", "the", "their", "then", "there", "these",
"they", "this", "to", "was", "will", "with"
);
SimpleAnalyzer 和 KeywordAnalyzer 均未使用停用词,因此由于某些其他问题(可能是对它们如何标记化的误解,或者索引和查询时间分析器之间存在分歧),这些不起作用。
【讨论】:
我尝试在没有任何停用词的情况下重新索引...
new IndexWriter(directory,
new StandardAnalyzer(Version.LUCENE_30, new HashSet<string>()), // No stop words
true,
IndexWriter.MaxFieldLength.UNLIMITED);
...之后,只要我使用相同类型的分析器(没有任何停用词)进行搜索,我就可以搜索“it”:
new StandardAnalyzer(Version.LUCENE_30, new HashSet<string>()
【讨论】: