我目前正在调查使用通用术语查询的使用,并且由于该文档有点缺乏(或者我不仅没有在这些问题上找到任何文档),因此我并不完全是确保某些操作是否与常见术语查询不相容,或者我做错了。
我目前在Ubuntu 12.04,64位的Elasticsearch版本上。
这是我要观察的:
-
查询类型匹配和match_phrase似乎与使用high_freq_operator,low_freq_operator和minimum_should_match选项不兼容。(例如
[match] query does not support [high_freq_operator]
和类似) -
and,或者,或者不(复合表达式)在其组件表达式指定使用常见术语时似乎会产生损坏的基础表达式。(例如
[_na] filter malformed, must start with start_object
) -
span_term查询似乎与常见术语查询不相容。(例如
[span_term] query does not support [common]
)
我的查询看起来很:
以下解析...
{ "query": {
"match_phrase": {
"subject": {
"common": {
"body": {
"cutoff_frequency": 0.001,
"query": "something not important"
}
}
}
}
}
}
这个人无法解析,引用" [匹配]查询不支持[high_freq_operator]:
{"query": {
"match_phrase": {
"subject": {
"common": {
"body": {
"cutoff_frequency": 0.001,
"high_freq_operator": "or",
"query": "something not important"
}
}
}
}
}
}
这个人未能解析,引用"过滤畸形,必须以start_object开头":
{
"filter": {
"or": [
{
"query": {
"match": {
"subject": {
"common": {
"body": {
"cutoff_frequency": 0.001,
"query": "PLEASE READ: something not important"
}
}
}
}
}
},
{
"query": {
"range": {
"date": {
"to": "2009-12-31T23:59:59Z"
}
}
}
}
]
}
}
您误解了查询的结构。查询可以是" Leaf"查询(直接处理单个字段或字段),也可以是包装其他查询的"化合物"查询,例如bool
和dis_max
查询。
common
–terms查询本身就是叶子查询,就像 match
, match_phrase
, term
和 range
查询一样。您无法将common
查询嵌入另一个叶子查询中。
match
查询(不是match_phrase
和match_phrase_prefix
)已与common
-TERMS查询部分集成,因为它支持cutoff_frequency
参数。这是一个简单的集成:如果指定cutoff_frequency
,则match
查询在内部重写为common
查询。如果您想要common
terms的全部功能,则需要直接使用它。
所以此match
查询:
{
"query": {
"match": {
"subject": {
"query": "some words to query",
"cutoff_frequency": 0.001
}
}
}
}
等效于此common
查询:
{
"query": {
"common": {
"subject": {
"query": "some words to query",
"cutoff_frequency": 0.001
}
}
}
}
区别在于,在common
查询中,还有许多其他旋钮可以扭曲,例如 high_freq_operator
etc
for Elasticsearch 6.4 :
例如,加入 common with filter 查询使用以下方式:
{
"explain": true,
"query": {
"bool": {
"must": {
"common": {
"task_content": {
"query": "this is bonsai cool superb",
"cutoff_frequency": 0.01,
"high_freq_operator": "and"
}
}
},
"filter": {
"term": {
"subject_id": 2
}
}
}
},
"highlight": {
"fields": {
"task_content": {}
}
}
}
希望它对新版本有帮助。