Vespa.ai: How to make an array of floats handle null values?

207 views Asked by At

I am trying to make a simple Vespa application, where one of my data fields are an Array. However the array contains some null values. For instance an array like: [2.0,1.4,null,5.6,...].

What can I use instead of float to represent elements in the array?

1

There are 1 answers

0
Jo Kristian Bergum On BEST ANSWER

Seems like you want to use a sparse tensor field instead since some addresses does not have a value. x{} denotes a sparse tensor, x[128] is an example of a dense tensor. See https://docs.vespa.ai/documentation/tensor-user-guide.html for an intro to vespa tensor fields.

field stuff type tensor<float>(x{}) {
  indexing: summary |attribute
}
[
  { "put": "id:example:example::0", "fields": {
      "stuff" : {
        "cells": [
          { "address" : { "x" : "0" }, "value": 2.0 },
          { "address" : { "x" : "1" }, "value": 1.4 },
          { "address" : { "x" : "3" }, "value": 5.6 },
        
        ]
      }
    }
  }
]