langchain.vectorstores.elasticsearch.BaseRetrievalStrategy¶
class langchain.vectorstores.elasticsearch.BaseRetrievalStrategy[source]¶
Base class for Elasticsearch retrieval strategies.
Methods
__init__()
before_index_setup(client, text_field, ...)
Executes before the index is created.
index(dims_length, vector_query_field, ...)
Executes when the index is created.
query(query_vector, query, *, k, fetch_k, ...)
Executes when a search is performed on the store.
require_inference()
Returns whether or not the strategy requires inference to be performed on the text before it is added to the index.
__init__()¶
before_index_setup(client: Elasticsearch, text_field: str, vector_query_field: str) → None[source]¶
Executes before the index is created. Used for setting up
any required Elasticsearch resources like a pipeline.
Parameters
client – The Elasticsearch client.
text_field – The field containing the text data in the index.
vector_query_field – The field containing the vector
representations in the index.
abstract index(dims_length: Optional[int], vector_query_field: str, similarity: Optional[DistanceStrategy]) → Dict[source]¶
Executes when the index is created.
Parameters
dims_length – Numeric length of the embedding vectors,
or None if not using vector-based query.
vector_query_field – The field containing the vector
representations in the index.
similarity – The similarity strategy to use,
or None if not using one.
Returns
The Elasticsearch settings and mappings for the strategy.
Return type
Dict
abstract query(query_vector: Optional[List[float]], query: Optional[str], *, k: int, fetch_k: int, vector_query_field: str, text_field: str, filter: List[dict], similarity: Optional[DistanceStrategy]) → Dict[source]¶