Skip to content

Terms Aggregation: Handle a list of order options #8612

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

Closed
mtraynham opened this issue Nov 23, 2014 · 1 comment
Closed

Terms Aggregation: Handle a list of order options #8612

mtraynham opened this issue Nov 23, 2014 · 1 comment

Comments

@mtraynham
Copy link

It would be nice if you could use a list of ordering options instead of a single order. This is useful for when you need a secondary sort because the first one is of low cardinality.

Doesn't seem too hard to add after looking at the code. InternalOrder could be extended with with a class called InternalOrderChain that can take a list of InternalOrder objects in it's constructor. The comparator could use Guava's Ordering.compound:

    protected Comparator<Bucket> comparator(final Aggregator aggregator) {
        return Ordering.compound(FluentIterable
                .from(orders)
                .transform(new Function<InternalOrder, Comparator<? super Bucket>>() {
                    @Override public Comparator<? super Bucket> apply(InternalOrder input) {
                        return input.comparator(aggregator);
                    }
                })
                .toList()
        );
    }

The only thing that's a bit strange is the InternalOrder.Streams handling and any check to see if the InternalOrder is an Aggregation...

@mtraynham
Copy link
Author

Closing in favor of #6917

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

1 participant