Skip to content

Conversation

@nazarewk
Copy link

@nazarewk nazarewk commented Apr 14, 2017

This change enables ordering terms by containing nested iaggregation inside order path. #16838

The changes are compatible with both master and 5.3 branches.

Only thing I am not entirely sure of is the ValueCountAggregator.metric() change.

PS: It is somehow related to #22303 but I took entirely different (and way less invasive) approach and written the tests.

@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@nazarewk nazarewk changed the title Enabling sorting terms aggregation by aggregations containing nested Enabled sorting terms aggregation by aggregations containing nested Apr 14, 2017
@nazarewk nazarewk force-pushed the feature/terms-order-nested branch from 5379479 to 51c1f39 Compare April 18, 2017 10:09
@jimczi jimczi added the :Analytics/Aggregations Aggregations label Apr 19, 2017
@jimczi
Copy link
Contributor

jimczi commented Apr 19, 2017

@colings86 can you take a look ?

@colings86
Copy link
Contributor

@nazarewk Thank you for your contribution, but I have the same concerns with this PR as I mentioned in the the issue and in @idozorenko 's PR which is that this relies on getting the first aggregator instance int he multi-bucket aggregator wrapper and using it for the sorting. This will have issues when collecting from multiple buckets because the values required for sorting the second third etc. buckets are not in the first aggregator instance but in the other instance's that the multi-bucket aggregator wrapper has created.

@nazarewk
Copy link
Author

@colings86 Can you think of any use case for which i could write tests exposing this issue? I am not proficient enough in elasticsearch codebase to conceive one.

I am already using this in my project and I am not getting any improper computations on mixing nested with terms yet.

My first impulse was to make a wrapper around MultiBucketAggregatorWrapper, but SingleBucketAggregator is just alias for Aggregator which is extension of BucketsAggregator and they both have all the methods final. I know Java, but have never used it much so i am not sure if there is any reason for this and i could just simply final and override methods or extract interfaces?

@nazarewk
Copy link
Author

I believe I have encountered the error:

{
  "error": {
    "root_cause": [],
    "type": "reduce_search_phase_exception",
    "reason": "[reduce] ",
    "phase": "fetch",
    "grouped": true,
    "failed_shards": [],
    "caused_by": {
      "type": "class_cast_exception",
      "reason": "org.elasticsearch.search.aggregations.bucket.nested.InternalNested cannot be cast to org.elasticsearch.search.aggregations.InternalMultiBucketAggregation"
    }
  },
  "status": 503
}

I tried to make extended_stats_bucket out of nested>terms>reverse_nested>nested>filter._count

@dakrone
Copy link
Member

dakrone commented Aug 15, 2017

@colings86 ping on this issue, is this still something we should pursue?

@nazarewk
Copy link
Author

nazarewk commented Aug 15, 2017 via email

@colings86
Copy link
Contributor

colings86 commented Aug 16, 2017

@dakrone It would be good to find a solution to this but as I mentioned above, I think that the current approach will suffer from issues as I described. I don't know of a way to get around these issues. I hope we will eventually find a solution but I think its going to be more complex and take longer to achieve than this approach

@colings86
Copy link
Contributor

This has now been fixed via #26683 so I'm going to close this PR. Thanks for the contribution @nazarewk

@colings86 colings86 closed this Oct 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants