Meilisearch is an open-source, lightning-fast, and hyper relevant search engine. It comes with great defaults to help developers build snappy search experiences. You can self-host Meilisearch or run on Meilisearch Cloud.Meilisearch v1.3 supports vector search. This page guides you through integrating Meilisearch as a vector store and using it to perform vector search. You’ll need to install
langchain-community
with pip install -qU langchain-community
to use this integration
Setup
Launching a Meilisearch instance
You will need a running Meilisearch instance to use as your vector store. You can run Meilisearch in local or create a Meilisearch Cloud account. As of Meilisearch v1.3, vector storage is an experimental feature. After launching your Meilisearch instance, you need to enable vector storage. For self-hosted Meilisearch, read the docs on enabling experimental features. On Meilisearch Cloud, enable Vector Store via your project Settings page. You should now have a running Meilisearch instance with vector storage enabled. 🎉Credentials
To interact with your Meilisearch instance, the Meilisearch SDK needs a host (URL of your instance) and an API key. Host- In local, the default host is
localhost:7700
- On Meilisearch Cloud, find the host in your project Settings page
- A
MASTER KEY
— it should only be used to create your Meilisearch instance - A
ADMIN KEY
— use it only server-side to update your database and its settings - A
SEARCH KEY
— a key that you can safely share in front-end applications
Installing dependencies
This guide uses the Meilisearch Python SDK. You can install it by running:Examples
There are multiple ways to initialize the Meilisearch vector store: providing a Meilisearch client or the URL and API key as needed. In our examples, the credentials will be loaded from the environment. You can make environment variables available in your Notebook environment by usingos
and getpass
. You can use this technique for all the following examples.
Adding text and embeddings
This example adds text to the Meilisearch vector database without having to initialize a Meilisearch vector store.Adding documents and embeddings
In this example, we’ll use LangChain TextSplitter to split the text in multiple documents. Then, we’ll store these documents along with their embeddings.Add documents by creating a Meilisearch Vectorstore
In this approach, we create a vector store object and add documents to it.Similarity Search with score
This specific method allows you to return the documents and the distance score of the query to them.embedder_name
is the name of the embedder that should be used for semantic search, defaults to “default”.
Similarity Search by vector
embedder_name
is the name of the embedder that should be used for semantic search, defaults to “default”.