Package org.elasticsearch.script
Class Field<T>
java.lang.Object
org.elasticsearch.script.Field<T>
- Direct Known Subclasses:
EmptyField,Field.BigIntegerField,Field.BooleanField,Field.BytesRefField,Field.DateMillisField,Field.DateNanosField,Field.DoubleField,Field.GeoPointField,Field.IpField,Field.LongField,Field.StringField,Field.VersionField
A field in a document accessible via scripting. In search contexts, the Field may be backed by doc values, source
or both. In ingestion, the field may be in the source document or being added to the document.
Field's methods must not throw exceptions nor return null. A Field object representing a empty or unmapped field will have
*
isEmpty() == true
* getValues().equals(Collections.emptyList())
* getValue(defaultValue) == defaultValue-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic Converter<BigInteger,Field.BigIntegerField>static Converter<Long,Field.LongField>protected Stringprotected FieldValues<T> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionExtensions outside the core package should override this method to implement their own conversions, calling the superclass of this method as a fallback.doublegetDouble(double defaultValue)ProvideConverters access to the underlyingFieldValues, should not be exposed to scriptslonggetLong(long defaultValue)getName()Get the first value of a field, ifisEmpty()return defaultValue insteadGet all values of a multivalued field.booleanisEmpty()Does the field have any values? An unmapped field may have values from source
-
Field Details
-
BigInteger
-
Long
-
name
-
values
-
-
Constructor Details
-
Field
-
-
Method Details
-
getName
-
isEmpty
public boolean isEmpty()Does the field have any values? An unmapped field may have values from source -
getValues
Get all values of a multivalued field. IfisEmpty()this returns an empty list -
as
Convert thisFieldinto anotherFieldtype using aConverterof the target type. As this is called from user scripts,asmay be called to convert a field into its same type, if sothisis cast via convertersConverter.getFieldClass(). -
convert
Extensions outside the core package should override this method to implement their own conversions, calling the superclass of this method as a fallback. -
getFieldValues
ProvideConverters access to the underlyingFieldValues, should not be exposed to scripts -
getValue
Get the first value of a field, ifisEmpty()return defaultValue instead -
getDouble
public double getDouble(double defaultValue)Get the underlying value as adoubleunlessisEmpty(), in which case returndefaultValue. May throwInvalidConversionif the underlying value is not representable as adouble. -
getLong
public long getLong(long defaultValue)Get the underlying value as alongunlessisEmpty(), in which case returndefaultValue. May throwInvalidConversionif the underlying value is not representable as along.
-