chunk_overlap=0)texts = text_splitter.split_text(state_of_the_union)# Use Meilisearch vector store to store texts & associated embeddings as vectorvector_store = Meilisearch.from_texts(texts=texts, embedding=embeddings)Behind the scenes, Meilisearch will convert the text to multiple vectors. This will bring us to the same result as the following example.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.from langchain.document_loaders import TextLoader# Load textloader = TextLoader("../../modules/state_of_the_union.txt")documents = loader.load()text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)# Create documentsdocs = text_splitter.split_documents(documents)# Import documents & embeddings in the vector storevector_store = Meilisearch.from_documents(documents=documents, embedding=embeddings)# Search in our vector storequery = "What did the president say about Ketanji Brown Jackson"docs = vector_store.similarity_search(query)print(docs[0].page_content)Add documents by creating a Meilisearch Vectorstore‚ÄãIn this approach, we create a vector store object and add documents to it.from langchain.vectorstores import Meilisearchimport meilisearchclient = meilisearch.Client(url="http://127.0.0.1:7700", api_key="***")vector_store = Meilisearch(    embedding=embeddings, client=client, index_name="langchain_demo", text_key="text")vector_store.add_documents(documents)Similarity Search with score‚ÄãThis specific method allows you to return the documents and the distance score of the query to them.docs_and_scores = vector_store.similarity_search_with_score(query)docs_and_scores[0]Similarity Search by vector‚Äãembedding_vector = embeddings.embed_query(query)docs_and_scores = vector_store.similarity_search_by_vector(embedding_vector)docs_and_scores[0]Additional resources‚ÄãDocumentationMeilisearchMeilisearch Python
Meilisearch is an open-source, lightning-fast, and hyper relevant search engine. It comes with great defaults to help developers build snappy search experiences.
Meilisearch is an open-source, lightning-fast, and hyper relevant search engine. It comes with great defaults to help developers build snappy search experiences. ->: chunk_overlap=0)texts = text_splitter.split_text(state_of_the_union)# Use Meilisearch vector store to store texts & associated embeddings as vectorvector_store = Meilisearch.from_texts(texts=texts, embedding=embeddings)Behind the scenes, Meilisearch will convert the text to multiple vectors. This will bring us to the same result as the following example.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.from langchain.document_loaders import TextLoader# Load textloader = TextLoader("../../modules/state_of_the_union.txt")documents = loader.load()text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)# Create documentsdocs = text_splitter.split_documents(documents)# Import documents & embeddings in the vector storevector_store = Meilisearch.from_documents(documents=documents, embedding=embeddings)# Search in our vector storequery = "What did the president say about Ketanji Brown Jackson"docs = vector_store.similarity_search(query)print(docs[0].page_content)Add documents by creating a Meilisearch Vectorstore‚ÄãIn this approach, we create a vector store object and add documents to it.from langchain.vectorstores import Meilisearchimport meilisearchclient = meilisearch.Client(url="http://127.0.0.1:7700", api_key="***")vector_store = Meilisearch(    embedding=embeddings, client=client, index_name="langchain_demo", text_key="text")vector_store.add_documents(documents)Similarity Search with score‚ÄãThis specific method allows you to return the documents and the distance score of the query to them.docs_and_scores = vector_store.similarity_search_with_score(query)docs_and_scores[0]Similarity Search by vector‚Äãembedding_vector = embeddings.embed_query(query)docs_and_scores = vector_store.similarity_search_by_vector(embedding_vector)docs_and_scores[0]Additional resources‚ÄãDocumentationMeilisearchMeilisearch Python