I saw one article where they are doing mapping directly dynamic after create two mapping which are given below:
My question is how elastic automatically predict it will goes to keword_facet or long_facet....Means we have to change in database something , so that elastic will understand or I am wrong somewhere....
article link is https://codeburst.io/elasticsearch-by-example-part-4-cd11928a579e
{
"entity": {
"name": "tshirt"
},
"keyword_facets": [
{
"facet_name": "size",
"facet_value": "S"
},
{
"facet_name": "color",
"facet_value": "black"
},
{
"facet_name": "fabric",
"facet_value": "cotton"
}
],
"long_facets": [
{
"facet_name": "price",
"facet_value": 1000
}
]
}
Observations:
Moved the descriptive name property under an entity property; this is where I anticipate placing other non-facet related properties.
We divide the facet data based on types: keyword and long.
Create (Revisited)
Assuming that we are using the same cluster environment, we need to delete the existing shirts index.
DELETE: ENDPOINT/shirts
and then recreate it as follows:
PUT: ENDPOINT/shirts
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1
},
"mappings": {
"shirt": {
"properties": {
"entity": {
"properties": {
"name": {
"type": "text"
}
}
},
"keyword_facets": {
"type": "nested",
"properties": {
"facet_name": {
"type": "keyword"
},
"facet_value": {
"type": "keyword"
}
}
},
"long_facets": {
"type": "nested",
"properties": {
"facet_name": {
"type": "keyword"
},
"facet_value": {
"type": "long"
}
}
}
}
}
}
}