public enum MultiValueMode extends Enum<MultiValueMode>
Enum Constant and Description |
---|
AVG
Average of all the values.
|
MAX
Pick the highest value.
|
MIN
Pick the lowest value.
|
SUM
Sum of all the values.
|
Modifier and Type | Method and Description |
---|---|
org.apache.lucene.util.BytesRef |
apply(org.apache.lucene.util.BytesRef a,
org.apache.lucene.util.BytesRef b) |
abstract double |
apply(double a,
double b)
Applies the sort mode and returns the result.
|
abstract long |
apply(long a,
long b)
Applies the sort mode and returns the result.
|
int |
applyOrd(int ord1,
int ord2) |
static MultiValueMode |
fromString(String sortMode)
A case insensitive version of
valueOf(String) |
protected int |
pick(org.apache.lucene.index.RandomAccessOrds values) |
protected org.apache.lucene.util.BytesRef |
pick(SortedBinaryDocValues values,
org.apache.lucene.util.BytesRef missingValue) |
protected long |
pick(org.apache.lucene.index.SortedNumericDocValues values,
long missingValue) |
protected double |
pick(SortedNumericDoubleValues values,
double missingValue) |
double |
reduce(double a,
int numValues)
Returns the aggregated value based on the sort mode.
|
long |
reduce(long a,
int numValues)
Returns the aggregated value based on the sort mode.
|
org.apache.lucene.index.SortedDocValues |
select(org.apache.lucene.index.RandomAccessOrds values)
Return a
SortedDocValues instance that can be used to sort documents
with this mode and the provided values. |
org.apache.lucene.index.SortedDocValues |
select(org.apache.lucene.index.RandomAccessOrds values,
org.apache.lucene.util.FixedBitSet rootDocs,
org.apache.lucene.util.FixedBitSet innerDocs)
Return a
SortedDocValues instance that can be used to sort root documents
with this mode, the provided values and filters for root/inner documents. |
org.apache.lucene.index.BinaryDocValues |
select(SortedBinaryDocValues values,
org.apache.lucene.util.BytesRef missingValue)
Return a
BinaryDocValues instance that can be used to sort documents
with this mode and the provided values. |
org.apache.lucene.index.BinaryDocValues |
select(SortedBinaryDocValues values,
org.apache.lucene.util.BytesRef missingValue,
org.apache.lucene.util.FixedBitSet rootDocs,
org.apache.lucene.util.FixedBitSet innerDocs,
int maxDoc)
Return a
BinaryDocValues instance that can be used to sort root documents
with this mode, the provided values and filters for root/inner documents. |
org.apache.lucene.index.NumericDocValues |
select(org.apache.lucene.index.SortedNumericDocValues values,
long missingValue)
Return a
NumericDocValues instance that can be used to sort documents
with this mode and the provided values. |
org.apache.lucene.index.NumericDocValues |
select(org.apache.lucene.index.SortedNumericDocValues values,
long missingValue,
org.apache.lucene.util.FixedBitSet rootDocs,
org.apache.lucene.util.FixedBitSet innerDocs,
int maxDoc)
Return a
NumericDocValues instance that can be used to sort root documents
with this mode, the provided values and filters for root/inner documents. |
NumericDoubleValues |
select(SortedNumericDoubleValues values,
double missingValue)
Return a
NumericDoubleValues instance that can be used to sort documents
with this mode and the provided values. |
NumericDoubleValues |
select(SortedNumericDoubleValues values,
double missingValue,
org.apache.lucene.util.FixedBitSet rootDocs,
org.apache.lucene.util.FixedBitSet innerDocs,
int maxDoc)
Return a
NumericDoubleValues instance that can be used to sort root documents
with this mode, the provided values and filters for root/inner documents. |
double |
startDouble()
Returns an initial value for the sort mode that is guaranteed to have no impact if passed
to
apply(double, double) . |
long |
startLong()
Returns an initial value for the sort mode that is guaranteed to have no impact if passed
to
apply(long, long) . |
static MultiValueMode |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static MultiValueMode[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final MultiValueMode SUM
public static final MultiValueMode AVG
public static final MultiValueMode MIN
public static final MultiValueMode MAX
public static MultiValueMode[] values()
for (MultiValueMode c : MultiValueMode.values()) System.out.println(c);
public static MultiValueMode valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic abstract double apply(double a, double b)
MAX
this method is equivalent to Math.max(double, double)
.
Note: all implementations are idempotent.a
- an argumentb
- another argumentpublic abstract long apply(long a, long b)
MAX
this method is equivalent to Math.max(long, long)
.
Note: all implementations are idempotent.a
- an argumentb
- another argumentpublic int applyOrd(int ord1, int ord2)
public org.apache.lucene.util.BytesRef apply(org.apache.lucene.util.BytesRef a, org.apache.lucene.util.BytesRef b)
public double startDouble()
apply(double, double)
. This value should be used as the initial value if the
sort mode is applied to a non-empty list of values. For instance:
double relevantValue = sortMode.startDouble(); for (int i = 0; i < array.length; i++) { relevantValue = sortMode.apply(array[i], relevantValue); }Note: This method return
0
by default.public long startLong()
apply(long, long)
. This value should be used as the initial value if the
sort mode is applied to a non-empty list of values. For instance:
long relevantValue = sortMode.startLong(); for (int i = 0; i < array.length; i++) { relevantValue = sortMode.apply(array[i], relevantValue); }Note: This method return
0
by default.public double reduce(double a, int numValues)
AVG
is used
this method divides the given value by the number of values. The default implementation returns
the first argument.
Note: all implementations are idempotent.public long reduce(long a, int numValues)
AVG
is used
this method divides the given value by the number of values. The default implementation returns
the first argument.
Note: all implementations are idempotent.public static MultiValueMode fromString(String sortMode)
valueOf(String)
ElasticsearchIllegalArgumentException
- if the given string doesn't match a sort mode or is null
.protected long pick(org.apache.lucene.index.SortedNumericDocValues values, long missingValue)
public org.apache.lucene.index.NumericDocValues select(org.apache.lucene.index.SortedNumericDocValues values, long missingValue)
NumericDocValues
instance that can be used to sort documents
with this mode and the provided values. When a document has no value,
missingValue
is returned.public org.apache.lucene.index.NumericDocValues select(org.apache.lucene.index.SortedNumericDocValues values, long missingValue, org.apache.lucene.util.FixedBitSet rootDocs, org.apache.lucene.util.FixedBitSet innerDocs, int maxDoc)
NumericDocValues
instance that can be used to sort root documents
with this mode, the provided values and filters for root/inner documents.
For every root document, the values of its inner documents will be aggregated.
If none of the inner documents has a value, then missingValue
is returned.
NOTE: Calling the returned instance on docs that are not root docs is illegalprotected double pick(SortedNumericDoubleValues values, double missingValue)
public NumericDoubleValues select(SortedNumericDoubleValues values, double missingValue)
NumericDoubleValues
instance that can be used to sort documents
with this mode and the provided values. When a document has no value,
missingValue
is returned.public NumericDoubleValues select(SortedNumericDoubleValues values, double missingValue, org.apache.lucene.util.FixedBitSet rootDocs, org.apache.lucene.util.FixedBitSet innerDocs, int maxDoc)
NumericDoubleValues
instance that can be used to sort root documents
with this mode, the provided values and filters for root/inner documents.
For every root document, the values of its inner documents will be aggregated.
If none of the inner documents has a value, then missingValue
is returned.
NOTE: Calling the returned instance on docs that are not root docs is illegalprotected org.apache.lucene.util.BytesRef pick(SortedBinaryDocValues values, org.apache.lucene.util.BytesRef missingValue)
public org.apache.lucene.index.BinaryDocValues select(SortedBinaryDocValues values, org.apache.lucene.util.BytesRef missingValue)
BinaryDocValues
instance that can be used to sort documents
with this mode and the provided values. When a document has no value,
missingValue
is returned.public org.apache.lucene.index.BinaryDocValues select(SortedBinaryDocValues values, org.apache.lucene.util.BytesRef missingValue, org.apache.lucene.util.FixedBitSet rootDocs, org.apache.lucene.util.FixedBitSet innerDocs, int maxDoc)
BinaryDocValues
instance that can be used to sort root documents
with this mode, the provided values and filters for root/inner documents.
For every root document, the values of its inner documents will be aggregated.
If none of the inner documents has a value, then missingValue
is returned.
NOTE: Calling the returned instance on docs that are not root docs is illegalprotected int pick(org.apache.lucene.index.RandomAccessOrds values)
public org.apache.lucene.index.SortedDocValues select(org.apache.lucene.index.RandomAccessOrds values)
SortedDocValues
instance that can be used to sort documents
with this mode and the provided values.public org.apache.lucene.index.SortedDocValues select(org.apache.lucene.index.RandomAccessOrds values, org.apache.lucene.util.FixedBitSet rootDocs, org.apache.lucene.util.FixedBitSet innerDocs)
SortedDocValues
instance that can be used to sort root documents
with this mode, the provided values and filters for root/inner documents.
For every root document, the values of its inner documents will be aggregated.
NOTE: Calling the returned instance on docs that are not root docs is illegalCopyright © 2009–2015. All rights reserved.