mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-14 08:56:27 +00:00
Virat/add param to optionally not refresh ES indices (#2233)
**Context** Noticed a TODO in `langchain/vectorstores/elastic_vector_search.py` for adding the option to NOT refresh ES indices **Change** Added a param to `add_texts()` called `refresh_indices` to not refresh ES indices. The default value is `True` so that existing behavior does not break.
This commit is contained in:
parent
579ad85785
commit
a9dddd8a32
@ -132,6 +132,7 @@ class ElasticVectorSearch(VectorStore, ABC):
|
|||||||
self,
|
self,
|
||||||
texts: Iterable[str],
|
texts: Iterable[str],
|
||||||
metadatas: Optional[List[dict]] = None,
|
metadatas: Optional[List[dict]] = None,
|
||||||
|
refresh_indices: bool = True,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> List[str]:
|
) -> List[str]:
|
||||||
"""Run more texts through the embeddings and add to the vectorstore.
|
"""Run more texts through the embeddings and add to the vectorstore.
|
||||||
@ -139,6 +140,7 @@ class ElasticVectorSearch(VectorStore, ABC):
|
|||||||
Args:
|
Args:
|
||||||
texts: Iterable of strings to add to the vectorstore.
|
texts: Iterable of strings to add to the vectorstore.
|
||||||
metadatas: Optional list of metadatas associated with the texts.
|
metadatas: Optional list of metadatas associated with the texts.
|
||||||
|
refresh_indices: bool to refresh ElasticSearch indices
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
List of ids from adding the texts into the vectorstore.
|
List of ids from adding the texts into the vectorstore.
|
||||||
@ -167,8 +169,9 @@ class ElasticVectorSearch(VectorStore, ABC):
|
|||||||
ids.append(_id)
|
ids.append(_id)
|
||||||
requests.append(request)
|
requests.append(request)
|
||||||
bulk(self.client, requests)
|
bulk(self.client, requests)
|
||||||
# TODO: add option not to refresh
|
|
||||||
self.client.indices.refresh(index=self.index_name)
|
if refresh_indices:
|
||||||
|
self.client.indices.refresh(index=self.index_name)
|
||||||
return ids
|
return ids
|
||||||
|
|
||||||
def similarity_search(
|
def similarity_search(
|
||||||
|
Loading…
Reference in New Issue
Block a user