这在7.6.2上有效,但是自升级到7.7以来,它已停止工作,不知道为什么?
我正在使用嵌套或必须嵌套的查询,因此它在三列上必须为5 5 5或6 6 6。
我正在使用laravel scout驱动程序进行 flex 搜索babenkoivan / scout-elasticsearch-driver
谢谢 :)!

  "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
}

最佳答案

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

              "must": [
      >>>       [
                  {
                    "term": {
                      "section": "205"
                    }
                  },
                  {
                    "term": {
                      "profile": "40"
                    }
                  },
                  {
                    "term": {
                      "rim_size": "17"
                    }
                  }
      >>>       ]
              ]
它应该看起来像这样:
              "must": [
                  {
                    "term": {
                      "section": "205"
                    }
                  },
                  {
                    "term": {
                      "profile": "40"
                    }
                  },
                  {
                    "term": {
                      "rim_size": "17"
                    }
                  }
              ]

08-28 14:03