vespa icon indicating copy to clipboard operation
vespa copied to clipboard

Clarify limitations of fieldupdate versus fieldpathupdate with mode index and reject unsupported operations

Open jobergum opened this issue 5 years ago • 2 comments

Originally reported here https://stackoverflow.com/questions/54361546/vespa-search-query-on-array-gives-hits-even-after-removing-the-element-from-ar

Given the following simple definition with an array of string

    document doc {
        field userIds type array<string> {
            indexing: summary | index
        }
    }

Update syntax 1:

{
"update": "id:doc:doc::0",
        "fields": {
        "userIds[0]": {
                "remove": 0
          }
  }
}

This update operation is parsed into a fieldpathupdate and is ignored by the proton indexing while the summary store is updated but not the index so the array value at position 0 is still searchable. The correct behaviour would be to reject the operation.

Update syntax 2:

{
"update": "id:doc:doc::0",
	"fields": {
    	"userIds": {
        	"remove": ["user1"]
    	  }
  }
}

This update is treated as a regular fieldupdate and both summary store and the index/attribute is updated. This syntax has the downside that you actually pass the value "user1" and not the index you want to remove, so in cases where the array has multiple occurrences all will be removed. It could look like we don't have a regular fieldupdate syntax for removing by element index?

jobergum avatar Jan 28 '19 11:01 jobergum

return error message, not ignore

kkraune avatar Jan 30 '19 14:01 kkraune

Specifically "Update syntax 1" above should produce an error message because the field path specifies the first item in the userIds, and in this document type that item is not iteself an array but a single value.

bratseth avatar Jan 30 '19 14:01 bratseth