PurpleVermont
PurpleVermont

Reputation: 1241

Using Elastic Query DSL in Kibana Discover to enable more_like_this etc

The Kibana documentation says:

When lucene is selected as your query language you can also submit queries using the Elasticsearch Query DSL.

However, whenever I try to enter such a query in the Discover pane, I get a parse error. These are queries that work fine in the Dev Tools pane.

For example, if I try even a simple query like this:

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

I get the following error:

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)

(I've removed my domain above and replaced with <mydomain>)

The above query works fine and returns results using cURL on the command line, or using

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

In the Dev Tools console.

I'm hoping to use the more_like_this query from the Discover panel, so (I think) I will need to use the Query DSL and not just use the straight lucene query syntax. But if there's a way to use the specialty queries like that using straight lucene (or kuery) that would be great.

Upvotes: 1

Views: 2326

Answers (1)

Val
Val

Reputation: 217254

The reason is simply because the input box only supports whatever you include inside the query section, so if you input this, it will work:

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

It makes sense if you think about it, i.e. the aggs section makes no sense in the Discover pane and the from/size attributes are already taken care of by the default settings.

If you look at the full query DSL, you'll see that there are several sections: query, aggs, from, size, _source, highlight, etc. In the Discover pane, you should only specify whatever goes into the query section, nothing else.

Upvotes: 4

Related Questions