ExactRetrievalStrategy#
- class langchain_elasticsearch.vectorstores.ExactRetrievalStrategy(*args, **kwargs)[source]#
Deprecated since version 0.2.0: Use
DenseVectorScriptScoreStrategy
instead.Exact retrieval strategy using the script_score query.
Methods
__init__
(*args,Β **kwargs)before_index_setup
(client,Β text_field,Β ...)Executes before the index is created.
index
(dims_length,Β vector_query_field,Β ...)Create the mapping for the Elasticsearch index.
query
(query_vector,Β query,Β k,Β fetch_k,Β ...)Executes when a search is performed on the store.
Returns whether or not the strategy requires inference to be performed on the text before it is added to the index.
- __init__(*args: Any, **kwargs: Any) Any #
- Parameters:
self (Any) β
args (Any) β
kwargs (Any) β
- Return type:
Any
- before_index_setup(client: Elasticsearch, text_field: str, vector_query_field: str) None #
Executes before the index is created. Used for setting up any required Elasticsearch resources like a pipeline.
- Parameters:
client (Elasticsearch) β The Elasticsearch client.
text_field (str) β The field containing the text data in the index.
vector_query_field (str) β The field containing the vector representations in the index.
- Return type:
None
- index(dims_length: int | None, vector_query_field: str, text_field: str, similarity: DistanceStrategy | None) Dict [source]#
Create the mapping for the Elasticsearch index.
- Parameters:
dims_length (int | None) β
vector_query_field (str) β
text_field (str) β
similarity (DistanceStrategy | None) β
- Return type:
Dict
- query(query_vector: List[float] | None, query: str | None, k: int, fetch_k: int, vector_query_field: str, text_field: str, filter: List[dict] | None, similarity: DistanceStrategy | None) Dict [source]#
Executes when a search is performed on the store.
- Parameters:
query_vector (List[float] | None) β The query vector, or None if not using vector-based query.
query (str | None) β The text query, or None if not using text-based query.
k (int) β The total number of results to retrieve.
fetch_k (int) β The number of results to fetch initially.
vector_query_field (str) β The field containing the vector representations in the index.
text_field (str) β The field containing the text data in the index.
filter (List[dict] | None) β List of filter clauses to apply to the query.
similarity (DistanceStrategy | None) β The similarity strategy to use, or None if not using one.
- Returns:
The Elasticsearch query body.
- Return type:
Dict
- require_inference() bool #
Returns whether or not the strategy requires inference to be performed on the text before it is added to the index.
- Returns:
Whether or not the strategy requires inference to be performed on the text before it is added to the index.
- Return type:
bool