Sometimes you want to index the same field with different mappings. For example, you want to index the title field both as text and as keyword. You can use the keyword field for an exact match and the text field for text search. You can do this by defining two fields, one with keyword mapping and other with text mapping, as shown next:
{
"properties": {
"title_text": {
"type": "text"
},
"title_keyword": {
"type": "keyword"
}
}
}
You can index the document as follows:
{
"title_text" : "Learning Elasticsearch",
"title_keyword" : "Learning Elasticsearch"
}
While indexing, the same value is used for both the title_text and title_keyword fields. The document source will now have two fields with...