Skip to content
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

Global Aggregations #4

Closed
kbredemeier opened this issue Sep 9, 2015 · 3 comments
Closed

Global Aggregations #4

kbredemeier opened this issue Sep 9, 2015 · 3 comments

Comments

@kbredemeier
Copy link

The following code raises an SystemStackError:

search do
  aggregation :all do
    global
    aggregation :foo do
      terms field: "bar"
    end
  end
end

What I would like to archive is the following:

"aggregations": {
   "all": {
       "global": {},
       "aggregations": {
           "foo": {
               "terms": {
                   "field": "bar"
               }
           }
       }
   }
}

The exception results from nesting the aggregations. Am I using it wrong or is this just not implemented yet?

I looked further into this: Since the global aggregation is structurally similar to a nested aggregation I thought it should be used like one:

search do
  aggregation :all do
    global do
      aggregation :foo do
        terms field: "bar"
      end
    end
  end
end

But this leads to an other error. aggregation is not defined. By comparing the Global class with the Nested class I noticed that Global includes BaseComponent while Nested includes BaseAggregationComponent. Currently I am working around this by monkeypatching the Global class and including BaseAggregationComponent.

I would love to create a pull request if this is the intended way of using the gloabl aggregation.

@karmi
Copy link

karmi commented Oct 7, 2015

Hi, yes, I think you're right and this is an oversight on part of the implementation -- making the global method take the block seems like the correct way. Do you feel like creating the pull request?

(Sorry for such a delayed response!, I was tied with something else...)

karmi referenced this issue in elastic/elasticsearch-ruby Dec 21, 2015
Changed global aggregation to behave like a nested aggregation

Related: #213

Closes #228
karmi referenced this issue in elastic/elasticsearch-ruby Dec 21, 2015
@gmile
Copy link

gmile commented Jan 5, 2016

@karmi now that elastic/elasticsearch-ruby#228 is merged, this should be closed?

@karmi
Copy link

karmi commented Jan 5, 2016

@gmile Yes, absolutely, thanks for the ping! And thanks for the other PRs and comments, will try to have a look at them this week!

@karmi karmi closed this as completed Jan 5, 2016
picandocodigo referenced this issue in elastic/elasticsearch-ruby Jan 10, 2022
Changed global aggregation to behave like a nested aggregation

Related: #213

Closes #228
picandocodigo referenced this issue in elastic/elasticsearch-ruby Jan 10, 2022
@technige technige transferred this issue from elastic/elasticsearch-ruby Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants