Given the following mapping:
{
"index-name-a" : {
"mappings" : {
"properties" : {
"id" : {
"type" : "integer"
},
"title" : {
"type" : "keyword",
"fields" : {
"suggest" : {
"type" : "completion",
"analyzer" : "standard",
"preserve_separators" : true,
"preserve_position_increments" : true,
"max_input_length" : 50
}
}
}
}
}
}
}
How do I update the weightings of individual documents? I have tried the following:
PUT /index-name-a/_doc/1
{
"title.suggest" : {
"weight" : 30
}
}
Which errors with:
Could not dynamically add mapping for field [title.suggest]. Existing mapping for [title] must be of type object but found [keyword]
Which makes sense, since the property is of type keyword and not an object. But I can't find the correct way to do it. Closest I could find in the docs doesn't seem to work if it's a multi-field.
CodePudding user response:
Workaround
Indeed I could reproduce this behaviour on elasticsearch v 8.1
PUT /72342475-2/
{
"mappings": {
"properties": {
"id": {
"type": "integer"
},
"title": {
"type": "completion",
"analyzer": "standard",
"preserve_separators": true,
"preserve_position_increments": true,
"max_input_length": 50,
"fields": {
"suggest": {
"type": "keyword"
}
}
}
}
}
}
PUT 72342475-2/_doc/1?refresh
{
"title": ["nevermind", "smell like teen spirit"],
"title.weight": 22
}