首页 > 解决方案 > Kibana Discover 中的 DSL 查询不能用作 Kibana 开发工具

问题描述

以下是具有内部命中的 MappingIndex、插入值和嵌套搜索查询

** 创建弹性映射索引**

PUT employee
{
    "mappings": {
        "emp_db": {
            "properties": {
                "emp_group": {
                    "type": "text"
                },
                "company": {
                    "type": "nested",
                    "properties": {
                        "employee": {
                                    "properties": {
                                        "first": {
                                            "type": "text",
                                            "fielddata": true
                                        },
                                        "last": {
                                            "type": "text",
                                            "fielddata": true
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

** 在创建的弹性索引映射上插入少量值 **

PUT employee/_doc/1
{
  "emp_group" : "000001",
  "company": [
      {
            "employee": {
                "first": "Alice",
                "last":"Smith"
              }
            },
            {
            "employee":{
                "first": "Pat",
                "last":"Smith"
              }
            },
            {
            "employee":{
                "first": "Alice",
                "last":"Hazelwood"
            }
        }
  ]
}

** 嵌套查询内部命中(它在 Kibana 开发工具中工作,但在 Kibana Discover 中不工作)**

GET employee/_search
{
  "_source":false,
  "query": {
    "nested": {
      "path": "company",
      "query": {
        "bool": {
          "must": [
            { "match": { "company.employee.first": "Alice" }},
            { "match": { "company.employee.last": "Smith" }}
          ]
        }
      },
      "inner_hits": {

          "_source": false,
          "docvalue_fields": [
            "company.employee.first",
            "company.employee.last"
            ]
      }
    }
  }
}

上面嵌套的内部命中查询完美地工作并在 Kibana Dev Tools 中给了我正确的结果,但是当我在 Kibana Discover (filter-> Edit Query DSL) 中运行相同的查询时,它没有给我任何结果。

非常感谢任何帮助..

标签: elasticsearchkibana-6

解决方案


推荐阅读