elasticsearch-haystack 4.0.0__tar.gz → 4.1.0__tar.gz
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.
- {elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/CHANGELOG.md +13 -0
- {elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/PKG-INFO +1 -1
- {elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/src/haystack_integrations/document_stores/elasticsearch/document_store.py +129 -27
- {elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/tests/test_document_store.py +130 -0
- {elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/.gitignore +0 -0
- {elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/LICENSE +0 -0
- {elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/README.md +0 -0
- {elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/docker-compose.yml +0 -0
- {elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/pydoc/config.yml +0 -0
- {elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/pyproject.toml +0 -0
- {elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/src/haystack_integrations/components/retrievers/elasticsearch/__init__.py +0 -0
- {elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/src/haystack_integrations/components/retrievers/elasticsearch/bm25_retriever.py +0 -0
- {elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/src/haystack_integrations/components/retrievers/elasticsearch/embedding_retriever.py +0 -0
- {elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/src/haystack_integrations/components/retrievers/py.typed +0 -0
- {elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/src/haystack_integrations/document_stores/elasticsearch/__init__.py +0 -0
- {elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/src/haystack_integrations/document_stores/elasticsearch/filters.py +0 -0
- {elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/src/haystack_integrations/document_stores/py.typed +0 -0
- {elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/tests/__init__.py +0 -0
- {elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/tests/test_bm25_retriever.py +0 -0
- {elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/tests/test_embedding_retriever.py +0 -0
- {elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/tests/test_filters.py +0 -0
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [integrations/elasticsearch-v4.0.0] - 2025-09-24
|
|
4
|
+
|
|
5
|
+
### 🚀 Features
|
|
6
|
+
|
|
7
|
+
- [**breaking**] Adding `api_token` and `apit_token_id` authentication support to `ElasticSearchDocumentStore` (#2292)
|
|
8
|
+
|
|
9
|
+
### 🧹 Chores
|
|
10
|
+
|
|
11
|
+
- Remove black (#1985)
|
|
12
|
+
- Standardize readmes - part 1 (#2202)
|
|
13
|
+
- Standardize readmes - part 2 (#2205)
|
|
14
|
+
|
|
15
|
+
|
|
3
16
|
## [integrations/elasticsearch-v3.1.0] - 2025-06-12
|
|
4
17
|
|
|
5
18
|
### 🐛 Bug Fixes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: elasticsearch-haystack
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.1.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
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
#
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
5
|
+
# ruff: noqa: FBT002, FBT001 boolean-type-hint-positional-argument and boolean-default-value-positional-argument
|
|
6
|
+
# ruff: noqa: B008 function-call-in-default-argument
|
|
7
|
+
# ruff: noqa: S101 disable checks for uses of the assert keyword
|
|
8
|
+
|
|
9
|
+
|
|
5
10
|
from collections.abc import Mapping
|
|
6
11
|
from typing import Any, Dict, List, Literal, Optional, Tuple, Union
|
|
7
12
|
|
|
@@ -68,8 +73,8 @@ class ElasticsearchDocumentStore:
|
|
|
68
73
|
hosts: Optional[Hosts] = None,
|
|
69
74
|
custom_mapping: Optional[Dict[str, Any]] = None,
|
|
70
75
|
index: str = "default",
|
|
71
|
-
api_key: Secret = Secret.from_env_var("ELASTIC_API_KEY", strict=False),
|
|
72
|
-
api_key_id: Secret = Secret.from_env_var("ELASTIC_API_KEY_ID", strict=False),
|
|
76
|
+
api_key: Secret = Secret.from_env_var("ELASTIC_API_KEY", strict=False),
|
|
77
|
+
api_key_id: Secret = Secret.from_env_var("ELASTIC_API_KEY_ID", strict=False),
|
|
73
78
|
embedding_similarity_function: Literal["cosine", "dot_product", "l2_norm", "max_inner_product"] = "cosine",
|
|
74
79
|
**kwargs: Any,
|
|
75
80
|
):
|
|
@@ -119,6 +124,29 @@ class ElasticsearchDocumentStore:
|
|
|
119
124
|
msg = "custom_mapping must be a dictionary"
|
|
120
125
|
raise ValueError(msg)
|
|
121
126
|
|
|
127
|
+
if not self._custom_mapping:
|
|
128
|
+
self._default_mappings = {
|
|
129
|
+
"properties": {
|
|
130
|
+
"embedding": {
|
|
131
|
+
"type": "dense_vector",
|
|
132
|
+
"index": True,
|
|
133
|
+
"similarity": self._embedding_similarity_function,
|
|
134
|
+
},
|
|
135
|
+
"content": {"type": "text"},
|
|
136
|
+
},
|
|
137
|
+
"dynamic_templates": [
|
|
138
|
+
{
|
|
139
|
+
"strings": {
|
|
140
|
+
"path_match": "*",
|
|
141
|
+
"match_mapping_type": "string",
|
|
142
|
+
"mapping": {
|
|
143
|
+
"type": "keyword",
|
|
144
|
+
},
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
}
|
|
149
|
+
|
|
122
150
|
def _ensure_initialized(self):
|
|
123
151
|
"""
|
|
124
152
|
Ensures both sync and async clients are initialized and the index exists.
|
|
@@ -150,27 +178,7 @@ class ElasticsearchDocumentStore:
|
|
|
150
178
|
mappings = self._custom_mapping
|
|
151
179
|
else:
|
|
152
180
|
# Configure mapping for the embedding field if none is provided
|
|
153
|
-
mappings =
|
|
154
|
-
"properties": {
|
|
155
|
-
"embedding": {
|
|
156
|
-
"type": "dense_vector",
|
|
157
|
-
"index": True,
|
|
158
|
-
"similarity": self._embedding_similarity_function,
|
|
159
|
-
},
|
|
160
|
-
"content": {"type": "text"},
|
|
161
|
-
},
|
|
162
|
-
"dynamic_templates": [
|
|
163
|
-
{
|
|
164
|
-
"strings": {
|
|
165
|
-
"path_match": "*",
|
|
166
|
-
"match_mapping_type": "string",
|
|
167
|
-
"mapping": {
|
|
168
|
-
"type": "keyword",
|
|
169
|
-
},
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
],
|
|
173
|
-
}
|
|
181
|
+
mappings = self._default_mappings
|
|
174
182
|
|
|
175
183
|
# Create the index if it doesn't exist
|
|
176
184
|
if not self._client.indices.exists(index=self._index):
|
|
@@ -227,7 +235,7 @@ class ElasticsearchDocumentStore:
|
|
|
227
235
|
Returns the synchronous Elasticsearch client, initializing it if necessary.
|
|
228
236
|
"""
|
|
229
237
|
self._ensure_initialized()
|
|
230
|
-
assert self._client is not None
|
|
238
|
+
assert self._client is not None
|
|
231
239
|
return self._client
|
|
232
240
|
|
|
233
241
|
@property
|
|
@@ -236,7 +244,7 @@ class ElasticsearchDocumentStore:
|
|
|
236
244
|
Returns the asynchronous Elasticsearch client, initializing it if necessary.
|
|
237
245
|
"""
|
|
238
246
|
self._ensure_initialized()
|
|
239
|
-
assert self._async_client is not None
|
|
247
|
+
assert self._async_client is not None
|
|
240
248
|
return self._async_client
|
|
241
249
|
|
|
242
250
|
def to_dict(self) -> Dict[str, Any]:
|
|
@@ -450,7 +458,7 @@ class ElasticsearchDocumentStore:
|
|
|
450
458
|
|
|
451
459
|
if errors:
|
|
452
460
|
# with stats_only=False, errors is guaranteed to be a list of dicts
|
|
453
|
-
assert isinstance(errors, list)
|
|
461
|
+
assert isinstance(errors, list)
|
|
454
462
|
duplicate_errors_ids = []
|
|
455
463
|
other_errors = []
|
|
456
464
|
for e in errors:
|
|
@@ -529,7 +537,7 @@ class ElasticsearchDocumentStore:
|
|
|
529
537
|
)
|
|
530
538
|
if failed:
|
|
531
539
|
# with stats_only=False, failed is guaranteed to be a list of dicts
|
|
532
|
-
assert isinstance(failed, list)
|
|
540
|
+
assert isinstance(failed, list)
|
|
533
541
|
if policy == DuplicatePolicy.FAIL:
|
|
534
542
|
for error in failed:
|
|
535
543
|
if "create" in error and error["create"]["status"] == DOC_ALREADY_EXISTS:
|
|
@@ -556,6 +564,14 @@ class ElasticsearchDocumentStore:
|
|
|
556
564
|
raise_on_error=False,
|
|
557
565
|
)
|
|
558
566
|
|
|
567
|
+
def _prepare_delete_all_request(self, *, is_async: bool) -> Dict[str, Any]:
|
|
568
|
+
return {
|
|
569
|
+
"index": self._index,
|
|
570
|
+
"body": {"query": {"match_all": {}}}, # Delete all documents
|
|
571
|
+
"wait_for_completion": False if is_async else True, # block until done (set False for async)
|
|
572
|
+
"refresh": True, # Ensure changes are visible immediately
|
|
573
|
+
}
|
|
574
|
+
|
|
559
575
|
async def delete_documents_async(self, document_ids: List[str]) -> None:
|
|
560
576
|
"""
|
|
561
577
|
Asynchronously deletes all documents with a matching document_ids from the document store.
|
|
@@ -575,6 +591,92 @@ class ElasticsearchDocumentStore:
|
|
|
575
591
|
msg = f"Failed to delete documents from Elasticsearch: {e!s}"
|
|
576
592
|
raise DocumentStoreError(msg) from e
|
|
577
593
|
|
|
594
|
+
def delete_all_documents(self, recreate_index: bool = False) -> None:
|
|
595
|
+
"""
|
|
596
|
+
Deletes all documents in the document store.
|
|
597
|
+
|
|
598
|
+
A fast way to clear all documents from the document store while preserving any index settings and mappings.
|
|
599
|
+
|
|
600
|
+
:param recreate_index: If True, the index will be deleted and recreated with the original mappings and
|
|
601
|
+
settings. If False, all documents will be deleted using the `delete_by_query` API.
|
|
602
|
+
"""
|
|
603
|
+
self._ensure_initialized() # _ensure_initialized ensures _client is not None and an index exists
|
|
604
|
+
|
|
605
|
+
if recreate_index:
|
|
606
|
+
# get the current index mappings and settings
|
|
607
|
+
index_name = self._index
|
|
608
|
+
mappings = self._client.indices.get(index=self._index)[index_name]["mappings"] # type: ignore
|
|
609
|
+
settings = self._client.indices.get(index=self._index)[index_name]["settings"] # type: ignore
|
|
610
|
+
|
|
611
|
+
# remove settings that cannot be set during index creation
|
|
612
|
+
settings["index"].pop("uuid", None)
|
|
613
|
+
settings["index"].pop("creation_date", None)
|
|
614
|
+
settings["index"].pop("provided_name", None)
|
|
615
|
+
settings["index"].pop("version", None)
|
|
616
|
+
|
|
617
|
+
self._client.indices.delete(index=self._index) # type: ignore
|
|
618
|
+
self._client.indices.create(index=self._index, settings=settings, mappings=mappings) # type: ignore
|
|
619
|
+
|
|
620
|
+
# delete index
|
|
621
|
+
self._client.indices.delete(index=self._index) # type: ignore
|
|
622
|
+
|
|
623
|
+
# recreate with mappings
|
|
624
|
+
self._client.indices.create(index=self._index, mappings=mappings) # type: ignore
|
|
625
|
+
|
|
626
|
+
else:
|
|
627
|
+
result = self._client.delete_by_query(**self._prepare_delete_all_request(is_async=False)) # type: ignore
|
|
628
|
+
logger.info(
|
|
629
|
+
"Deleted all the {n_docs} documents from the index '{index}'.",
|
|
630
|
+
index=self._index,
|
|
631
|
+
n_docs=result["deleted"],
|
|
632
|
+
)
|
|
633
|
+
|
|
634
|
+
async def delete_all_documents_async(self, recreate_index: bool = False) -> None:
|
|
635
|
+
"""
|
|
636
|
+
Asynchronously deletes all documents in the document store.
|
|
637
|
+
|
|
638
|
+
A fast way to clear all documents from the document store while preserving any index settings and mappings.
|
|
639
|
+
:param recreate_index: If True, the index will be deleted and recreated with the original mappings and
|
|
640
|
+
settings. If False, all documents will be deleted using the `delete_by_query` API.
|
|
641
|
+
"""
|
|
642
|
+
self._ensure_initialized() # ensures _async_client is not None
|
|
643
|
+
|
|
644
|
+
try:
|
|
645
|
+
if recreate_index:
|
|
646
|
+
# get the current index mappings and settings
|
|
647
|
+
index_name = self._index
|
|
648
|
+
index_info = await self._async_client.indices.get(index=self._index) # type: ignore
|
|
649
|
+
mappings = index_info[index_name]["mappings"]
|
|
650
|
+
settings = index_info[index_name]["settings"]
|
|
651
|
+
|
|
652
|
+
# remove settings that cannot be set during index creation
|
|
653
|
+
settings["index"].pop("uuid", None)
|
|
654
|
+
settings["index"].pop("creation_date", None)
|
|
655
|
+
settings["index"].pop("provided_name", None)
|
|
656
|
+
settings["index"].pop("version", None)
|
|
657
|
+
|
|
658
|
+
# delete index
|
|
659
|
+
await self._async_client.indices.delete(index=self._index) # type: ignore
|
|
660
|
+
|
|
661
|
+
# recreate with settings and mappings
|
|
662
|
+
await self._async_client.indices.create(index=self._index, settings=settings, mappings=mappings) # type: ignore
|
|
663
|
+
|
|
664
|
+
else:
|
|
665
|
+
# use delete_by_query for more efficient deletion without index recreation
|
|
666
|
+
# For async, we need to wait for completion to get the deleted count
|
|
667
|
+
delete_request = self._prepare_delete_all_request(is_async=True)
|
|
668
|
+
delete_request["wait_for_completion"] = True # Override to wait for completion in async
|
|
669
|
+
result = await self._async_client.delete_by_query(**delete_request) # type: ignore
|
|
670
|
+
logger.info(
|
|
671
|
+
"Deleted all the {n_docs} documents from the index '{index}'.",
|
|
672
|
+
index=self._index,
|
|
673
|
+
n_docs=result["deleted"],
|
|
674
|
+
)
|
|
675
|
+
|
|
676
|
+
except Exception as e:
|
|
677
|
+
msg = f"Failed to delete all documents from Elasticsearch: {e!s}"
|
|
678
|
+
raise DocumentStoreError(msg) from e
|
|
679
|
+
|
|
578
680
|
def _bm25_retrieval(
|
|
579
681
|
self,
|
|
580
682
|
query: str,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
5
5
|
import random
|
|
6
|
+
import time
|
|
6
7
|
from typing import List
|
|
7
8
|
from unittest.mock import Mock, patch
|
|
8
9
|
|
|
@@ -483,6 +484,59 @@ class TestDocumentStore(DocumentStoreBaseTests):
|
|
|
483
484
|
mappings=custom_mapping,
|
|
484
485
|
)
|
|
485
486
|
|
|
487
|
+
def test_delete_all_documents_index_recreation(self, document_store: ElasticsearchDocumentStore):
|
|
488
|
+
# populate the index with some documents
|
|
489
|
+
docs = [Document(id="1", content="A first document"), Document(id="2", content="Second document")]
|
|
490
|
+
document_store.write_documents(docs)
|
|
491
|
+
|
|
492
|
+
# capture index structure before deletion
|
|
493
|
+
assert document_store._client is not None
|
|
494
|
+
index_info_before = document_store._client.indices.get(index=document_store._index)
|
|
495
|
+
mappings_before = index_info_before[document_store._index]["mappings"]
|
|
496
|
+
settings_before = index_info_before[document_store._index]["settings"]
|
|
497
|
+
|
|
498
|
+
# delete all documents
|
|
499
|
+
document_store.delete_all_documents(recreate_index=True)
|
|
500
|
+
assert document_store.count_documents() == 0
|
|
501
|
+
|
|
502
|
+
# verify index structure is preserved
|
|
503
|
+
index_info_after = document_store._client.indices.get(index=document_store._index)
|
|
504
|
+
mappings_after = index_info_after[document_store._index]["mappings"]
|
|
505
|
+
assert mappings_after == mappings_before, "delete_all_documents should preserve index mappings"
|
|
506
|
+
|
|
507
|
+
settings_after = index_info_after[document_store._index]["settings"]
|
|
508
|
+
settings_after["index"].pop("uuid", None)
|
|
509
|
+
settings_after["index"].pop("creation_date", None)
|
|
510
|
+
settings_before["index"].pop("uuid", None)
|
|
511
|
+
settings_before["index"].pop("creation_date", None)
|
|
512
|
+
assert settings_after == settings_before, "delete_all_documents should preserve index settings"
|
|
513
|
+
|
|
514
|
+
# verify index can accept new documents and retrieve
|
|
515
|
+
new_doc = Document(id="4", content="New document after delete all")
|
|
516
|
+
document_store.write_documents([new_doc])
|
|
517
|
+
assert document_store.count_documents() == 1
|
|
518
|
+
|
|
519
|
+
results = document_store.filter_documents()
|
|
520
|
+
assert len(results) == 1
|
|
521
|
+
assert results[0].content == "New document after delete all"
|
|
522
|
+
|
|
523
|
+
def test_delete_all_documents_no_index_recreation(self, document_store: ElasticsearchDocumentStore):
|
|
524
|
+
docs = [Document(id="1", content="A first document"), Document(id="2", content="Second document")]
|
|
525
|
+
document_store.write_documents(docs)
|
|
526
|
+
assert document_store.count_documents() == 2
|
|
527
|
+
|
|
528
|
+
document_store.delete_all_documents(recreate_index=False)
|
|
529
|
+
time.sleep(2) # need to wait for the deletion to be reflected in count_documents
|
|
530
|
+
assert document_store.count_documents() == 0
|
|
531
|
+
|
|
532
|
+
new_doc = Document(id="3", content="New document after delete all")
|
|
533
|
+
document_store.write_documents([new_doc])
|
|
534
|
+
assert document_store.count_documents() == 1
|
|
535
|
+
|
|
536
|
+
results = document_store.filter_documents()
|
|
537
|
+
assert len(results) == 1
|
|
538
|
+
assert results[0].content == "New document after delete all"
|
|
539
|
+
|
|
486
540
|
|
|
487
541
|
@pytest.mark.integration
|
|
488
542
|
class TestElasticsearchDocumentStoreAsync:
|
|
@@ -631,3 +685,79 @@ class TestElasticsearchDocumentStoreAsync:
|
|
|
631
685
|
assert len(results) == 1
|
|
632
686
|
assert results[0].id == "1"
|
|
633
687
|
assert not hasattr(results[0], "sparse_embedding") or results[0].sparse_embedding is None
|
|
688
|
+
|
|
689
|
+
@pytest.mark.asyncio
|
|
690
|
+
async def test_delete_all_documents_async(self, document_store):
|
|
691
|
+
docs = [
|
|
692
|
+
Document(id="1", content="First document", meta={"category": "test"}),
|
|
693
|
+
Document(id="2", content="Second document", meta={"category": "test"}),
|
|
694
|
+
Document(id="3", content="Third document", meta={"category": "other"}),
|
|
695
|
+
]
|
|
696
|
+
await document_store.write_documents_async(docs)
|
|
697
|
+
assert await document_store.count_documents_async() == 3
|
|
698
|
+
|
|
699
|
+
# delete all documents
|
|
700
|
+
await document_store.delete_all_documents_async(recreate_index=False)
|
|
701
|
+
assert await document_store.count_documents_async() == 0
|
|
702
|
+
|
|
703
|
+
# verify index still exists and can accept new documents and retrieve
|
|
704
|
+
new_doc = Document(id="4", content="New document after delete all")
|
|
705
|
+
await document_store.write_documents_async([new_doc])
|
|
706
|
+
assert await document_store.count_documents_async() == 1
|
|
707
|
+
|
|
708
|
+
results = await document_store.filter_documents_async()
|
|
709
|
+
assert len(results) == 1
|
|
710
|
+
assert results[0].id == "4"
|
|
711
|
+
assert results[0].content == "New document after delete all"
|
|
712
|
+
|
|
713
|
+
@pytest.mark.asyncio
|
|
714
|
+
async def test_delete_all_documents_async_index_recreation(self, document_store):
|
|
715
|
+
# populate the index with some documents
|
|
716
|
+
docs = [Document(id="1", content="A first document"), Document(id="2", content="Second document")]
|
|
717
|
+
await document_store.write_documents_async(docs)
|
|
718
|
+
|
|
719
|
+
# capture index structure before deletion
|
|
720
|
+
assert document_store._async_client is not None
|
|
721
|
+
index_info_before = await document_store._async_client.indices.get(index=document_store._index)
|
|
722
|
+
mappings_before = index_info_before[document_store._index]["mappings"]
|
|
723
|
+
settings_before = index_info_before[document_store._index]["settings"]
|
|
724
|
+
|
|
725
|
+
# delete all documents with index recreation
|
|
726
|
+
await document_store.delete_all_documents_async(recreate_index=True)
|
|
727
|
+
assert await document_store.count_documents_async() == 0
|
|
728
|
+
|
|
729
|
+
# verify index structure is preserved
|
|
730
|
+
index_info_after = await document_store._async_client.indices.get(index=document_store._index)
|
|
731
|
+
mappings_after = index_info_after[document_store._index]["mappings"]
|
|
732
|
+
assert mappings_after == mappings_before, "delete_all_documents_async should preserve index mappings"
|
|
733
|
+
|
|
734
|
+
settings_after = index_info_after[document_store._index]["settings"]
|
|
735
|
+
settings_after["index"].pop("uuid", None)
|
|
736
|
+
settings_after["index"].pop("creation_date", None)
|
|
737
|
+
settings_before["index"].pop("uuid", None)
|
|
738
|
+
settings_before["index"].pop("creation_date", None)
|
|
739
|
+
assert settings_after == settings_before, "delete_all_documents_async should preserve index settings"
|
|
740
|
+
|
|
741
|
+
# verify index can accept new documents and retrieve
|
|
742
|
+
new_doc = Document(id="4", content="New document after delete all")
|
|
743
|
+
await document_store.write_documents_async([new_doc])
|
|
744
|
+
assert await document_store.count_documents_async() == 1
|
|
745
|
+
|
|
746
|
+
results = await document_store.filter_documents_async()
|
|
747
|
+
assert len(results) == 1
|
|
748
|
+
assert results[0].content == "New document after delete all"
|
|
749
|
+
|
|
750
|
+
@pytest.mark.asyncio
|
|
751
|
+
async def test_delete_all_documents_async_no_index_recreation(self, document_store):
|
|
752
|
+
docs = [Document(id="1", content="A first document"), Document(id="2", content="Second document")]
|
|
753
|
+
await document_store.write_documents_async(docs)
|
|
754
|
+
assert await document_store.count_documents_async() == 2
|
|
755
|
+
|
|
756
|
+
await document_store.delete_all_documents_async(recreate_index=False)
|
|
757
|
+
# Need to wait for the deletion to be reflected in count_documents
|
|
758
|
+
time.sleep(2)
|
|
759
|
+
assert await document_store.count_documents_async() == 0
|
|
760
|
+
|
|
761
|
+
new_doc = Document(id="3", content="New document after delete all")
|
|
762
|
+
await document_store.write_documents_async([new_doc])
|
|
763
|
+
assert await document_store.count_documents_async() == 1
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{elasticsearch_haystack-4.0.0 → elasticsearch_haystack-4.1.0}/tests/test_embedding_retriever.py
RENAMED
|
File without changes
|
|
File without changes
|