Returns
A list of tuples, where each tuple contains a Document object and a score.
knn_search(query: Optional[str] = None, k: Optional[int] = 10, query_vector: Optional[List[float]] = None, model_id: Optional[str] = None, size: Optional[int] = 10, source: Optional[bool] = True, fields: Optional[Union[List[Mapping[str, Any]], Tuple[Mapping[str, Any], ...]]] = None, page_content: Optional[str] = 'text') → List[Tuple[Document, float]][source]¶
Perform a k-NN search on the Elasticsearch index.
Parameters
query (str, optional) – The query text to search for.
k (int, optional) – The number of nearest neighbors to return.
query_vector (List[float], optional) – The query vector to search for.
model_id (str, optional) – The ID of the model to use for transforming the
query text into a vector.
size (int, optional) – The number of search results to return.
source (bool, optional) – Whether to return the source of the search results.
fields (List[Mapping[str, Any]], optional) – The fields to return in the
search results.
page_content (str, optional) – The name of the field that contains the page
content.
Returns
A list of tuples, where each tuple contains a Document object and a score.
max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) → List[Document]¶
Return docs selected using the maximal marginal relevance.
Maximal marginal relevance optimizes for similarity to query AND diversity
among selected documents.
Parameters
query – Text to look up documents similar to.