Adressing comments
This commit is contained in:
parent
b01e3f0d3b
commit
cbcbe75cf0
|
@ -57,7 +57,7 @@ public class FiltersAggregator extends BucketsAggregator {
|
|||
public static final ParseField OTHER_BUCKET_FIELD = new ParseField("other_bucket");
|
||||
public static final ParseField OTHER_BUCKET_KEY_FIELD = new ParseField("other_bucket_key");
|
||||
|
||||
public static class KeyedFilter implements Writeable<KeyedFilter>, ToXContent, Comparable<KeyedFilter> {
|
||||
public static class KeyedFilter implements Writeable<KeyedFilter>, ToXContent {
|
||||
|
||||
static final KeyedFilter PROTOTYPE = new KeyedFilter("", EmptyQueryBuilder.PROTOTYPE);
|
||||
private final String key;
|
||||
|
@ -122,11 +122,6 @@ public class FiltersAggregator extends BucketsAggregator {
|
|||
return Objects.equals(key, other.key)
|
||||
&& Objects.equals(filter, other.filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(KeyedFilter o) {
|
||||
return this.key.compareTo(o.key);
|
||||
}
|
||||
}
|
||||
|
||||
private final String[] keys;
|
||||
|
|
|
@ -59,7 +59,7 @@ public class FiltersAggregatorBuilder extends AggregatorBuilder<FiltersAggregato
|
|||
private FiltersAggregatorBuilder(String name, List<KeyedFilter> filters) {
|
||||
super(name, InternalFilters.TYPE);
|
||||
// internally we want to have a fixed order of filters, regardless of the order of the filters in the request
|
||||
Collections.sort(filters);
|
||||
Collections.sort(filters, (KeyedFilter kf1, KeyedFilter kf2) -> kf1.key().compareTo(kf2.key()));
|
||||
this.filters = filters;
|
||||
this.keyed = true;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,9 @@ import org.elasticsearch.test.ESIntegTestCase;
|
|||
import org.hamcrest.Matchers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -488,13 +490,9 @@ public class FiltersIT extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
private static KeyedFilter[] randomOrder(KeyedFilter... filters) {
|
||||
for (int i = 0; i < filters.length; i++) {
|
||||
KeyedFilter tmp = filters[i];
|
||||
int index = randomInt(filters.length - 1);
|
||||
filters[i] = filters[index];
|
||||
filters[index] = tmp;
|
||||
}
|
||||
return filters;
|
||||
List<KeyedFilter> asList = Arrays.asList(filters);
|
||||
Collections.shuffle(asList);
|
||||
return asList.toArray(new KeyedFilter[filters.length]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue