question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

filter_path parameter

See original GitHub issue

Hi I was wondering if the filter_path parameter could be specified when building query, to avoid parsing huge elasticsearch responses

Here is my use case: I have the following query where

  • I execute a first term aggregation that returns a large number of buckets
  • then execute a metric aggregation on this bucket (avg in this example)
  • and finally a sum_bucket aggregation
  • When I run this query, the output contains all the intermediary my_huge_bucket.my_huge_bucket_metric results but I am only interested by the sum_bucket metric.

Is there a way to strip the intermediary aggregation from the result?

{
  "size": 0,
  "aggs": {
    "my_sum_bucket": {
      "sum_bucket": {
        "buckets_path": "my_huge_bucket.my_huge_bucket_metric"
      }
    },
    "my_huge_bucket": {
      "terms": {
        "field": "some_field",
        "size": 0
      },
      "aggs": {
        "my_huge_bucket_metric": {
          "avg": {
            "field": "some_field"
          }
        }
      }
    }
  }
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
spalgercommented, May 20, 2016

@ilovett the q parameter is actually the lucene query string, not a url query string.

To specify arbitrary query string parameters all you need to do is add them to the root of the object passed to any api method. So @ilovett 's example would become:

client.search({
  index: 'myindex',
  filter_path: 'aggs.**.sum_bucket',
  body: {
    size: 0,
    aggs: { ... }
  }
})

That said, I would also like to add actual support for this and get it listed in the api conventions, so I’ll leave this open

0reactions
spalgercommented, May 20, 2016

Yeah, that’s a fair point. Thanks for the tip. I’ll probably update the api docs to have the api conventions at the top of each page, rather than on a new page. Unfortunately they are already so big 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

Common options | Elasticsearch Guide [8.5] | Elastic
Response Filteringedit. All REST APIs accept a filter_path parameter that can be used to reduce the response returned by Elasticsearch. This parameter takes...
Read more >
ElasticSearch: How to use filter_path parameter in POST body
All REST APIs accept a filter_path parameter that can be used to reduce the response returned by Elasticsearch.
Read more >
New-DatabaseDocumentation - SQL Change Automation 3
Alternatively, you can use the TemporaryDatabaseServer parameter to specify a SQL Server instance for the temporary ... -FilterPath <System.
Read more >
Unable to add maxConcurrentSearches,filterPath in mSearch
I've noticed that mSearch will mess up the request when parameters like maxConcurrentSearches are added: Here's a request with only body ...
Read more >
WicketFilter (Wicket Parent 10.0.0-M1-SNAPSHOT API)
Either get the filterPath retrieved from web.xml, or if not found the old (1.3) way via a filter mapping param. protected String.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found