-
-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add filter aggregations #64
Conversation
Thanks @johannes-scharlach! At a high level this LGTM and I'll take a closer look in the next week or so with more specific feedback. Also pinging @arielshad in case if you have any thoughts on this approach. |
@danpaz I'd love to see this in a near-future version of bodybuilder, so that I don't need to maintain my own fork. Would you like me to rebase on top of the latest changes? |
I don't think a rebase is necessary, thanks. Can you add a section to the readme showing how to make a filter aggregation? Can you also add a test to test/index.js as a sort of integration test showing that the feature works as you expected? Maybe that test and the readme can show how you might create this query from the docs: https://www.elastic.co/guide/en/elasticsearch/reference/2.4/search-aggregations-bucket-filter-aggregation.html#search-aggregations-bucket-filter-aggregation |
The test is slightly different, but the readme looks like the ES documentation :) Let me know if I should change the test also or you expected something different. |
This is great! I think we can move forward with this while we continue to discuss more structural changes separately in #71 (and chances are a more drastic change would have to be a semver major bump anyway). |
I also had the need for a filter aggregation, but chose a more generic approach than #42.
I'm not sure if it's valid to choose any filter that bodybuilder (or in particular the new FilterBuilder) generates, but in particular the terms filter works quite well like this.
A signature like
function filterAggregation(filterType, filterField, filterValue, aggregationName)
seemed to simple, since it would essentially reduce the API to one particular filter.Let me know what you think about this approach!