Adding a field with multiple mappings
Often, a field must be processed with several core types or in different ways. For example, a string field must be processed as analyzed for search and as not_analyzed for sorting. To do this, you need to define a multi_field special property called fields.
Note
In the previous ElasticSearch versions (prior to 1.x), there was the multi_field type, but this has now deprecated and will be removed in favor of the fields property.
The fields property is a very powerful feature of mapping because it allows you to use the same field in different ways.
Getting ready
You need a working ElasticSearch cluster.
How to do it...
To define a multifields property, you need to:
Use field as a type – define the main field type, as we saw in the previous sections.
Define a dictionary that contains subfields called
fields. The subfield with the same name as the parent field is the default one.
If you consider the item of your order example, you can index the name in this way:
"name...