Skip to content

Commit

Permalink
custom settings on vectorstore
Browse files Browse the repository at this point in the history
  • Loading branch information
giacbrd committed Nov 28, 2024
1 parent 9c3bccd commit 56b3c72
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions libs/elasticsearch/langchain_elasticsearch/_async/vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ class AsyncElasticsearchStore(VectorStore):
Name of the index to create.
embedding: Embeddings
Embedding function to use.
custom_index_settings: Optional[Dict[str, Any]]
A dictionary of custom settings for the index.
This can include configurations like the number of shards, number of replicas,
analysis settings, and other index-specific settings. If not provided, default
settings will be used. Note that if the same setting is provided by both the user
and the strategy, will raise an error.
Key init args — client params:
es_connection: Optional[Elasticsearch]
Expand All @@ -101,6 +107,8 @@ class AsyncElasticsearchStore(VectorStore):
Password to use when connecting to Elasticsearch.
es_api_key: Optional[str]
API key to use when connecting to Elasticsearch.
es_params: Optional[Dict[str, Any]]
Additional parameters for the Elasticsearch client.
Instantiate:
.. code-block:: python
Expand Down Expand Up @@ -311,6 +319,7 @@ def __init__(
BaseRetrievalStrategy, AsyncRetrievalStrategy
] = ApproxRetrievalStrategy(),
es_params: Optional[Dict[str, Any]] = None,
custom_index_settings: Optional[Dict[str, Any]] = None,
):
if isinstance(strategy, BaseRetrievalStrategy):
strategy = _convert_retrieval_strategy(
Expand Down Expand Up @@ -339,6 +348,7 @@ def __init__(
text_field=query_field,
vector_field=vector_query_field,
user_agent=user_agent("langchain-py-vs"),
custom_index_settings=custom_index_settings,
)

self.embedding = embedding
Expand Down
10 changes: 10 additions & 0 deletions libs/elasticsearch/langchain_elasticsearch/_sync/vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ class ElasticsearchStore(VectorStore):
Name of the index to create.
embedding: Embeddings
Embedding function to use.
custom_index_settings: Optional[Dict[str, Any]]
A dictionary of custom settings for the index.
This can include configurations like the number of shards, number of replicas,
analysis settings, and other index-specific settings. If not provided, default
settings will be used. Note that if the same setting is provided by both the user
and the strategy, will raise an error.
Key init args — client params:
es_connection: Optional[Elasticsearch]
Expand All @@ -101,6 +107,8 @@ class ElasticsearchStore(VectorStore):
Password to use when connecting to Elasticsearch.
es_api_key: Optional[str]
API key to use when connecting to Elasticsearch.
es_params: Optional[Dict[str, Any]]
Additional parameters for the Elasticsearch client.
Instantiate:
.. code-block:: python
Expand Down Expand Up @@ -311,6 +319,7 @@ def __init__(
BaseRetrievalStrategy, RetrievalStrategy
] = ApproxRetrievalStrategy(),
es_params: Optional[Dict[str, Any]] = None,
custom_index_settings: Optional[Dict[str, Any]] = None,
):
if isinstance(strategy, BaseRetrievalStrategy):
strategy = _convert_retrieval_strategy(
Expand Down Expand Up @@ -339,6 +348,7 @@ def __init__(
text_field=query_field,
vector_field=vector_query_field,
user_agent=user_agent("langchain-py-vs"),
custom_index_settings=custom_index_settings,
)

self.embedding = embedding
Expand Down

0 comments on commit 56b3c72

Please sign in to comment.