elasticsearch 7.7断开查询

6fe3ivhb  于 2021-06-14  发布在  ElasticSearch
关注(0)|答案(1)|浏览(1309)

它在7.6.2上运行,但自从升级到7.7后就停止工作了,不知道为什么?
我正在用嵌套的或嵌套的must进行查询,所以在三列上必须是5或6。
我正在使用laravel scout驱动程序进行ElasticSearchbabenkoivan/scout elasticsearch驱动程序
谢谢:)!

"query": {
    "bool": {
      "must": [
        {
          "bool": {
            "should": [
              {
                "bool": {
                  "must": [
                    [
                      {
                        "term": {
                          "section": "205"
                        }
                      },
                      {
                        "term": {
                          "profile": "40"
                        }
                      },
                      {
                        "term": {
                          "rim_size": "17"
                        }
                      }
                    ]
                  ]
                }
              }
            ]
          }
        },
        {
          "bool": {
            "should": [
              [
                {
                  "term": {
                    "supplier_id": 3
                  }
                }
              ]
            ]
          }
        }
      ]
    }
  },

错误:

{
   "error":{
      "root_cause":[
         {
            "type":"x_content_parse_exception",
            "reason":"[1:106] [bool] failed to parse field [must]"
         }
      ],
      "type":"x_content_parse_exception",
      "reason":"[1:106] [bool] failed to parse field [must]",
      "caused_by":{
         "type":"x_content_parse_exception",
         "reason":"[1:106] [bool] failed to parse field [should]",
         "caused_by":{
            "type":"x_content_parse_exception",
            "reason":"[1:106] [bool] failed to parse field [must]",
            "caused_by":{
               "type":"illegal_state_exception",
               "reason":"expected value but got [START_ARRAY]"
            }
         }
      }
   },
   "status":400
}
rggaifut

rggaifut1#

您的数据库中有两个嵌套数组 bool/must ,您需要删除一个:

"must": [
      >>>       [
                  {
                    "term": {
                      "section": "205"
                    }
                  },
                  {
                    "term": {
                      "profile": "40"
                    }
                  },
                  {
                    "term": {
                      "rim_size": "17"
                    }
                  }
      >>>       ]
              ]

它应该是这样的:

"must": [
                  {
                    "term": {
                      "section": "205"
                    }
                  },
                  {
                    "term": {
                      "profile": "40"
                    }
                  },
                  {
                    "term": {
                      "rim_size": "17"
                    }
                  }
              ]

相关问题