vespa
vespa copied to clipboard
Support Create If Not Exists for Tensor Cells in Tensor Field Modifications
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
It would be great if there were a way to create a tensor cell if it does not exist with a tensor modification request during a tensor partial update via the document api. Currently if you do a modify operation on a tensor field and the cell you wish to modify does not exist, the modification request is ignored for that cell and thus, even when using the create=true
parameter on the document request, the document is created but with an empty tensor field.
Describe the solution you'd like A clear and concise description of what you want to happen.
I propose a parameter in the document api PUT which would allow a cell to be automatically created with reasonable defaults such that a modification request would result in the originally non-existent field to be populated with the expected values.
Additional context Add any other context or screenshots about the feature request here.
As a more concrete example of what I would like, assume we have the following document schema within the content cluster named "content":
schema tensor_document {
document tensor_document {
field tensor_field type tensor<float>(x{}) {
indexing: attribute
}
}
}
Currently if I were to make the following request:
PUT /document/v1/content/tesnor_document/docid/1234?create=true HTTP/1.1
Content-Type: application/json
{
"fields": {
"tensor_field": {
"modify": {
"operation": "add",
"cells": {
"a": 1.0
}
}
}
}
}
I would get back the following from a GET request to the same url
{
"pathId": "/document/v1/content/tensor_document/docid/1234",
"id": "id:content:tensor_document::1234",
"fields": {}
}
What I would like is for the fields to contain a tensor with the cell a:1.0
similarly to how it would exist if you were to use add
instead of modify
in the document update request.
The semantics of create=true
only apply at the document level and not the field (or cell) level. I think for a feature like this we'd likely want a separate modify
operation with cell upsert semantics (or enhance the semantics of an existing operation), as these explicitly operate on specific fields. This could also be used together with create=true
to effectively create a single-cell document if none already existed.
Yes. We could e.g signal this by passing a default value with the operation. The alternative is to use 1 with multiplicative and 0 with additive ops.
Support for "create": true
on tensor modify update is available in Vespa 8.217.43 (https://github.com/vespa-engine/vespa/pull/28152).
System test: https://github.com/vespa-engine/system-test/pull/2988
Reference documentation: https://github.com/vespa-engine/documentation/pull/2838
In Vespa 8.218.31, "create": true
also works for empty (non-existing) tensor fields (https://github.com/vespa-engine/vespa/pull/28186).
System test: https://github.com/vespa-engine/system-test/pull/2989
Vespa 8.218.31 is now available. Reference doc: https://docs.vespa.ai/en/reference/document-json-format.html#tensor-modify