ECloud Vector Search in LangChain - Using China Mobile's ElasticSearch Service
Posted: Feb 9, 2025.
The ECloud Vector Search integration in LangChain provides a way to store and search document embeddings using China Mobile's ECloud ElasticSearch service. This guide will show you how to use the EcloudESVectorStore class for vector similarity search and document retrieval.
What is EcloudESVectorStore?
EcloudESVectorStore is a vector store implementation that uses China Mobile's ECloud ElasticSearch service as the backend. It allows you to:
- Store document embeddings in ElasticSearch indices
- Perform similarity searches using different models and methods
- Filter search results
- Support for asynchronous operations
- Handle document metadata and embeddings
Reference
Key methods of the EcloudESVectorStore class:
Method | Description |
---|---|
from_documents() | Create a vector store from a list of documents |
from_texts() | Create a vector store from raw texts |
similarity_search() | Find similar documents to a query text |
similarity_search_with_score() | Find similar documents with similarity scores |
add_documents() | Add new documents to the store |
delete() | Delete documents from the store |
max_marginal_relevance_search() | Search with diversity optimization |
How to use EcloudESVectorStore
Basic Setup and Initialization
First, let's set up a connection to ECloud ElasticSearch:
Adding Documents
You can add documents in a few different ways:
Performing Similarity Searches
Basic similarity search:
Using filters:
Advanced Search Options
Using different search models and similarities:
Async Operations
The class supports async operations for better performance in async applications:
The EcloudESVectorStore provides a robust integration with China Mobile's ECloud ElasticSearch service, offering various search models and methods for different use cases. Whether you need exact search, LSH-based approximate search, or filtered queries, the implementation provides flexibility while maintaining ease of use.
An alternative to LangSmith
Open-source LangChain monitoring, prompt management, and magic. Get started in 2 minutes.
LangChain DocsJoin 10,000+ subscribers
Every 2 weeks, latest model releases and industry news.
An alternative to LangSmith
Open-source LangChain monitoring, prompt management, and magic. Get started in 2 minutes.