2

Im following the documentation: https://docs.vespa.ai/documentation/reference/document-json-update-format.html#assign-map-field

When I update a single field of a struct in a map to struct the unspecified values are deleted. Is this an error or expected behavior? I would like to retain the other values.

Before the update the object looks like this

...
"status":[  
   {  
      "key":0,
      "value":{  
         "f1":"before",
         "f2":"before2"
      }
   }
]
...

I make an http PUT request

{
   "update":"id:ITEM:ITEM::ITEM_1",
   "fields":{
      "status{0}":{
         "assign":{
            "f1: "changed"
         }
      }
   }
}

after the PUT, the f1 field changes but the f2 field is deleted

"status":[
   {
      "key":0,
      "value":{
         "f1":"changed"
      }
   }
]
field status type map<int, status> {
     indexing: summary
     struct-field key { indexing: attribute }
     struct-field value.f1 { indexing: summary | attribute}
     struct-field value.f2 { indexing: summary | attribute}
}

struct status {
     field f1 type string {}
     field f2 type string {}
}
4

1 回答 1

4

您需要使用文档字段路径语法来更新各个地图条目。

{
   "update":"id:ITEM:ITEM::ITEM_1",
   "fields":{
      "status{0}.f1": { "assign": "changed" }
   }
}
于 2019-02-14T20:02:30.880 回答