Elasticsearch 2.x到5.x查询问题

Elasticsearch 2.x到5.x查询问题,
Warning: implode(): Invalid arguments passed in /data/phpspider/zhask/webroot/tpl/detail.html on line 45
,,下面的查询需要从版本2.x更改为版本5.x filtered=>bool 但是应该不支持多个查询 "query": { "filtered": { "query": { "match_all": {} }, "filter": { "bool": { "must": [{ "query": {

下面的查询需要从版本2.x更改为版本5.x

filtered=>bool

但是应该不支持多个查询

"query": {
    "filtered": {
        "query": {
            "match_all": {}
        },
        "filter": {
            "bool": {
                "must": [{
                    "query": {
                        "match": {
                            "valid": "Y"
                        }
                    }
                }],
                "should": [
                    { "query": { "wildcard": { "name": { "value": '*' + searchValue + '*' } } } },
                    { "query": { "wildcard": { "fisrtname": { "value": '*' + searchValue + '*' } } } }   
                ]
            }
        }
    }
},
"sort": [{
    "name": {
        "order": "asec"
    }
}],
"from": 0,
"size": 15
大概是这样的:

{
  "query": {
    "bool": {
      "filter": {
        "bool": {
          "must": [
            {
              "match": {
                "valid": "Y"
              }
            }
          ],
          "should": [
            {
              "wildcard": {
                "name": {
                  "value": "searchValue"
                }
              }
            },
            {
              "wildcard": {
                "firstname": {
                  "value": "searchValue"
                }
              }
            }
          ]
        }
      }
    }
  },
  "sort": [
    {
      "name": {
        "order": "asc"
      }
    }
  ],
  "from": 0,
  "size": 15
}

第一个bool.filter包装是这样,所有内容都被视为过滤器,而不是评分和可能的缓存。

感谢它的工作。但是唯一的问题是排序。我更正了答案,排序的字段名不正确。不,它仍然不起作用。排序在新版本中发生了变化,它的工作方式与v2.x不同。在新版本中,它说我们需要更改关键字上的映射。参考:[