- 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.
Get Field Mapping
editGet Field Mapping
editThe get field mapping API allows you to retrieve mapping definitions for one or more fields. This is useful when you do not need the complete type mapping returned by the Get Mapping API.
The following returns the mapping of the field text
only:
curl -XGET 'http://localhost:9200/twitter/tweet/_mapping/field/text'
For which the response is (assuming text
is a default string field):
{ "twitter": { "tweet": { "text": { "full_name": "text", "mapping": { "text": { "type": "string" } } } } } }
Multiple Indices, Types and Fields
editThe get field mapping API can be used to get the mapping of multiple fields from more than one index or type
with a single call. General usage of the API follows the
following syntax: host:port/{index}/{type}/_mapping/field/{field}
where
{index}
, {type}
and {field}
can stand for comma-separated list of names or wild cards. To
get mappings for all indices you can use _all
for {index}
. The
following are some examples:
curl -XGET 'http://localhost:9200/twitter,kimchy/_mapping/field/message' curl -XGET 'http://localhost:9200/_all/tweet,book/_mapping/field/message,user.id' curl -XGET 'http://localhost:9200/_all/tw*/_mapping/field/*.id'
Specifying fields
editThe get mapping api allows you to specify one or more fields separated with by a comma. You can also use wildcards. The field names can be any of the following:
Full names |
the full path, including any parent object name the field is
part of (ex. |
Index names |
the name of the lucene field (can be different than the
field name if the |
Field names |
the name of the field without the path to it (ex. |
The above options are specified in the order the field
parameter is resolved.
The first field found which matches is returned. This is especially important
if index names or field names are used as those can be ambiguous.
For example, consider the following mapping:
{ "article": { "properties": { "id": { "type": "string" }, "title": { "type": "string", "index_name": "text" }, "abstract": { "type": "string", "index_name": "text" }, "author": { "properties": { "id": { "type": "string" }, "name": { "type": "string", "index_name": "author" } } } } } }
To select the id
of the author
field, you can use it’s full name author.id
. Using text
will return
the mapping of abstract
as it is one of the fields which map to the Lucene field text
. name
will return
the field author.name
:
curl -XGET "http://localhost:9200/publications/article/_mapping/field/author.id,text,name"
returns:
{ "publications": { "article": { "text": { "full_name": "abstract", "mapping": { "abstract": { "type": "string", "index_name": "text" } } }, "author.id": { "full_name": "author.id", "mapping": { "id": { "type": "string" } } }, "name": { "full_name": "author.name", "mapping": { "name": { "type": "string", "index_name": "author" } } } } } }
Note how the response always use the same fields specified in the request as keys.
The full_name
in every entry contains the full name of the field whose mapping were returned.
This is useful when the request can refer to to multiple fields (like text
above).
Other options
edit
include_defaults |
adding |