Fluent builder for Elasticsearch index mappings, used by AppIndexer implementations to describe how a field is stored and searched. Each field method (textField, keywordField, longField, dateField and so on) both appends to the underlying mapping JSON and records field metadata - title, type, lookup function or cross-index relation - in a metadata map shared across the whole mapping. Nested object and array fields are opened with startObjectMapping or startNestedObjectMapping and closed with endObjectMapping, each call returning a new builder scoped to that level while still sharing the same field metadata map.

Group: Builders


Properties

PropertyReturnsDescription
fieldsMap<String,ESFieldMeta>Field metadata for every field added anywhere in this mapping, keyed by its dotted path - shared across all nested builders derived from the same root, so it reflects the whole mapping regardless of which level added a field.
mapBuilderMapBuilderUnderlying map builder for this mapping, with the current object scope closed off. Used internally to render the mapping to JSON once all fields have been added.

Methods

duplicate() · newText(String fieldName) · newText(String fieldName, Integer ignore_above) · textField(String fieldName) · newTextNoKeyword(String fieldName) · newKeyword(String fieldName) · keywordField(String fieldName) · keywordField(String fieldName, boolean lowerCase) · newIp(String fieldName) · ipField(String fieldName) · newLong(String fieldName) · longField(String fieldName) · newDouble(String fieldName) · doubleField(String fieldName) · newInteger(String fieldName) · integerField(String fieldName) · newGeoPoint(String fieldName) · geoPointField(String fieldName) · newBoolean(String fieldName) · booleanField(String fieldName) · newDate(String fieldName) · dateField(String fieldName) · startObjectMapping(String fieldName) · startNestedObjectMapping(String fieldName) · endObjectMapping() · getMapBuilder() · hasField(String name) · getFields()

duplicate()

Returns: ESMappingsBuilder

Creates an independent copy of this builder and its field metadata, so a mapping can be branched and extended differently along two paths without either affecting the other.

newText(String fieldName)

Returns: ESFieldBuilder

Creates a text field builder for the given field name, with term-frequency data enabled and an automatic lowercase keyword sub-field for exact-match and sorting use. Call build() on the result to add it to the mapping.

ParameterDescription
fieldNamethe name of the field in the mapping

newText(String fieldName, Integer ignore_above)

Returns: ESFieldBuilder

Creates a text field builder like newText(String), but with a keyword sub-field that ignores values longer than ignore_above characters instead of applying the default lowercase normaliser.

ParameterDescription
fieldNamethe name of the field in the mapping
ignore_abovethe maximum character length indexed by the keyword sub-field; longer values are ignored

textField(String fieldName)

Returns: ESMappingsBuilder

Adds a stored, term-frequency-enabled text field with a lowercase keyword sub-field to the mapping in one call. Equivalent to calling newText(fieldName), then store(true), then build().

ParameterDescription
fieldNamethe name of the field in the mapping

newTextNoKeyword(String fieldName)

Returns: ESFieldBuilder

Creates a text field builder like newText(String) but without the automatic keyword sub-field, for fields that only need free-text search and are never sorted or filtered on their exact value.

ParameterDescription
fieldNamethe name of the field in the mapping

newKeyword(String fieldName)

Returns: ESFieldBuilder

Creates a keyword field builder for the given field name, with eager global ordinals enabled so it aggregates and sorts efficiently.

ParameterDescription
fieldNamethe name of the field in the mapping

keywordField(String fieldName)

Returns: ESMappingsBuilder

Adds a stored keyword field with a text sub-field to the mapping in one call, for values that need both exact matching and free-text search.

ParameterDescription
fieldNamethe name of the field in the mapping

keywordField(String fieldName, boolean lowerCase)

Returns: ESMappingsBuilder

Adds a stored keyword field to the mapping in one call, optionally applying a lowercase normaliser so matches are case-insensitive.

ParameterDescription
fieldNamethe name of the field in the mapping
lowerCaseif true, values are normalised to lower case before indexing

newIp(String fieldName)

Returns: ESFieldBuilder

Creates an ip field builder for the given field name, for values that are IP addresses.

ParameterDescription
fieldNamethe name of the field in the mapping

ipField(String fieldName)

Returns: ESMappingsBuilder

Adds a stored ip field to the mapping in one call.

ParameterDescription
fieldNamethe name of the field in the mapping

newLong(String fieldName)

Returns: ESFieldBuilder

Creates a long field builder for the given field name, for whole-number values.

ParameterDescription
fieldNamethe name of the field in the mapping

longField(String fieldName)

Returns: ESMappingsBuilder

Adds a stored long field to the mapping in one call.

ParameterDescription
fieldNamethe name of the field in the mapping

newDouble(String fieldName)

Returns: ESFieldBuilder

Creates a double field builder for the given field name, for floating-point values.

ParameterDescription
fieldNamethe name of the field in the mapping

doubleField(String fieldName)

Returns: ESMappingsBuilder

Adds a stored double field to the mapping in one call.

ParameterDescription
fieldNamethe name of the field in the mapping

newInteger(String fieldName)

Returns: ESFieldBuilder

Creates an integer field builder for the given field name, for whole-number values that fit in 32 bits.

ParameterDescription
fieldNamethe name of the field in the mapping

integerField(String fieldName)

Returns: ESMappingsBuilder

Adds a stored integer field to the mapping in one call.

ParameterDescription
fieldNamethe name of the field in the mapping

newGeoPoint(String fieldName)

Returns: ESFieldBuilder

Creates a geo_point field builder for the given field name, for latitude/longitude values.

ParameterDescription
fieldNamethe name of the field in the mapping

geoPointField(String fieldName)

Returns: ESMappingsBuilder

Adds a stored geo_point field to the mapping in one call.

ParameterDescription
fieldNamethe name of the field in the mapping

newBoolean(String fieldName)

Returns: ESFieldBuilder

Creates a boolean field builder for the given field name.

ParameterDescription
fieldNamethe name of the field in the mapping

booleanField(String fieldName)

Returns: ESMappingsBuilder

Adds a stored boolean field to the mapping in one call.

ParameterDescription
fieldNamethe name of the field in the mapping

newDate(String fieldName)

Returns: ESFieldBuilder

Creates a date field builder for the given field name.

ParameterDescription
fieldNamethe name of the field in the mapping

dateField(String fieldName)

Returns: ESMappingsBuilder

Adds a stored date field to the mapping in one call.

ParameterDescription
fieldNamethe name of the field in the mapping

startObjectMapping(String fieldName)

Returns: ESMappingsBuilder

Opens a nested object mapping scope under the given field name, for grouping a set of related fields as a single object property. Subsequent field calls on the returned builder are added inside that object; close the scope with endObjectMapping to return to the parent level.

ParameterDescription
fieldNamethe name of the object field

startNestedObjectMapping(String fieldName)

Returns: ESMappingsBuilder

Opens a nested object mapping scope like startObjectMapping, but marks the field as Elasticsearch's nested type so each entry in an array of these objects is indexed and queried independently rather than being flattened together with the others.

ParameterDescription
fieldNamethe name of the object field

endObjectMapping()

Returns: ESMappingsBuilder

Closes the current object mapping scope opened by startObjectMapping or startNestedObjectMapping and returns a builder scoped to the parent level, still sharing the same field metadata map.

getMapBuilder()

Returns: MapBuilder

Underlying map builder for this mapping, with the current object scope closed off. Used internally to render the mapping to JSON once all fields have been added.

hasField(String name)

Returns: boolean

Whether a field with the given name has already been added at the current mapping level.

ParameterDescription
namethe field name to check

getFields()

Returns: Map<String,ESFieldMeta>

Field metadata for every field added anywhere in this mapping, keyed by its dotted path - shared across all nested builders derived from the same root, so it reflects the whole mapping regardless of which level added a field.

To get full access to the Kademi Hub existing customers can login here, or new customers can register here.