- Elasticsearch Guide: other versions:
- Setup
- API Conventions
- Document APIs
- Search APIs
- Indices APIs
- Create Index
- Delete Index
- Indices Exists
- Open / Close Index API
- Put Mapping
- Get Mapping
- Get Field Mapping
- Types Exists
- Delete Mapping
- Index Aliases
- Update Indices Settings
- Get Settings
- Analyze
- Index Templates
- Warmers
- Status
- Indices Stats
- Indices Segments
- Clear Cache
- Flush
- Refresh
- Optimize
- Gateway Snapshot
- Cluster APIs
- Query DSL
- Queries
- Match Query
- Multi Match Query
- Bool Query
- Boosting Query
- Common Terms Query
- Custom Filters Score Query
- Custom Score Query
- Custom Boost Factor Query
- Constant Score Query
- Dis Max Query
- Field Query
- Filtered Query
- Fuzzy Like This Query
- Fuzzy Like This Field Query
- Function Score Query
- Fuzzy Query
- GeoShape Query
- Has Child Query
- Has Parent Query
- Ids Query
- Indices Query
- Match All Query
- More Like This Query
- More Like This Field Query
- Nested Query
- Prefix Query
- Query String Query
- Simple Query String Query
- Range Query
- Regexp Query
- Span First Query
- Span Multi Term Query
- Span Near Query
- Span Not Query
- Span Or Query
- Span Term Query
- Term Query
- Terms Query
- Top Children Query
- Wildcard Query
- Text Query
- Minimum Should Match
- Multi Term Query Rewrite
- Filters
- And Filter
- Bool Filter
- Exists Filter
- Geo Bounding Box Filter
- Geo Distance Filter
- Geo Distance Range Filter
- Geo Polygon Filter
- GeoShape Filter
- Geohash Cell Filter
- Has Child Filter
- Has Parent Filter
- Ids Filter
- Indices Filter
- Limit Filter
- Match All Filter
- Missing Filter
- Nested Filter
- Not Filter
- Numeric Range Filter
- Or Filter
- Prefix Filter
- Query Filter
- Range Filter
- Regexp Filter
- Script Filter
- Term Filter
- Terms Filter
- Type Filter
- Queries
- Mapping
- Analysis
- Analyzers
- Tokenizers
- Token Filters
- Standard Token Filter
- ASCII Folding Token Filter
- Length Token Filter
- Lowercase Token Filter
- NGram Token Filter
- Edge NGram Token Filter
- Porter Stem Token Filter
- Shingle Token Filter
- Stop Token Filter
- Word Delimiter Token Filter
- Stemmer Token Filter
- Stemmer Override Token Filter
- Keyword Marker Token Filter
- Keyword Repeat Token Filter
- KStem Token Filter
- Snowball Token Filter
- Phonetic Token Filter
- Synonym Token Filter
- Compound Word Token Filter
- Reverse Token Filter
- Elision Token Filter
- Truncate Token Filter
- Unique Token Filter
- Pattern Capture Token Filter
- Pattern Replace Token Filter
- Trim Token Filter
- Limit Token Count Token Filter
- Hunspell Token Filter
- Common Grams Token Filter
- Normalization Token Filter
- Keep Words Token Filter
- Delimited Payload Token Filter
- Character Filters
- ICU Analysis Plugin
- Modules
- Index Modules
- Glossary of terms
WARNING: Version 0.90 of Elasticsearch has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Multi Field Type
editMulti Field Type
editThe multi_field
type allows to map several
core_types of the same
value. This can come very handy, for example, when wanting to map a
string
type, once when it’s analyzed
and once when it’s
not_analyzed
. For example:
{ "tweet" : { "properties" : { "name" : { "type" : "multi_field", "fields" : { "name" : {"type" : "string", "index" : "analyzed"}, "untouched" : {"type" : "string", "index" : "not_analyzed"} } } } } }
The above example shows how the name
field, which is of simple
string
type, gets mapped twice, once with it being analyzed
under
name
, and once with it being not_analyzed
under untouched
.
Accessing Fields
editWith multi_field
mapping, the field that has the same name as the
property is treated as if it was mapped without a multi field. That’s
the "default" field. It can be accessed regularly, for example using
name
or using typed navigation tweet.name
.
The path
attribute allows to control how non-default fields can be
accessed. If the path
attribute is set to full
, which is the default
setting, all non-default fields are prefixed with the name of the
property and can be accessed by their full path using the navigation
notation: name.untouched
, or using the typed navigation notation
tweet.name.untouched
. If the path
attribute is set to just_name
the actual field name without a prefix is used. The just_name
setting,
among other things, allows indexing content of multiple fields under the
same name. In the example below the content of both fields first_name
and last_name
can be accessed by using any_name
or tweet.any_name
{ "tweet" : { "properties": { "first_name": { "type": "multi_field", "path": "just_name", "fields": { "first_name": {"type": "string", "index": "analyzed"}, "any_name": {"type": "string","index": "analyzed"} } }, "last_name": { "type": "multi_field", "path": "just_name", "fields": { "last_name": {"type": "string", "index": "analyzed"}, "any_name": {"type": "string","index": "analyzed"} } } } } }
Include in All
editThe include_in_all
setting on the "default" field allows to control if
the value of the field should be included in the _all
field. Note, the
value of the field is copied to _all
, not the tokens. So, it only
makes sense to copy the field value once. Because of this, the
include_in_all
setting on all non-default fields is automatically set
to false
and can’t be changed.
Merging
editWhen updating mapping definition using the put_mapping
API, a core
type mapping can be "upgraded" to a multi_field
mapping. This means
that if the old mapping has a plain core type mapping, the updated
mapping for the same property can be a multi_field
type, with the
default field being the one being replaced.
On this page