代码之家  ›  专栏  ›  技术社区  ›  PurpleVermont

在Kibana Discover中使用弹性查询DSL以启用更多类似于此的

  •  1
  • PurpleVermont  · 技术社区  · 6 年前

    Kibana文件中说:

    选择lucene作为查询语言时,您还可以提交 使用Elasticsearch查询DSL进行查询。

    然而,每当我尝试在发现窗格中输入这样的查询时,就会出现一个解析错误。这些查询在“开发工具”窗格中运行良好。

    例如,如果我尝试这样一个简单的查询:

    {"query":{"match_phrase":{"summary":"stochastic noise"}}}
    

    我得到以下错误:

    Discover: [parsing_exception] no [query] registered for [query], with { line=1 & col=356 }    
    
    Error: [parsing_exception] no [query] registered for [query], with { line=1 & col=356 }
        at respond (http://<mydomain>:5601/bundles/vendors.bundle.js?v=16602:111:161556)
        at checkRespForFailure (http://<mydomain>:5601/bundles/vendors.bundle.js?v=16602:111:160796)
        at http://<mydomain>:5601/bundles/vendors.bundle.js?v=16602:105:285566
        at processQueue (http://<mydomain>:5601/bundles/vendors.bundle.js?v=16602:58:132456)
        at http://<mydomain>:5601/bundles/vendors.bundle.js?v=16602:58:133349
        at Scope.$digest (http://<mydomain>:5601/bundles/vendors.bundle.js?v=16602:58:144239)
        at Scope.$apply (http://<mydomain>:5601/bundles/vendors.bundle.js?v=16602:58:147018)
        at done (http://<mydomain>:5601/bundles/vendors.bundle.js?v=16602:58:100026)
        at completeRequest (http://<mydomain>:5601/bundles/vendors.bundle.js?v=16602:58:104697)
        at XMLHttpRequest.xhr.onload (http://<mydomain>:5601/bundles/vendors.bundle.js?v=16602:58:105435)
    

    (我已删除上面的域并替换为 <mydomain> )

    上述查询工作正常,使用命令行上的cURL或

    GET /_search
    {
      "query": {
        "match_phrase": {
          "summary": "stochastic noise"
        }
      }
    }
    

    在开发工具控制台中。

    我希望使用 more_like_this 从Discover面板进行查询,因此(我认为)我需要使用查询DSL,而不仅仅是使用直接的lucene查询语法。但是如果有一种方法可以使用像直接lucene(或kuery)这样的专业查询,那就太好了。

    1 回复  |  直到 6 年前
        1
  •  4
  •   Val    6 年前

    原因很简单,因为输入框只支持 query 节,因此如果您输入此项,它将起作用:

    {"match_phrase":{"summary":"stochastic noise"}}
    

    如果你仔细想想,也就是 aggs 部分在发现窗格和 from/size 默认设置已处理属性。

    如果查看完整的查询DSL,您将看到有几个部分: 查询 ,则, aggs公司 ,则, from ,则, size ,则, _source ,则, highlight ,等等。在发现窗格中,您应该只指定进入 查询 节,没有其他内容。