parent
c8af7edb24
commit
d62376ce33
|
@ -58,8 +58,6 @@ public class FiltersAggregator extends BucketsAggregator {
|
|||
public static final ParseField OTHER_BUCKET_KEY_FIELD = new ParseField("other_bucket_key");
|
||||
|
||||
public static class KeyedFilter implements Writeable<KeyedFilter>, ToXContent {
|
||||
|
||||
static final KeyedFilter PROTOTYPE = new KeyedFilter("", new MatchAllQueryBuilder());
|
||||
private final String key;
|
||||
private final QueryBuilder<?> filter;
|
||||
|
||||
|
@ -78,6 +76,20 @@ public class FiltersAggregator extends BucketsAggregator {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read from a stream.
|
||||
*/
|
||||
public KeyedFilter(StreamInput in) throws IOException {
|
||||
key = in.readString();
|
||||
filter = in.readQuery();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeString(key);
|
||||
out.writeQuery(filter);
|
||||
}
|
||||
|
||||
public String key() {
|
||||
return key;
|
||||
}
|
||||
|
@ -92,19 +104,6 @@ public class FiltersAggregator extends BucketsAggregator {
|
|||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyedFilter readFrom(StreamInput in) throws IOException {
|
||||
String key = in.readString();
|
||||
QueryBuilder<?> filter = in.readQuery();
|
||||
return new KeyedFilter(key, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeString(key);
|
||||
out.writeQuery(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(key, filter);
|
||||
|
|
|
@ -100,7 +100,7 @@ public class FiltersAggregatorBuilder extends AggregatorBuilder<FiltersAggregato
|
|||
filters = new ArrayList<>(filtersSize);
|
||||
if (keyed) {
|
||||
for (int i = 0; i < filtersSize; i++) {
|
||||
filters.add(KeyedFilter.PROTOTYPE.readFrom(in));
|
||||
filters.add(new KeyedFilter(in));
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < filtersSize; i++) {
|
||||
|
|
Loading…
Reference in New Issue