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.

Nested aggregation with path param

See original GitHub issue

Suppose we have next doc: `{ …

"product" : {
    "properties" : {
        "resellers" : { 
            "type" : "nested",
            "properties" : {
                "name" : { "type" : "text" },
                "price" : { "type" : "double" }
            }
        }
    }
}

}`

Is there a way to built next aggregation query: `{

"query" : {
    "match" : { "name" : "led tv" }
},
"aggs" : {
    "resellers" : {
        "nested" : {
            "path" : "resellers"
        },
        "aggs" : {
            "min_price" : { "min" : { "field" : "resellers.price" } }
        }
    }
}

}`

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

10reactions
sudo-suhascommented, Jul 8, 2017

A bit late but here you go:

bodybuilder()
    .query('match', 'name', 'led tv')
    .aggregation(
        'nested', 
        { path: 'resellers' }, 
        'resellers',
        agg => agg.aggregation('min', 'resellers.price', 'min_price')
    )
    .build()
0reactions
sudo-suhascommented, Aug 14, 2017

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Elasticsearch aggregation with reverse_nested path parameter
The nested query/aggregation let you query/aggregate on nested objects. You have to specify the path which the query/aggregation goes into.
Read more >
Nested aggregation | Elasticsearch Guide [8.5] | Elastic
A special single bucket aggregation that enables aggregating nested documents. ... As you can see above, the nested aggregation requires the path of...
Read more >
Missing path field for nested aggregation ” + ... - Opster
This guide will help you check for common problems that cause the log ” Missing path field for nested aggregation ” + aggregationName...
Read more >
Aggregations - OpenSearch documentation
The inner aggs keyword begins a new nested aggregation. The syntax of the parent aggregation and the nested aggregation is the same. Nested...
Read more >
Bucket Aggregations - Open Distro for Elasticsearch
You can also aggregate values from nested documents to their parent; this aggregation is called reverse_nested . You can use reverse_nested to aggregate...
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