elasticsearch-haystack 0.2.0__py3-none-any.whl → 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of elasticsearch-haystack might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: elasticsearch-haystack
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Haystack 2.x Document Store for ElasticSearch
5
5
  Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/elasticsearch#readme
6
6
  Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
@@ -1,10 +1,10 @@
1
1
  haystack_integrations/components/retrievers/elasticsearch/__init__.py,sha256=cSJBsYjz_T4kK-M-auAHVUnYIcgUqqwwQe_hsF0_IG4,307
2
- haystack_integrations/components/retrievers/elasticsearch/bm25_retriever.py,sha256=Taq5pPDIu5lUuCgdbbZoGCMozUIoKqCVzcc085jGpNg,4277
3
- haystack_integrations/components/retrievers/elasticsearch/embedding_retriever.py,sha256=Y2C4Foeiqg2-bOEcc_WEyC62k96DqjnMqBllPcgCrxk,3392
2
+ haystack_integrations/components/retrievers/elasticsearch/bm25_retriever.py,sha256=qu67WxyTjh1DbEEqg1_IcOkNl0BHtedLFjQVDC0bONE,4398
3
+ haystack_integrations/components/retrievers/elasticsearch/embedding_retriever.py,sha256=6HhfAzOjec9R2PnjWT2hLcIWVEe6-bZuWhULu18gJCE,3513
4
4
  haystack_integrations/document_stores/elasticsearch/__init__.py,sha256=YTfu94dtVUBogbJFr1aJrKuaI6-Bw9VuHfPoyU7M8os,207
5
- haystack_integrations/document_stores/elasticsearch/document_store.py,sha256=SDaPCgK1B_O3G7pNa2Z71YktvgpAHDGgC_gHuzy2HTE,15416
5
+ haystack_integrations/document_stores/elasticsearch/document_store.py,sha256=qFe9BmXaT6vNOF5EYZ8PNhC6Z1bZVzBoAZ5J2agwcZI,15586
6
6
  haystack_integrations/document_stores/elasticsearch/filters.py,sha256=L1tN7YCIDuNdhGrBQdPoqXFk37x__2-K038xZ6PRdNQ,9923
7
- elasticsearch_haystack-0.2.0.dist-info/METADATA,sha256=Enr2ufED5ISLsuRqZatL08Zg_Wss1x9A8uyS1eXCUsw,2105
8
- elasticsearch_haystack-0.2.0.dist-info/WHEEL,sha256=mRYSEL3Ih6g5a_CVMIcwiF__0Ae4_gLYh01YFNwiq1k,87
9
- elasticsearch_haystack-0.2.0.dist-info/licenses/LICENSE,sha256=_M2kulivnaiTHiW-5CRlZrPmH47tt04pBgAgeDvfYi4,11342
10
- elasticsearch_haystack-0.2.0.dist-info/RECORD,,
7
+ elasticsearch_haystack-0.3.0.dist-info/METADATA,sha256=P5KpaBuMowYSFu5pf88YxHfyZI0oHJZ-4Z5-tdj7AwE,2105
8
+ elasticsearch_haystack-0.3.0.dist-info/WHEEL,sha256=TJPnKdtrSue7xZ_AVGkp9YXcvDrobsjBds1du3Nx6dc,87
9
+ elasticsearch_haystack-0.3.0.dist-info/licenses/LICENSE,sha256=_M2kulivnaiTHiW-5CRlZrPmH47tt04pBgAgeDvfYi4,11342
10
+ elasticsearch_haystack-0.3.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.21.0
2
+ Generator: hatchling 1.21.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -89,17 +89,18 @@ class ElasticsearchBM25Retriever:
89
89
  return default_from_dict(cls, data)
90
90
 
91
91
  @component.output_types(documents=List[Document])
92
- def run(self, query: str, top_k: Optional[int] = None):
92
+ def run(self, query: str, filters: Optional[Dict[str, Any]] = None, top_k: Optional[int] = None):
93
93
  """
94
94
  Retrieve documents using the BM25 keyword-based algorithm.
95
95
 
96
96
  :param query: String to search in Documents' text.
97
+ :param filters: Filters applied to the retrieved Documents.
97
98
  :param top_k: Maximum number of Documents to return.
98
99
  :return: List of Documents that match the query.
99
100
  """
100
101
  docs = self._document_store._bm25_retrieval(
101
102
  query=query,
102
- filters=self._filters,
103
+ filters=filters or self._filters,
103
104
  fuzziness=self._fuzziness,
104
105
  top_k=top_k or self._top_k,
105
106
  scale_score=self._scale_score,
@@ -63,17 +63,18 @@ class ElasticsearchEmbeddingRetriever:
63
63
  return default_from_dict(cls, data)
64
64
 
65
65
  @component.output_types(documents=List[Document])
66
- def run(self, query_embedding: List[float], top_k: Optional[int] = None):
66
+ def run(self, query_embedding: List[float], filters: Optional[Dict[str, Any]] = None, top_k: Optional[int] = None):
67
67
  """
68
68
  Retrieve documents using a vector similarity metric.
69
69
 
70
70
  :param query_embedding: Embedding of the query.
71
+ :param filters: Filters applied to the retrieved Documents.
71
72
  :param top_k: Maximum number of Documents to return.
72
73
  :return: List of Documents similar to `query_embedding`.
73
74
  """
74
75
  docs = self._document_store._embedding_retrieval(
75
76
  query_embedding=query_embedding,
76
- filters=self._filters,
77
+ filters=filters or self._filters,
77
78
  top_k=top_k or self._top_k,
78
79
  num_candidates=self._num_candidates,
79
80
  )
@@ -13,6 +13,7 @@ from haystack.dataclasses import Document
13
13
  from haystack.document_stores.errors import DocumentStoreError, DuplicateDocumentError
14
14
  from haystack.document_stores.types import DuplicatePolicy
15
15
  from haystack.utils.filters import convert
16
+ from haystack.version import __version__ as haystack_version
16
17
 
17
18
  from elasticsearch import Elasticsearch, helpers # type: ignore[import-not-found]
18
19
 
@@ -90,7 +91,11 @@ class ElasticsearchDocumentStore:
90
91
  :param **kwargs: Optional arguments that ``Elasticsearch`` takes.
91
92
  """
92
93
  self._hosts = hosts
93
- self._client = Elasticsearch(hosts, **kwargs)
94
+ self._client = Elasticsearch(
95
+ hosts,
96
+ headers={"user-agent": f"haystack-py-ds/{haystack_version}"},
97
+ **kwargs,
98
+ )
94
99
  self._index = index
95
100
  self._embedding_similarity_function = embedding_similarity_function
96
101
  self._kwargs = kwargs