Skip to content
This repository has been archived by the owner on Nov 14, 2021. It is now read-only.

Aggregation nesting #22

Open
wanganhong opened this issue Jun 19, 2018 · 2 comments
Open

Aggregation nesting #22

wanganhong opened this issue Jun 19, 2018 · 2 comments

Comments

@wanganhong
Copy link

How can i make an aggregations like the following examples?

"aggs": {
                "results": {
                    "date_histogram": {
                        "field": "time",
                        "interval": 'day'
                    },
                    "aggs": {
                        "to-child": {
                            "children": {
                                "type": "status"
                            },
                            "aggs": {
                                "inner": {
                                    "terms": {
                                        "field": "handle_flag",
                                        "size": 10
                                    }
                                }
                            }
                        }
                    }
                }
            }
@wanganhong
Copy link
Author

I got it!
Used:

aggs1 = Aggregate.date_histogram('results', 'time', 'day')
aggs2 = Aggregate.children('to-child', 'status')
aggs3 = Aggregate.terms('inner', 'handle_flag')
aggs2.aggregate(aggs3)
aggs1.aggregate(aggs2)
print aggs1.dict()

Is there a simpler way?

@Fizzadar
Copy link
Owner

@wanganhong unfortunately not; for more complex aggregations I never managed to come up with a decent API! Sadly I no longer have any time to maintain this project beyond bugs; feel free to PR though :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants