首页 > 解决方案 > PHP + Elasticsearch - 从 Elastic2 到 Elastic6

问题描述

有人可以解释一下这个需要从 Elasticsearch 2 翻译到 Elasticsearch 6 的查询的含义吗?

$query = '{
        "query": {
            "filtered": {
                "filter": {
                    "bool": {
                        "must": [
                            { "term": { "pouzivatelId": "5b0e65022a35d13df2236183" } },
                            { "term": { "route": "Search:default" } },
                            { "term": { "parametre.hladat": 1 } }
                        ]
                    }
                }
            }
        }
    }';


$resp = $this->elastica->request('log/user/_search/exists', Elastica\Request::POST, json_decode($query, true))
    ->getData();

我不明白一些事情。

  1. 网址 - 用户。我认为这是对 _type 的查询
  2. 网址 - 存在部分。我找不到这方面的文档
  3. 查询 - 它与 Elastic 6 兼容吗?

谢谢你。

标签: phpelasticsearchrequest

解决方案


  1. 这将起作用,日志是索引,用户是类型。请注意,如果您转到 es 6.0,则只能使用一种映射类型(https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html)。2.x 到 6.x 之间的映射也发生了变化,但这不是你的问题。
  2. 使用: size=0&terminate_after=1 代替(https://www.elastic.co/guide/en/elasticsearch/reference/5.5/break_50_search_changes.html),存在已被删除。
  3. 不,试试这个:

    $query = '{ "query": { "bool": { "must": [ { "term": { "pouzivatelId": "5b0e65022a35d13df2236183" } }, { "term": { "route": "Search:default " } }, { "term": { "parametre.hladat": 1 } } ] } } }';


推荐阅读