Metadata feature allows you to store context with your vectors to make a connection. There can be a couple of uses of this:

  1. You can put the source of the vector in the metadata to use in your application from the query response.
  2. You can put some metadata to further filter the results upon the query.

You can set metadata with your vector as follows:

curl https://powerful-kodiak-60521-us1-vector.upstash.io/upsert \
  -H "Authorization: Bearer UPSTASH_VECTOR_TOKEN" \
  -d '{
   "id":"4",
   "vector":[0.9215,0.3897,....],
   "metadata":{
      "url":"https://imgur.com/z9AVZLb"
   }
}'

When you do a query or fetch, you can opt-in to retrieve the metadata as follows:

  • Query Example
curl https://powerful-kodiak-60521-us1-vector.upstash.io/query \
  -H "Authorization: Bearer UPSTASH_VECTOR_TOKEN" \
  -d '{
   "vector":[0.9215,0.3897,...],
   "topK" : 5,
   "includeMetadata": true
}'
{
  "result": [
    {
      "id": "1",
      "score": 1,
      "metadata": {
        "url": "https://imgur.com/z9AVZLb"
      }
    },
    {
      "id": "3",
      "score": 0.99961007,
      "metadata": {
        "url": "https://imgur.com/zfOPmnI"
      }
    }
  ]
}

Also, you can filter the results further by providing a metadata filter:

curl https://powerful-kodiak-60521-us1-vector.upstash.io/query \
  -H "Authorization: Bearer UPSTASH_VECTOR_TOKEN" \
  -d '{
   "vector":[0.9215,0.3897,...],
   "topK" : 5,
   "filter": "url GLOB \"*imgur.com*\"",
   "includeMetadata": true
}'

See Metadata Filtering documentation for more details.

  • Range Example
curl https://powerful-kodiak-60521-us1-vector.upstash.io/range \
  -H "Authorization: Bearer UPSTASH_VECTOR_TOKEN" \
  -d '{ "cursor" : "",  "limit" : 3, "includeMetadata": true}'
{
  "result": {
    "nextCursor": "4",
    "vectors": [
      { "id": "1", "metadata": { "url": "https://imgur.com/z9AVZLb" } },
      { "id": "2", "metadata": { "url": "https://imgur.com/a2nCEIt" } },
      { "id": "3", "metadata": { "url": "https://imgur.com/zfOPmnI" } }
    ]
  }
}