我遇到了一些将cutoff_frequency与“and”运算符相结合的弹性搜索查询,但这对我来说没有意义。
这是bool查询的一部分:
{
"match": {
"content": {
"query": "I has candy and cake",
"cutoff_frequency": 0.001,
"operator": "and"
}
}
}
根据这个文档,cutoff_frequency将(取决于文档,但很可能)将其转换为以下内容;
{
"bool": {
"must": {
"bool": {
"should": [
{ "term": { "text": "candy" }},
{ "term": { "text": "cake" }}
]
}
},
"should": {
"bool": {
"should": [
{ "term": { "text": "I" }},
{ "term": { "text": "has" }},
{ "term": { "text": "and" }}
]
}
}
}
}
但是,由于在查询中添加了“and”运算符,会发生什么?这是否意味着“cutoff_frequency”没有效果?
答案 0 :(得分:1)
它有效果。 来自文档Elastic Documentation
匹配查询支持 cutoff_frequency ,允许指定绝对或相对文档频率,其中高频项移动到可选子查询中,仅得分 a或运算符情况下的低频率(低于截止值)或运算符匹配时的所有低频项。
更新:我在查询中遇到了错误
看起来像这样:
{
"bool": {
"must": {
"bool": {
"must": [
{ "term": { "text": "candy" }},
{ "term": { "text": "cake" }}
]
}
},
"should": {
"bool": {
"should": [
{ "term": { "text": "I" }},
{ "term": { "text": "has" }},
{ "term": { "text": "and" }}
]
}
}
}
}
回答你的问题“只有匹配两个术语时才是的”