In an Elasticsearch movie or email mapping, the fields object gives one field additional data-type representations. A subject or title can remain text for full-text search while exposing keyword or completion forms for other operations. section 4.7
One value, several searchable forms
A subject mapped as text, keyword, and completion is still supplied as one field value. Query subject for analyzed text, subject.kw for exact matching, or subject.comp for completion behavior. The dot-separated names identify the additional field representations. section 4.7
Listing 4.43 Schema definition with a multi-typed field
PUT emails_multi_type
{
"mappings": {
"properties": {
"subject":{
"type": "text", #1
"fields": {
"kw":{ "type":"keyword" }, #2
"comp":{ "type":"completion" } #3
}
}
}
}
}
This mapping creates subject as text and adds keyword and completion representations under the fields object. section 4.7
Use the additional representations deliberately:
- Use the parent field, such as subject, when analyzed text is appropriate. section 4.7
- Use a named subfield, such as title.keyword or subject.kw, when exact values are required; keyword values remain unanalyzed unless normalization is configured. section 4.1.2 section 4.7
- Do not confuse this mapping object with the search-response fields object, which explicitly selects returned fields such as title and rating; those values appear as JSON arrays. section 8.8.5
