【发布时间】:2021-05-03 02:58:54
【问题描述】:
我的要求如下:
- 我需要为 must_not 匹配条件使用多个字段
- 我需要在词条查询中使用多个字段
当我运行以下查询时,Must_not 出现以下错误
"reason": "[match] 查询不支持多个字段,找到了[app_rating] 和[satisfaction_rating]"
对于条款,多个字段也出现错误。
“原因”:“预期 [START_OBJECT] 在 [should] 下,但在 [MyBuckets] 中得到了 [START_ARRAY]”,
如何更正查询?
"size":0,
"_source":["comments.keyword"],
"query":{
"bool": {
"must": [
{"match":{"source.keyword": "ONA"}}
],
"must_not":[
{"match":{"app_rating":"0","satisfaction_rating":"0","usability_rating": "0"}}
]
}
},
"aggs": {
"MyBuckets": {
"should":[{
"terms": {
"fields": ["comments.keyword"]
}
},
{
"terms":{
"fields": ["app_rating"]
}
},
{
"terms":{
"fields": ["satisfaction_rating"]
}
},
{
"terms":{
"fields": ["usability_rating"]
}
}
],
"order":{
"_count": "desc"
},
"size": "10"
}
}
}
** Below is the sample Mapping details**
'''{
"mapping": {
"properties": {
"Id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"app_rating": {
"type": "long"
},
"comments": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"conversation_rating": {
"type": "long"
},
"id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"satisfaction_rating": {
"type": "long"
},
"source": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"timestamp": {
"type": "long"
},
"usability_rating": {
"type": "long"
}
}
}
}
【问题讨论】:
-
能否提供您的索引映射和示例文档,以便我提供工作示例。
标签: elasticsearch elasticsearch-aggregation elasticsearch-dsl