当前位置: 代码迷 >> 综合 >> Elasticsearch——》解决:[term] query does not support array of values
  详细解决方案

Elasticsearch——》解决:[term] query does not support array of values

热度:27   发布时间:2024-02-20 00:38:33.0

请参考:总结——》【Elasticsearch】

一、现象

1、查询语句
GET goods/_search
{
    "from": 0,"size": 10,"query": {
    "bool": {
    "must": [{
    "term": {
    "couponIds": [1,2]}}]}}
}
2、错误现象
{
    "error" : {
    "root_cause" : [{
    "type" : "parsing_exception","reason" : "[term] query does not support array of values","line" : 9,"col" : 26}],"type" : "parsing_exception","reason" : "[term] query does not support array of values","line" : 9,"col" : 26},"status" : 400
}

在这里插入图片描述

二、原因

数组查询要用关键字terms ,不是term

三、解决

GET goods/_search
{
    "from": 0,"size": 10,"query": {
    "bool": {
    "must": [{
    "terms": {
    "couponIds": [1,2]}}]}}
}

在这里插入图片描述

  相关解决方案