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
Modifier and TypeClassDescriptionstatic class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
-
Field Summary
Modifier and TypeFieldDescriptionstatic Converter<BigInteger,Field.BigIntegerField>
static Converter<Long,Field.LongField>
protected String
protected FieldValues<T>
-
Constructor Summary
-
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.double
getDouble(double defaultValue)
ProvideConverter
s access to the underlyingFieldValues
, should not be exposed to scriptslong
getLong(long defaultValue)
getName()
Get the first value of a field, ifisEmpty()
return defaultValue insteadGet all values of a multivalued field.boolean
isEmpty()
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 thisField
into anotherField
type using aConverter
of the target type. As this is called from user scripts,as
may be called to convert a field into its same type, if sothis
is 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
ProvideConverter
s 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 adouble
unlessisEmpty()
, in which case returndefaultValue
. May throwInvalidConversion
if the underlying value is not representable as adouble
. -
getLong
public long getLong(long defaultValue)Get the underlying value as along
unlessisEmpty()
, in which case returndefaultValue
. May throwInvalidConversion
if the underlying value is not representable as along
.
-