-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Closed
Labels
:Search Relevance/VectorsVector searchVector search>docsGeneral docs changesGeneral docs changesTeam:DocsMeta label for docs teamMeta label for docs teamTeam:Search RelevanceMeta label for the Search Relevance team in ElasticsearchMeta label for the Search Relevance team in Elasticsearch
Description
Elasticsearch Version
9.1.4
Installed Plugins
No response
Java Version
bundled
OS Version
osx
Problem Description
When using the update API on a sparse_vector
field, the existing contents of that field do not get removed, but the new data simply gets appended. This behaviour seems different from other fields, but makes sense from a JSON perspective.
I suppose the same issue is with rank_features
, but the question is, if this is a bug or a feature.
Steps to Reproduce
DELETE alexr-test
PUT alexr-test
{
"mappings": {
"properties": {
"sparse_vector": {
"type": "sparse_vector"
},
"keyword" : {
"type" : "keyword"
}
}
}
}
PUT alexr-test/_doc/1?refresh
{
"sparse_vector" : {
"a" : 1,
"b" : 2
},
"keyword": ["a", "b"]
}
POST alexr-test/_update/1?refresh
{
"doc": {
"sparse_vector" : {
"c" : 3
},
"keyword" : ["c"]
}
}
# this contains sparse_vector: { a:1, b:2, c:3 }
GET alexr-test/_doc/1
A workaround could be to use scripting
POST alexr-test/_update/1?refresh
{
"script": {
"params": {
"sparse_vector": {
"c": 3
}
},
"source": "ctx._source.sparse_vector = params.sparse_vector"
}
}
Logs (if relevant)
No response
Metadata
Metadata
Assignees
Labels
:Search Relevance/VectorsVector searchVector search>docsGeneral docs changesGeneral docs changesTeam:DocsMeta label for docs teamMeta label for docs teamTeam:Search RelevanceMeta label for the Search Relevance team in ElasticsearchMeta label for the Search Relevance team in Elasticsearch