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 final ParseField OTHER_BUCKET_KEY_FIELD = new ParseField("other_bucket_key");
|
||||||
|
|
||||||
public static class KeyedFilter implements Writeable<KeyedFilter>, ToXContent {
|
public static class KeyedFilter implements Writeable<KeyedFilter>, ToXContent {
|
||||||
|
|
||||||
static final KeyedFilter PROTOTYPE = new KeyedFilter("", new MatchAllQueryBuilder());
|
|
||||||
private final String key;
|
private final String key;
|
||||||
private final QueryBuilder<?> filter;
|
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() {
|
public String key() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
@ -92,19 +104,6 @@ public class FiltersAggregator extends BucketsAggregator {
|
||||||
return builder;
|
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
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(key, filter);
|
return Objects.hash(key, filter);
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class FiltersAggregatorBuilder extends AggregatorBuilder<FiltersAggregato
|
||||||
filters = new ArrayList<>(filtersSize);
|
filters = new ArrayList<>(filtersSize);
|
||||||
if (keyed) {
|
if (keyed) {
|
||||||
for (int i = 0; i < filtersSize; i++) {
|
for (int i = 0; i < filtersSize; i++) {
|
||||||
filters.add(KeyedFilter.PROTOTYPE.readFrom(in));
|
filters.add(new KeyedFilter(in));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < filtersSize; i++) {
|
for (int i = 0; i < filtersSize; i++) {
|
||||||
|
|
Loading…
Reference in New Issue