Return docs most similar to query.
async asimilarity_search_by_vector(embedding: List[float], k: int = 4, **kwargs: Any) → List[Document]¶
Return docs most similar to embedding vector.
async asimilarity_search_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) → List[Tuple[Document, float]]¶
Return docs most similar to query.
create_knn_index(mapping: Dict) → None[source]¶
Create a new k-NN index in Elasticsearch.
Parameters
mapping (Dict) – The mapping to use for the new index.
Returns
None
delete(ids: Optional[List[str]] = None, **kwargs: Any) → Optional[bool]¶
Delete by vector ID or other criteria.
Parameters
ids – List of ids to delete.
**kwargs – Other keyword arguments that subclasses might use.
Returns
True if deletion is successful,
False otherwise, None if not implemented.
Return type
Optional[bool]
classmethod from_documents(documents: List[Document], embedding: Embeddings, **kwargs: Any) → VST¶
Return VectorStore initialized from documents and embeddings.
classmethod from_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[Dict[Any, Any]]] = None, **kwargs: Any) → ElasticKnnSearch[source]¶
Create a new ElasticKnnSearch instance and add a list of texts to theElasticsearch index.
Parameters
texts (List[str]) – The texts to add to the index.
embedding (Embeddings) – The embedding model to use for transforming the
texts into vectors.
metadatas (List[Dict[Any, Any]], optional) – A list of metadata dictionaries
to associate with the texts.
**kwargs – Arbitrary keyword arguments.
Returns