在处理精确匹配时,我会得到这样一个真实世界的查询:
非教育、就业或培训
转换为移除停止词的Lucene查询将提供:
+Content:"? ? education employment ? training" 下面是一个更精心设计的例子:
“没有这样的东西”
转换为移除停止词的Lucene查询将提供:
+Content:"? ? ? ? thing" 我的目标是让搜索像这样的匹配,只有准确的匹配,当用户输入它。
一种解决办法是清除止损词列表吗?这会否有不良影响?如果是的话什么?(我的google-fu失败)
发布于 2018-03-22 04:36:08
这完全取决于您使用的分析器。StandardAnalyzer使用停止词并将它们去掉,实际上,StopAnalyzer是StandardAnalyzer获取停止词的地方。
使用WhitespaceAnalyzer或通过继承最适合您的需求的继承来创建您自己的,并将其修改为您想要的。
或者,如果您喜欢StandardAnalyzer,您可以使用自定义的“停止单词列表”更新一个:
//This is what the default stop word list is in case you want to use or filter this
var defaultStopWords = StopAnalyzer.ENGLISH_STOP_WORDS_SET;
//create a new StandardAnalyzer with custom stop words
var sa = new StandardAnalyzer(
Version.LUCENE_29, //depends on your version
new HashSet<string> //pass in your own stop word list
{
"hello",
"world"
});https://stackoverflow.com/questions/49397197
复制相似问题