k – Number of Documents to return. Defaults to 4.
fetch_k – Number of Documents to fetch to pass to MMR algorithm.
lambda_mult – Number between 0 and 1 that determines the degree
of diversity among the results with 0 corresponding
to maximum diversity and 1 to minimum diversity.
Defaults to 0.5.
Returns
List of Documents selected by maximal marginal relevance.
search(query: str, search_type: str, **kwargs: Any) → List[Document]¶
Return docs most similar to query using specified search type.
similarity_search(query: str, k: int = 4, filter: Optional[List[dict]] = None, **kwargs: Any) → List[Document][source]¶
Return Elasticsearch documents most similar to query.
Parameters
query – Text to look up documents similar to.
k – Number of Documents to return. Defaults to 4.
filter – Array of Elasticsearch filter clauses to apply to the query.
Returns
List of Documents most similar to the query,
in descending order of similarity.
similarity_search_by_vector(embedding: List[float], k: int = 4, **kwargs: Any) → List[Document]¶
Return docs most similar to embedding vector.
Parameters
embedding – Embedding to look up documents similar to.
k – Number of Documents to return. Defaults to 4.
Returns
List of Documents most similar to the query vector.
similarity_search_by_vector_with_relevance_scores(embedding: List[float], k: int = 4, filter: Optional[List[Dict]] = None, **kwargs: Any) → List[Tuple[Document, float]][source]¶
Return Elasticsearch documents most similar to query, along with scores.
Parameters
embedding – Embedding to look up documents similar to.
k – Number of Documents to return. Defaults to 4.