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

Added support for sorting buckets based on single-bucket sub aggregation... #5321

Closed
wants to merge 1 commit into from
Closed

Added support for sorting buckets based on single-bucket sub aggregation... #5321

wants to merge 1 commit into from

Conversation

uboness
Copy link
Contributor

@uboness uboness commented Mar 3, 2014

...s (based on their doc_count)

Closes #5253

public int compare(Terms.Bucket o1, Terms.Bucket o2) {
long v1 = ((SingleBucketAggregator) aggregator).bucketDocCount(((InternalTerms.Bucket) o1).bucketOrd);
long v2 = ((SingleBucketAggregator) aggregator).bucketDocCount(((InternalTerms.Bucket) o2).bucketOrd);
return asc ? Long.compare(v1, v2) : Long.compare(v2, v1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just beware that Long.compare is Java 1.7 only, you might want to use Longs.compare from Guava instead when merging to 1.x

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grrrrr.... bitten... good catch!

@jpountz
Copy link
Contributor

jpountz commented Mar 3, 2014

The change looks good to me. For consistency, should we have the same feature on histograms?

@uboness
Copy link
Contributor Author

uboness commented Mar 3, 2014

oh... good one... we probably should, will add it

…urrent hierarchy. This is supported as long as the aggregation in the specified order path are of a single-bucket type, where the last aggregation in the path points to either a single-bucket aggregation or a metrics one. If it's a single-bucket aggregation, the sort will be applied on the document count in the bucket (i.e. doc_count), and if it is a metrics type, the sort will be applied on the pointed out metric (in case of a single-metric aggregations, such as avg, the sort will be applied on the single metric value)

 Closes #5253
@uboness
Copy link
Contributor Author

uboness commented Mar 5, 2014

replaced by #5340

@uboness uboness closed this Mar 5, 2014
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

Successfully merging this pull request may close these issues.

Sorting on SingleBucketAggregation's should be possible
2 participants