Return docs most similar to query using specified search type.
similarity_search(query: str, k: int = 4, filter: Optional[RedisFilterExpression] = None, return_metadata: bool = True, distance_threshold: Optional[float] = None, **kwargs: Any) → List[Document][source]¶
Run similarity search
Parameters
query (str) – The query text for which to find similar documents.
k (int) – The number of documents to return. Default is 4.
filter (RedisFilterExpression, optional) – Optional metadata filter.
Defaults to None.
return_metadata (bool, optional) – Whether to return metadata.
Defaults to True.
distance_threshold (Optional[float], optional) – Maximum vector distance
between selected documents and the query vector. Defaults to None.
Returns
A list of documents that are most similar to the querytext.
Return type
List[Document]
similarity_search_by_vector(embedding: List[float], k: int = 4, filter: Optional[RedisFilterExpression] = None, return_metadata: bool = True, distance_threshold: Optional[float] = None, **kwargs: Any) → List[Document][source]¶
Run similarity search between a query vector and the indexed vectors.
Parameters
embedding (List[float]) – The query vector for which to find similar
documents.
k (int) – The number of documents to return. Default is 4.
filter (RedisFilterExpression, optional) – Optional metadata filter.
Defaults to None.
return_metadata (bool, optional) – Whether to return metadata.
Defaults to True.
distance_threshold (Optional[float], optional) – Maximum vector distance
between selected documents and the query vector. Defaults to None.
Returns
A list of documents that are most similar to the querytext.
Return type
List[Document]