An implementation of LangChain vectorstore abstraction using gel as the backend.
Gel is an open-source PostgreSQL data layer optimized for fast development to production cycle. It comes with a high-level strictly typed graph-like data model, composable hierarchical query language, full SQL support, migrations, Auth and AI modules.
The code lives in an integration package called langchain-gel.
Setup
First install relevant packages:Initialization
In order to use Gel as a backend for yourVectorStore, you’re going to need a working Gel instance.
Fortunately, it doesn’t have to involve Docker containers or anything complicated, unless you want to!
To set up a local instance, run:
Set up the schema
Gel schema is an explicit high-level description of your application’s data model. Aside from enabling you to define exactly how your data is going to be laid out, it drives Gel’s many powerful features such as links, access policies, functions, triggers, constraints, indexes, and more. The LangChain’sVectorStore expects the following layout for the schema:
GelVectorStore can be used as a drop-in replacement for any other vectorstore available in LangChain.
Instantiation
Manage vector store
Add items to vector store
Note that adding documents by ID will over-write any existing documents that match that ID.Delete items from vector store
Query vector store
Once your vector store has been created and the relevant documents have been added you will most likely wish to query it during the running of your chain or agent.Filtering Support
The vectorstore supports a set of filters that can be applied against the metadata fields of the documents.| Operator | Meaning/Category |
|---|---|
| $eq | Equality (==) |
| $ne | Inequality (!=) |
| $lt | Less than (<) |
| $lte | Less than or equal (<=) |
| $gt | Greater than (>) |
| $gte | Greater than or equal (>=) |
| $in | Special Cased (in) |
| $nin | Special Cased (not in) |
| $between | Special Cased (between) |
| $like | Text (like) |
| $ilike | Text (case-insensitive like) |
| $and | Logical (and) |
| $or | Logical (or) |
Query directly
Performing a simple similarity search can be done as follows:Query by turning into retriever
You can also transform the vector store into a retriever for easier usage in your chains.Usage for retrieval-augmented generation
For guides on how to use this vector store for retrieval-augmented generation (RAG), see the following sections:API reference
For detailed documentation of all GelVectorStore features and configurations head to the API reference: python.langchain.com/api_reference/Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.