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_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) → List[Tuple[Document, float]]¶
Return docs and relevance scores in the range [0, 1].
0 is dissimilar, 1 is most similar.
Parameters
query – input text
k – Number of Documents to return. Defaults to 4.
**kwargs – kwargs to be passed to similarity search. Should include:
score_threshold: Optional, a floating point value between 0 to 1 to
filter the resulting set of retrieved docs
Returns
List of Tuples of (doc, similarity_score)
similarity_search_with_score(query: str, k: int = 4, param: Optional[dict] = None, expr: Optional[str] = None, timeout: Optional[int] = None, **kwargs: Any) → List[Tuple[Document, float]][source]¶
Performs a search on the query string and returns results with scores.
Parameters
query (str) – The text being searched.
k (int, optional) – The number of results to return.
4. (Default is) – 
param (dict) – Specifies the search parameters for the index.
None. (Default is) – 
expr (str, optional) – Filtering expression. Default is None.
timeout (int, optional) – The waiting time before a timeout error.
None. – 
kwargs – Keyword arguments for Collection.search().
Return type
List[float], List[Tuple[Document, any, any]]