Per-field configuration for a single Elasticsearch mapping field, created by one of ESMappingsBuilder's newX methods and completed with a call to build() to add it to the enclosing mapping. Supports setting a display title and description, an optional sub-field for alternate indexing (for example a keyword sub-field alongside a text field), and either a lookup function or a relation to another AppIndexer for rendering the raw indexed value as a readable label.
Group: Builders
Methods
build() · idField() · deprecated(boolean b) · subfield(String type) · subfieldNoStore(String type) · subfieldWithNormaliser(String type, String normaliser) · subfield(String type, Integer ignore_above) · fielddata(boolean s) · ignoreAbove(Integer ignoreAbove) · normalizer(String normalizer) · subfieldNormalizer(String subfieldNormalizer) · eagerGlobalOrdinals(boolean s) · lowerCase(boolean s) · lowerCaseSubfield(boolean s) · relation(AppIndexer indexer, String fieldName) · lookupFn(Function<Object,String> s) · content(String title, String desc) · title(String s) · description(String s) · store(boolean s)
build()
Returns: ESMappingsBuilder
Adds this field to the enclosing mapping and records its metadata, resolving a display title from the field name if none was explicitly set. Returns the enclosing builder so more fields can be chained.
idField()
Returns: ESFieldBuilder
Marks this field as a relational identifier for its table or entity type, so search results and relation lookups can locate the record it points to.
deprecated(boolean b)
Returns: ESFieldBuilder
Marks this field as deprecated, so it is still indexed and queryable but hidden from the search UI.
| Parameter | Description |
|---|---|
b | true to mark the field deprecated |
subfield(String type)
Returns: ESFieldBuilder
Adds a sub-field of the given type (for example keyword or text) alongside this field's own value, stored under a name matching the type.
| Parameter | Description |
|---|---|
type | the Elasticsearch type of the sub-field |
subfieldNoStore(String type)
Returns: ESFieldBuilder
Adds a sub-field like subfield(String), but with storage disabled for that sub-field.
| Parameter | Description |
|---|---|
type | the Elasticsearch type of the sub-field |
subfieldWithNormaliser(String type, String normaliser)
Returns: ESFieldBuilder
Adds a sub-field like subfield(String), with the given normaliser applied to it.
| Parameter | Description |
|---|---|
type | the Elasticsearch type of the sub-field |
normaliser | the name of the normaliser to apply to the sub-field |
subfield(String type, Integer ignore_above)
Returns: ESFieldBuilder
Adds a sub-field like subfield(String), with a keyword sub-field that ignores values longer than ignore_above characters.
| Parameter | Description |
|---|---|
type | the Elasticsearch type of the sub-field |
ignore_above | the maximum character length indexed by a keyword sub-field; ignored for other types |
fielddata(boolean s)
Returns: ESFieldBuilder
Enables or disables fielddata (in-memory field values used for aggregations and sorting) on this field. Only valid for text fields; a request to enable it on any other type is ignored and logged as a warning.
| Parameter | Description |
|---|---|
s | true to enable fielddata |
ignoreAbove(Integer ignoreAbove)
Returns: ESFieldBuilder
Sets the maximum character length indexed for this field, beyond which the value is ignored. Only valid for keyword fields; a value set on any other type is ignored and logged as a warning.
| Parameter | Description |
|---|---|
ignoreAbove | the maximum character length to index, or null for no limit |
normalizer(String normalizer)
Returns: ESFieldBuilder
Sets the normaliser applied to this field's values before indexing, for example to lower-case them for case-insensitive matching.
| Parameter | Description |
|---|---|
normalizer | the name of the normaliser to apply |
subfieldNormalizer(String subfieldNormalizer)
Returns: ESFieldBuilder
Sets the normaliser for this field's sub-field named normalize, kept for backward compatibility with mappings that use that sub-field name directly.
| Parameter | Description |
|---|---|
subfieldNormalizer | the name of the normaliser to apply to the normalize sub-field |
eagerGlobalOrdinals(boolean s)
Returns: ESFieldBuilder
Enables or disables eager global ordinals for this field, which pre-computes the data structures aggregations need so the first aggregation query after an index refresh is not slow.
| Parameter | Description |
|---|---|
s | true to enable eager global ordinals |
lowerCase(boolean s)
Returns: ESFieldBuilder
Sets whether this field's values are normalised to lower case before indexing, for case-insensitive exact matching.
| Parameter | Description |
|---|---|
s | true to lower-case values before indexing |
lowerCaseSubfield(boolean s)
Returns: ESFieldBuilder
Sets whether this field's sub-field values are normalised to lower case before indexing.
| Parameter | Description |
|---|---|
s | true to lower-case the sub-field's values before indexing |
relation(AppIndexer indexer, String fieldName)
Returns: ESFieldBuilder
Marks this field as related to a field of another AppIndexer's index, so raw indexed values (typically an entity ID) can be resolved to a readable label by looking them up in that related index.
| Parameter | Description |
|---|---|
indexer | the AppIndexer that owns the related field |
fieldName | the name of the field in the related index to look the value up against |
lookupFn(Function<Object,String> s)
Returns: ESFieldBuilder
Sets a function used to resolve this field's raw indexed value (typically an entity ID) to a readable label, for use where the value cannot be resolved through a relation to another AppIndexer.
| Parameter | Description |
|---|---|
s | the function that converts a raw value to its display label |
content(String title, String desc)
Returns: ESFieldBuilder
Sets both the display title and description for this field in one call.
| Parameter | Description |
|---|---|
title | the display title shown in the search UI |
desc | the description of what this field represents |
title(String s)
Returns: ESFieldBuilder
Sets the display title for this field, shown in the search UI in place of the raw field name.
| Parameter | Description |
|---|---|
s | the display title |
description(String s)
Returns: ESFieldBuilder
Sets the description for this field, explaining what it represents to someone building a query against it.
| Parameter | Description |
|---|---|
s | the description text |
store(boolean s)
Returns: ESFieldBuilder
Sets whether this field's value is stored separately (in addition to being indexed), which allows retrieving it directly from Elasticsearch without loading the whole source document.
| Parameter | Description |
|---|---|
s | true to store the field's value |