Xata is a serverless data platform, based on PostgreSQL. It provides a Python SDK for interacting with your database, and a UI for managing your data. Xata has a native vector type, which can be added to any table, and supports similarity search. LangChain inserts vectors directly to Xata, and queries it for the nearest neighbors of a given vector, so that you can use all the LangChain Embeddings integrations with Xata.This notebook guides you how to use Xata as a VectorStore.
Setup
Create a database to use as a vector store
In the Xata UI create a new database. You can name it whatever you want, in this notepad we’ll uselangchain.
Create a table, again you can name it anything, but we will use vectors. Add the following columns via the UI:
contentof type “Text”. This is used to store theDocument.pageContentvalues.embeddingof type “Vector”. Use the dimension used by the model you plan to use. In this notebook we use OpenAI embeddings, which have 1536 dimensions.sourceof type “Text”. This is used as a metadata column by this example.- any other columns you want to use as metadata. They are populated from the
Document.metadataobject. For example, if in theDocument.metadataobject you have atitleproperty, you can create atitlecolumn in the table and it will be populated.
https://demo-uni3q8.eu-west-1.xata.sh/db/langchain.
Create the Xata vector store
Let’s import our test dataset:Similarity Search
Similarity Search with score (vector distance)
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.