This commit is contained in:
Colin Goodheart-Smithe 2015-04-13 14:34:53 +01:00
parent 306d94adb9
commit 392f9ce1f8
5 changed files with 8 additions and 26 deletions

View File

@ -19,6 +19,9 @@
package org.elasticsearch.index.query;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.similarities.Similarity;
import org.elasticsearch.ElasticsearchIllegalArgumentException;
import org.elasticsearch.common.xcontent.XContentBuilder;
@ -27,7 +30,7 @@ import java.io.IOException;
/**
* CommonTermsQuery query is a query that executes high-frequency terms in a
* optional sub-query to prevent slow queries due to "common" terms like
* stopwords. This query basically builds 2 queries off the {@link #addAggregator(Term)
* stopwords. This query basically builds 2 queries off the {@link #add(Term)
* added} terms where low-frequency terms are added to a required boolean clause
* and high-frequency terms are added to an optional boolean clause. The
* optional clause is only executed if the required "low-frequency' clause

View File

@ -27,7 +27,6 @@ import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.search.aggregations.reducers.ReducerBuilder;
import java.io.IOException;
import java.util.List;
@ -39,7 +38,6 @@ import java.util.Map;
public abstract class AggregationBuilder<B extends AggregationBuilder<B>> extends AbstractAggregationBuilder {
private List<AbstractAggregationBuilder> aggregations;
private List<ReducerBuilder<?>> reducers;
private BytesReference aggregationsBinary;
private Map<String, Object> metaData;
@ -62,18 +60,6 @@ public abstract class AggregationBuilder<B extends AggregationBuilder<B>> extend
return (B) this;
}
/**
* Add a sub get to this bucket get.
*/
@SuppressWarnings("unchecked")
public B subAggregation(ReducerBuilder<?> reducer) {
if (reducers == null) {
reducers = Lists.newArrayList();
}
reducers.add(reducer);
return (B) this;
}
/**
* Sets a raw (xcontent / json) sub addAggregation.
*/
@ -135,7 +121,7 @@ public abstract class AggregationBuilder<B extends AggregationBuilder<B>> extend
builder.field(type);
internalXContent(builder, params);
if (aggregations != null || aggregationsBinary != null || reducers != null) {
if (aggregations != null || aggregationsBinary != null) {
builder.startObject("aggregations");
if (aggregations != null) {
@ -144,12 +130,6 @@ public abstract class AggregationBuilder<B extends AggregationBuilder<B>> extend
}
}
if (reducers != null) {
for (ReducerBuilder<?> subAgg : reducers) {
subAgg.toXContent(builder, params);
}
}
if (aggregationsBinary != null) {
if (XContentFactory.xContentType(aggregationsBinary) == builder.contentType()) {
builder.rawField("aggregations", aggregationsBinary);

View File

@ -105,7 +105,7 @@ public abstract class Aggregator extends BucketCollector implements Releasable {
* Build an empty aggregation.
*/
public abstract InternalAggregation buildEmptyAggregation();
/** Aggregation mode for sub aggregations. */
public enum SubAggCollectionMode {

View File

@ -197,7 +197,6 @@ public class AggregatorParsers {
if (subFactories != null) {
throw new SearchParseException(context, "Aggregation [" + aggregationName + "] cannot define sub-aggregations");
}
// TODO: should we validate here like aggs?
factories.addReducer(reducerFactory);
}
}

View File

@ -150,9 +150,9 @@ public class BucketHelpers {
}
public static Double resolveBucketValue(InternalMultiBucketAggregation<?, ? extends InternalMultiBucketAggregation.Bucket> agg,
InternalMultiBucketAggregation.Bucket bucket, List<String> aggPathsList, GapPolicy gapPolicy) {
InternalMultiBucketAggregation.Bucket bucket, List<String> aggPathAsList, GapPolicy gapPolicy) {
try {
Object propertyValue = bucket.getProperty(agg.getName(), aggPathsList);
Object propertyValue = bucket.getProperty(agg.getName(), aggPathAsList);
if (propertyValue == null) {
throw new AggregationExecutionException(DerivativeParser.BUCKETS_PATH.getPreferredName()
+ " must reference either a number value or a single value numeric metric aggregation");