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/support/IncludeExclude.java | |
parent | 3b35754f5900286acdeb9ada7d2a988a9d177ecd (diff) |
Removes Aggregation Builders in place of AggregatorFactory implementations
Diffstat (limited to 'core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/support/IncludeExclude.java')
-rw-r--r-- | core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/support/IncludeExclude.java | 50 |
1 files changed, 50 insertions, 0 deletions
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. */ |