Perform a hybrid k-NN and text search on the Elasticsearch index.
knn_hybrid_search(
self,
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,
knn_boost: Optional[float] = 0.9,
query_boost: Optional[float] = 0.1,
fields: Optional[Union[List[Mapping[str, Any]], Tuple[Mapping[str, Any], ...], None]] = None,
page_content: Optional[str] = 'text'
) -> List[Tuple[Document, float]]| Name | Type | Description |
|---|---|---|
query | str | Default: NoneThe query text to search for. |
k | int | Default: 10The number of nearest neighbors to return. |
query_vector | List[float] | Default: NoneThe query vector to search for. |
model_id | str | Default: NoneThe ID of the model to use for transforming the query text into a vector. |
size | int | Default: 10The number of search results to return. |
source | bool | Default: TrueWhether to return the source of the search results. |
knn_boost | float | Default: 0.9The boost value to apply to the k-NN search results. |
query_boost | float | Default: 0.1The boost value to apply to the text search results. |
fields | List[Mapping[str, Any]] | Default: NoneThe fields to return in the search results. |
page_content | str | Default: 'text'The name of the field that contains the page content. |