diff options
author | Colin Goodheart-Smithe <colings86@users.noreply.github.com> | 2016-01-14 10:52:28 +0000 |
---|---|---|
committer | Colin Goodheart-Smithe <colings86@users.noreply.github.com> | 2016-01-26 15:13:43 +0000 |
commit | 11bafa18e1b1c6d9a95da57295fc9e2271f12ba7 (patch) | |
tree | 7cf3b0530f389b4bd9d46cf87e190b390079d1d0 /core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms | |
parent | 3b35754f5900286acdeb9ada7d2a988a9d177ecd (diff) |
Removes Aggregation Builders in place of AggregatorFactory implementations
Diffstat (limited to 'core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms')
7 files changed, 135 insertions, 313 deletions
diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/GlobalOrdinalsStringTermsAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/GlobalOrdinalsStringTermsAggregator.java index 1e7a0047ea..91e949e190 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/GlobalOrdinalsStringTermsAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/GlobalOrdinalsStringTermsAggregator.java @@ -347,7 +347,7 @@ public class GlobalOrdinalsStringTermsAggregator extends AbstractStringTermsAggr Map<String, Object> metaData) throws IOException { super(name, factories, valuesSource, order, bucketCountThresholds, null, aggregationContext, parent, collectionMode, showTermDocCountError, pipelineAggregators, metaData); - assert factories == null || factories.count() == 0; + assert factories == null || factories.countAggregators() == 0; this.segmentDocCounts = context.bigArrays().newIntArray(1, true); } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalOrder.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalOrder.java index b5e1e81479..f3f87c09dc 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalOrder.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalOrder.java @@ -96,7 +96,7 @@ class InternalOrder extends Terms.Order { public static boolean isCountDesc(Terms.Order order) { if (order == COUNT_DESC) { return true; - }else if (order instanceof CompoundOrder) { + } else if (order instanceof CompoundOrder) { // check if its a compound order with count desc and the tie breaker (term asc) CompoundOrder compoundOrder = (CompoundOrder) order; if (compoundOrder.orderElements.size() == 2 && compoundOrder.orderElements.get(0) == COUNT_DESC && compoundOrder.orderElements.get(1) == TERM_ASC) { @@ -106,6 +106,23 @@ class InternalOrder extends Terms.Order { return false; } + public static boolean isTermOrder(Terms.Order order) { + if (order == TERM_ASC) { + return true; + } else if (order == TERM_DESC) { + return true; + } else if (order instanceof CompoundOrder) { + // check if its a compound order with only a single element ordering + // by term + CompoundOrder compoundOrder = (CompoundOrder) order; + if (compoundOrder.orderElements.size() == 1 && compoundOrder.orderElements.get(0) == TERM_ASC + || compoundOrder.orderElements.get(0) == TERM_DESC) { + return true; + } + } + return false; + } + final byte id; final String key; final boolean asc; diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalTerms.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalTerms.java index 31285d20f8..6e5aaac2e8 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalTerms.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalTerms.java @@ -188,7 +188,7 @@ public abstract class InternalTerms<A extends InternalTerms, B extends InternalT } otherDocCount += terms.getSumOfOtherDocCounts(); final long thisAggDocCountError; - if (terms.buckets.size() < this.shardSize || this.order == InternalOrder.TERM_ASC || this.order == InternalOrder.TERM_DESC) { + if (terms.buckets.size() < this.shardSize || InternalOrder.isTermOrder(order)) { thisAggDocCountError = 0; } else if (InternalOrder.isCountDesc(this.order)) { thisAggDocCountError = terms.buckets.get(terms.buckets.size() - 1).docCount; diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregatorFactory.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregatorFactory.java index 0458f5fb01..37e50465ac 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregatorFactory.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregatorFactory.java @@ -42,8 +42,6 @@ import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFacto import org.elasticsearch.search.aggregations.support.ValuesSourceType; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; @@ -135,7 +133,7 @@ public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory<Values AggregationContext aggregationContext, Aggregator parent, SubAggCollectionMode subAggCollectMode, boolean showTermDocCountError, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { - if (includeExclude != null || factories.count() > 0 + if (includeExclude != null || factories.countAggregators() > 0 // we need the FieldData impl to be able to extract the // segment to global ord mapping || valuesSource.getClass() != ValuesSource.Bytes.FieldData.class) { @@ -182,7 +180,7 @@ public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory<Values } } - private List<Terms.Order> orders = Collections.singletonList(Terms.Order.count(false)); + private Terms.Order order = Terms.Order.compound(Terms.Order.count(false), Terms.Order.term(true)); private IncludeExclude includeExclude = null; private String executionHint = null; private SubAggCollectionMode collectMode = SubAggCollectionMode.DEPTH_FIRST; @@ -190,8 +188,8 @@ public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory<Values DEFAULT_BUCKET_COUNT_THRESHOLDS); private boolean showTermDocCountError = false; - public TermsAggregatorFactory(String name, ValuesSourceType valuesSourceType, ValueType valueType) { - super(name, StringTerms.TYPE, valuesSourceType, valueType); + public TermsAggregatorFactory(String name, ValueType valueType) { + super(name, StringTerms.TYPE, ValuesSourceType.ANY, valueType); } public TermsAggregator.BucketCountThresholds bucketCountThresholds() { @@ -204,18 +202,64 @@ public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory<Values } /** + * Sets the size - indicating how many term buckets should be returned + * (defaults to 10) + */ + public TermsAggregatorFactory size(int size) { + bucketCountThresholds.setRequiredSize(size); + return this; + } + + /** + * Sets the shard_size - indicating the number of term buckets each shard + * will return to the coordinating node (the node that coordinates the + * search execution). The higher the shard size is, the more accurate the + * results are. + */ + public TermsAggregatorFactory shardSize(int shardSize) { + bucketCountThresholds.setShardSize(shardSize); + return this; + } + + /** + * Set the minimum document count terms should have in order to appear in + * the response. + */ + public TermsAggregatorFactory minDocCount(long minDocCount) { + bucketCountThresholds.setMinDocCount(minDocCount); + return this; + } + + /** + * Set the minimum document count terms should have on the shard in order to + * appear in the response. + */ + public TermsAggregatorFactory shardMinDocCount(long shardMinDocCount) { + bucketCountThresholds.setShardMinDocCount(shardMinDocCount); + return this; + } + + /** * Sets the order in which the buckets will be returned. */ - public TermsAggregatorFactory order(List<Terms.Order> order) { - this.orders = order; + public TermsAggregatorFactory order(Terms.Order order) { + this.order = order; + return this; + } + + /** + * Sets the order in which the buckets will be returned. + */ + public TermsAggregatorFactory order(List<Terms.Order> orders) { + order(Terms.Order.compound(orders)); return this; } /** * Gets the order in which the buckets will be returned. */ - public List<Terms.Order> order() { - return orders; + public Terms.Order order() { + return order; } /** @@ -281,7 +325,6 @@ public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory<Values @Override protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { - Terms.Order order = resolveOrder(orders); final InternalAggregation aggregation = new UnmappedTerms(name, order, bucketCountThresholds.getRequiredSize(), bucketCountThresholds.getShardSize(), bucketCountThresholds.getMinDocCount(), pipelineAggregators, metaData); return new NonCollectingAggregator(name, aggregationContext, parent, factories, pipelineAggregators, metaData) { @@ -315,7 +358,6 @@ public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory<Values protected Aggregator doCreateInternal(ValuesSource valuesSource, AggregationContext aggregationContext, Aggregator parent, boolean collectsFromSingleBucket, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { - Terms.Order order = resolveOrder(orders); if (collectsFromSingleBucket == false) { return asMultiBucketAggregator(this, aggregationContext, parent); } @@ -415,11 +457,8 @@ public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory<Values if (executionHint != null) { builder.field(TermsAggregatorFactory.EXECUTION_HINT_FIELD_NAME.getPreferredName(), executionHint); } - builder.startArray(ORDER_FIELD.getPreferredName()); - for (Terms.Order order : orders) { - order.toXContent(builder, params); - } - builder.endArray(); + builder.field(ORDER_FIELD.getPreferredName()); + order.toXContent(builder, params); builder.field(SubAggCollectionMode.KEY.getPreferredName(), collectMode.parseField().getPreferredName()); if (includeExclude != null) { includeExclude.toXContent(builder, params); @@ -430,19 +469,14 @@ public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory<Values @Override protected TermsAggregatorFactory innerReadFrom(String name, ValuesSourceType valuesSourceType, ValueType targetValueType, StreamInput in) throws IOException { - TermsAggregatorFactory factory = new TermsAggregatorFactory(name, valuesSourceType, targetValueType); + TermsAggregatorFactory factory = new TermsAggregatorFactory(name, targetValueType); factory.bucketCountThresholds = BucketCountThresholds.readFromStream(in); factory.collectMode = SubAggCollectionMode.BREADTH_FIRST.readFrom(in); factory.executionHint = in.readOptionalString(); if (in.readBoolean()) { factory.includeExclude = IncludeExclude.readFromStream(in); } - int numOrders = in.readVInt(); - List<Terms.Order> orders = new ArrayList<>(numOrders); - for (int i = 0; i < numOrders; i++) { - orders.add(InternalOrder.Streams.readOrder(in)); - } - factory.orders = orders; + factory.order = InternalOrder.Streams.readOrder(in); factory.showTermDocCountError = in.readBoolean(); return factory; } @@ -457,16 +491,13 @@ public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory<Values if (hasIncExc) { includeExclude.writeTo(out); } - out.writeVInt(orders.size()); - for (Terms.Order order : orders) { - InternalOrder.Streams.writeOrder(order, out); - } + InternalOrder.Streams.writeOrder(order, out); out.writeBoolean(showTermDocCountError); } @Override protected int innerHashCode() { - return Objects.hash(bucketCountThresholds, collectMode, executionHint, includeExclude, orders, showTermDocCountError); + return Objects.hash(bucketCountThresholds, collectMode, executionHint, includeExclude, order, showTermDocCountError); } @Override @@ -476,7 +507,7 @@ public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory<Values && Objects.equals(collectMode, other.collectMode) && Objects.equals(executionHint, other.executionHint) && Objects.equals(includeExclude, other.includeExclude) - && Objects.equals(orders, other.orders) + && Objects.equals(order, other.order) && Objects.equals(showTermDocCountError, other.showTermDocCountError); } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsBuilder.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsBuilder.java deleted file mode 100644 index 3d8aff9b24..0000000000 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsBuilder.java +++ /dev/null @@ -1,276 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.search.aggregations.bucket.terms; - -import org.apache.lucene.util.automaton.RegExp; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode; -import org.elasticsearch.search.aggregations.ValuesSourceAggregationBuilder; - -import java.io.IOException; -import java.util.Locale; - -/** - * Builder for the {@link Terms} aggregation. - */ -public class TermsBuilder extends ValuesSourceAggregationBuilder<TermsBuilder> { - - private TermsAggregator.BucketCountThresholds bucketCountThresholds = new TermsAggregator.BucketCountThresholds(-1, -1, -1, -1); - - private Terms.ValueType valueType; - private Terms.Order order; - private String includePattern; - private String excludePattern; - private String executionHint; - private SubAggCollectionMode collectionMode; - private Boolean showTermDocCountError; - private String[] includeTerms = null; - private String[] excludeTerms = null; - - /** - * Sole constructor. - */ - public TermsBuilder(String name) { - super(name, "terms"); - } - - /** - * Sets the size - indicating how many term buckets should be returned (defaults to 10) - */ - public TermsBuilder size(int size) { - bucketCountThresholds.setRequiredSize(size); - return this; - } - - /** - * Sets the shard_size - indicating the number of term buckets each shard will return to the coordinating node (the - * node that coordinates the search execution). The higher the shard size is, the more accurate the results are. - */ - public TermsBuilder shardSize(int shardSize) { - bucketCountThresholds.setShardSize(shardSize); - return this; - } - - /** - * Set the minimum document count terms should have in order to appear in the response. - */ - public TermsBuilder minDocCount(long minDocCount) { - bucketCountThresholds.setMinDocCount(minDocCount); - return this; - } - - /** - * Set the minimum document count terms should have on the shard in order to appear in the response. - */ - public TermsBuilder shardMinDocCount(long shardMinDocCount) { - bucketCountThresholds.setShardMinDocCount(shardMinDocCount); - return this; - } - - /** - * Define a regular expression that will determine what terms should be aggregated. The regular expression is based - * on the {@link RegExp} class. - * - * @see RegExp#RegExp(String) - */ - public TermsBuilder include(String regex) { - if (includeTerms != null) { - throw new IllegalArgumentException("exclude clause must be an array of strings or a regex, not both"); - } - this.includePattern = regex; - return this; - } - - /** - * Define a set of terms that should be aggregated. - */ - public TermsBuilder include(String [] terms) { - if (includePattern != null) { - throw new IllegalArgumentException("include clause must be an array of exact values or a regex, not both"); - } - this.includeTerms = terms; - return this; - } - - /** - * Define a set of terms that should be aggregated. - */ - public TermsBuilder include(long [] terms) { - if (includePattern != null) { - throw new IllegalArgumentException("include clause must be an array of exact values or a regex, not both"); - } - this.includeTerms = longsArrToStringArr(terms); - return this; - } - - private String[] longsArrToStringArr(long[] terms) { - String[] termsAsString = new String[terms.length]; - for (int i = 0; i < terms.length; i++) { - termsAsString[i] = Long.toString(terms[i]); - } - return termsAsString; - } - - - /** - * Define a set of terms that should be aggregated. - */ - public TermsBuilder include(double [] terms) { - if (includePattern != null) { - throw new IllegalArgumentException("include clause must be an array of exact values or a regex, not both"); - } - this.includeTerms = doubleArrToStringArr(terms); - return this; - } - - private String[] doubleArrToStringArr(double[] terms) { - String[] termsAsString = new String[terms.length]; - for (int i = 0; i < terms.length; i++) { - termsAsString[i] = Double.toString(terms[i]); - } - return termsAsString; - } - - /** - * Define a regular expression that will filter out terms that should be excluded from the aggregation. The regular - * expression is based on the {@link RegExp} class. - * - * @see RegExp#RegExp(String) - */ - public TermsBuilder exclude(String regex) { - if (excludeTerms != null) { - throw new IllegalArgumentException("exclude clause must be an array of exact values or a regex, not both"); - } - this.excludePattern = regex; - return this; - } - - /** - * Define a set of terms that should not be aggregated. - */ - public TermsBuilder exclude(String [] terms) { - if (excludePattern != null) { - throw new IllegalArgumentException("exclude clause must be an array of exact values or a regex, not both"); - } - this.excludeTerms = terms; - return this; - } - - - /** - * Define a set of terms that should not be aggregated. - */ - public TermsBuilder exclude(long [] terms) { - if (excludePattern != null) { - throw new IllegalArgumentException("exclude clause must be an array of exact values or a regex, not both"); - } - this.excludeTerms = longsArrToStringArr(terms); - return this; - } - - /** - * Define a set of terms that should not be aggregated. - */ - public TermsBuilder exclude(double [] terms) { - if (excludePattern != null) { - throw new IllegalArgumentException("exclude clause must be an array of exact values or a regex, not both"); - } - this.excludeTerms = doubleArrToStringArr(terms); - return this; - } - - - - /** - * When using scripts, the value type indicates the types of the values the script is generating. - */ - public TermsBuilder valueType(Terms.ValueType valueType) { - this.valueType = valueType; - return this; - } - - /** - * Defines the order in which the buckets will be returned. - */ - public TermsBuilder order(Terms.Order order) { - this.order = order; - return this; - } - - /** - * Expert: provide an execution hint to the aggregation. - */ - public TermsBuilder executionHint(String executionHint) { - this.executionHint = executionHint; - return this; - } - - /** - * Expert: set the collection mode. - */ - public TermsBuilder collectMode(SubAggCollectionMode mode) { - this.collectionMode = mode; - return this; - } - - /** - * Expert: return document count errors per term in the response. - */ - public TermsBuilder showTermDocCountError(boolean showTermDocCountError) { - this.showTermDocCountError = showTermDocCountError; - return this; - } - - @Override - protected XContentBuilder doInternalXContent(XContentBuilder builder, Params params) throws IOException { - - bucketCountThresholds.toXContent(builder, params); - - if (showTermDocCountError != null) { - builder.field(TermsAggregatorFactory.SHOW_TERM_DOC_COUNT_ERROR.getPreferredName(), showTermDocCountError); - } - if (executionHint != null) { - builder.field(TermsAggregatorFactory.EXECUTION_HINT_FIELD_NAME.getPreferredName(), executionHint); - } - if (valueType != null) { - builder.field("value_type", valueType.name().toLowerCase(Locale.ROOT)); - } - if (order != null) { - builder.field("order"); - order.toXContent(builder, params); - } - if (collectionMode != null) { - builder.field(SubAggCollectionMode.KEY.getPreferredName(), collectionMode.parseField().getPreferredName()); - } - if (includeTerms != null) { - builder.array("include", includeTerms); - } - if (includePattern != null) { - builder.field("include", includePattern); - } - if (excludeTerms != null) { - builder.array("exclude", excludeTerms); - } - if (excludePattern != null) { - builder.field("exclude", excludePattern); - } - return builder; - } -} diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsParser.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsParser.java index 5b8368a218..7e300af763 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsParser.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsParser.java @@ -52,7 +52,7 @@ public class TermsParser extends AbstractTermsParser { protected TermsAggregatorFactory doCreateFactory(String aggregationName, ValuesSourceType valuesSourceType, ValueType targetValueType, BucketCountThresholds bucketCountThresholds, SubAggCollectionMode collectMode, String executionHint, IncludeExclude incExc, Map<ParseField, Object> otherOptions) { - TermsAggregatorFactory factory = new TermsAggregatorFactory(aggregationName, valuesSourceType, targetValueType); + TermsAggregatorFactory factory = new TermsAggregatorFactory(aggregationName, targetValueType); List<OrderElement> orderElements = (List<OrderElement>) otherOptions.get(TermsAggregatorFactory.ORDER_FIELD); if (orderElements != null) { List<Terms.Order> orders = new ArrayList<>(orderElements.size()); @@ -97,7 +97,7 @@ public class TermsParser extends AbstractTermsParser { orderElements.add(orderParam); } else { throw new ParsingException(parser.getTokenLocation(), - "Order elements must be of type object in [" + aggregationName + "]."); + "Order elements must be of type object in [" + aggregationName + "] found token of type [" + token + "]."); } } otherOptions.put(TermsAggregatorFactory.ORDER_FIELD, orderElements); @@ -179,8 +179,8 @@ public class TermsParser extends AbstractTermsParser { } @Override - public AggregatorFactory[] getFactoryPrototypes() { - return new AggregatorFactory[] { new TermsAggregatorFactory(null, null, null) }; + public AggregatorFactory<?> getFactoryPrototypes() { + return new TermsAggregatorFactory(null, null); } } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/support/IncludeExclude.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/support/IncludeExclude.java index f6df150a4c..eee9d4cbf9 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/support/IncludeExclude.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/support/IncludeExclude.java @@ -20,6 +20,7 @@ package org.elasticsearch.search.aggregations.bucket.terms.support; import com.carrotsearch.hppc.LongHashSet; import com.carrotsearch.hppc.LongSet; + import org.apache.lucene.index.RandomAccessOrds; import org.apache.lucene.index.SortedSetDocValues; import org.apache.lucene.index.Terms; @@ -226,6 +227,10 @@ public class IncludeExclude implements Writeable<IncludeExclude>, ToXContent { this.excludeValues = null; } + public IncludeExclude(String include, String exclude) { + this(include == null ? null : new RegExp(include), exclude == null ? null : new RegExp(exclude)); + } + /** * @param includeValues The terms to be included * @param excludeValues The terms to be excluded @@ -240,6 +245,51 @@ public class IncludeExclude implements Writeable<IncludeExclude>, ToXContent { this.excludeValues = excludeValues; } + public IncludeExclude(String[] includeValues, String[] excludeValues) { + this(convertToBytesRefSet(includeValues), convertToBytesRefSet(excludeValues)); + } + + public IncludeExclude(double[] includeValues, double[] excludeValues) { + this(convertToBytesRefSet(includeValues), convertToBytesRefSet(excludeValues)); + } + + public IncludeExclude(long[] includeValues, long[] excludeValues) { + this(convertToBytesRefSet(includeValues), convertToBytesRefSet(excludeValues)); + } + + private static SortedSet<BytesRef> convertToBytesRefSet(String[] values) { + SortedSet<BytesRef> returnSet = null; + if (values != null) { + returnSet = new TreeSet<>(); + for (String value : values) { + returnSet.add(new BytesRef(value)); + } + } + return returnSet; + } + + private static SortedSet<BytesRef> convertToBytesRefSet(double[] values) { + SortedSet<BytesRef> returnSet = null; + if (values != null) { + returnSet = new TreeSet<>(); + for (double value : values) { + returnSet.add(new BytesRef(String.valueOf(value))); + } + } + return returnSet; + } + + private static SortedSet<BytesRef> convertToBytesRefSet(long[] values) { + SortedSet<BytesRef> returnSet = null; + if (values != null) { + returnSet = new TreeSet<>(); + for (long value : values) { + returnSet.add(new BytesRef(String.valueOf(value))); + } + } + return returnSet; + } + /** * Terms adapter around doc values. */ |