elasticsearch - ElasticSearch - 带截止的普通查询,只有当所有低频词都匹配时才对高频词进行评分
问题描述
尝试使用“ https://www.elastic.co/guide/en/elasticsearch/reference/6.4/query-dsl-common-terms-query.html ”但不能使某件事起作用:添加高频词分数到总分,仅当查询中的所有低频词都已匹配时。
尝试使用"low_freq_operator": "and"
,但它需要查询中的所有低频词 - 我不知道。
另外 - 如果我使用
"minimum_should_match": {
"low_freq" : "50%",
}
这是否意味着如果查询有 4 个低频词,其中 2 个的文档将作为命中返回,但只有 1 个查询词的文档不会返回对吗?
谢谢。
解决方案
常用术语查询
低频词
- 更重要
- 您可以构造查询以返回包含查询字符串的所有单词的文档
must be present
(利用"low_freq_operator": "and"
)only some of them
(利用"low_freq_operator": "or"
some percentage of them
(利用minimum_should_match
)
高频词
- 不太重要。
- 您可以构造查询
influence the score
,其中查询字符串中的所有停用词must be considered
(利用"high_freq_operator": "and"
)only some of them
(利用"high_freq_operator": "or"
)some percentage of them
(利用minimum_should_match
)
- 仅影响相关性分数。
- 如果不存在低频词,则它是
should
查询字符串中所有词条的典型子句
它如何将单词分类为频率较低或频率较高
根据链接,
根据 cutoff_frequency 将术语分配给高频或低频组,可以将其指定为绝对频率 (>=1) 或相对频率 (0.0 .. 1.0)....
也许这个查询最有趣的属性是它自动适应特定领域的停用词。例如,在视频托管网站上,“剪辑”或“视频”等常用术语将自动表现为停用词,而无需维护手动列表。
它如何与示例一起使用
从这个链接,
常用术语查询is a modern alternative to stopwords which improves the precision and recall of search results
(通过考虑停用词),而不牺牲性能。
假设我有以下文件:
Document 1: Is there stairway to this path?
Document 2: Is there a stairway to heaven?
Document 3: Stairway to heaven
.....
.....
现在说您的搜索查询如下:
{
"query": {
"common": {
"body": {
"query": "stairway to heaven",
"cutoff_frequency": 0.001,
"low_freq_operator": "and"
}
}
}
}
当您使用时,and
结果将是Document 3 followed by Document 2
唯一的。当您使用 时or
,结果将Document 3, Document 2, Document 1
分别为。
所以当你使用 时or
,这里会使用高频词 ieto
来影响分数。以类似的方式,这high_freq_operator
将适用于停用词,但它再次仅用于影响分数。
所以对于你的第一个查询,希望上面的解释就足够了,对于下面的查询,
这是否意味着如果查询有 4 个低频词,其中 2 个的文档将作为命中返回,但只有 1 个查询词的文档不会返回对吗?
对,那是正确的。
希望能帮助到你!
推荐阅读
- python - Flask WTForms,如何为 SelectField 的选项添加附加属性?
- java - 在我的代码中,getArgument 每次都返回 null
- python - 提高 CNN 模型的准确性(陷入非常低的准确性)
- android - 从 AOSP 源代码树构建 Android 系统应用
- java - 来自 ZipInputStream 的 XMLEventReader 关闭流
- reactjs - 带有有效负载 {"name":"Home","params":{} 的操作 'NAVIGATE' 未被任何导航器处理
- reactjs - 使用 useState 在另一个对象中填充一个对象
- java - 由于 JRE 版本,Java 程序无法运行
- python - 当我想在python中存储recall_score时,如何为每个值指定一个类标签?
- flutter - 如何用图像创建多页pdf?