Data is another kind of information you can store per vector
to attribute some context to it. Compared to metadata, it is not
structured, and it can only be fetched in queries, not used
to further filter them.It is especially useful when you upsert raw text data, so that you
would have access to the textual form of vector along with the
embedded vector values.It can save you from storing contextual information per vector
in a separate database.You can set both the metadata and data, or only one of them
while upserting your vectors as follows:
When a raw text data is upserted, the data will be set to
the raw text data automatically:
Copy
Ask AI
from upstash_vector import Indexindex = Index( url="UPSTASH_VECTOR_REST_URL", token="UPSTASH_VECTOR_REST_TOKEN",)index.upsert( [ { "id": "id-2", "data": "Upstash is a serverless data platform.", }, ],)
Copy
Ask AI
from upstash_vector import Indexindex = Index( url="UPSTASH_VECTOR_REST_URL", token="UPSTASH_VECTOR_REST_TOKEN",)result = index.query( data="What is Upstash?", include_data=True,)for res in result: print(f"{res.id}: {res.data}")
Similar to metadata, the data field can be requested in queries, range
iterator, and fetch requests, by setting the includeData to true as
shown above.