Commit c93287c
feat: add sparse vector storage to ElasticsearchDocumentStore (#2989)
* feat: add sparse vector storage to ElasticsearchDocumentStore (#2939)
* test: update retriever tests for new ElasticsearchDocumentStore serialization
- Update est_bm25_retriever.py and est_embedding_retriever.py to include sparse_vector_field in serialized document_store init parameters.
* test: add sync and async tests for sparse vector storage
- Add est_write_documents_with_sparse_vectors and est_write_documents_with_sparse_embedding_warning to est_document_store.py
- Add est_write_documents_async_with_sparse_vectors to est_document_store_async.py
- Update existing warning test in est_document_store_async.py
- Add est_init_with_sparse_vector_field and update serialization tests.
* style: fix B905 (strict zip) and E501 (line length) linting errors
* style: fix mypy type inference for _default_mappings
* refactor: address PR review feedback for sparse vector storage
- Add SPECIAL_FIELDS validation for sparse_vector_field in __init__
- Add sparse_vector_field to __init__ docstring
- Inject sparse_vector mapping into custom_mapping when both provided
- Extract _handle_sparse_embedding helper to deduplicate write methods
- Convert _deserialize_document to reconstruct SparseEmbedding on read
* test: address PR review feedback for sparse vector tests
- Add SPECIAL_FIELDS validation test
- Add custom_mapping injection test
- Add legacy from_dict backward compat test
- Fix async test to use async_client for index deletion
- Add retrieval reconstruction assertions to sync and async sparse tests
* fixing docstrings
* just as a safeguard original custom_mapping dict is left unchanged
* organising imports
* formatting
* adding more tests + fixing typing issues
* formatting
* updating unit tests
* adding unit tests for _handle_sparse_embedding function
---------
Co-authored-by: David S. Batista <dsbatista@gmail.com>1 parent 0172236 commit c93287c
File tree
6 files changed
+309
-31
lines changed- integrations/elasticsearch
- src/haystack_integrations/document_stores/elasticsearch
- tests
6 files changed
+309
-31
lines changedLines changed: 55 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | | - | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| |||
86 | 85 | | |
87 | 86 | | |
88 | 87 | | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
120 | 123 | | |
121 | 124 | | |
122 | 125 | | |
| |||
126 | 129 | | |
127 | 130 | | |
128 | 131 | | |
| 132 | + | |
129 | 133 | | |
130 | 134 | | |
131 | 135 | | |
132 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
133 | 141 | | |
134 | 142 | | |
135 | 143 | | |
136 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
137 | 150 | | |
138 | | - | |
| 151 | + | |
139 | 152 | | |
140 | 153 | | |
141 | 154 | | |
| |||
156 | 169 | | |
157 | 170 | | |
158 | 171 | | |
| 172 | + | |
| 173 | + | |
159 | 174 | | |
160 | 175 | | |
161 | 176 | | |
| |||
277 | 292 | | |
278 | 293 | | |
279 | 294 | | |
| 295 | + | |
280 | 296 | | |
281 | 297 | | |
282 | 298 | | |
| |||
404 | 420 | | |
405 | 421 | | |
406 | 422 | | |
407 | | - | |
408 | | - | |
| 423 | + | |
409 | 424 | | |
410 | 425 | | |
411 | 426 | | |
412 | | - | |
| 427 | + | |
413 | 428 | | |
414 | 429 | | |
415 | 430 | | |
| |||
420 | 435 | | |
421 | 436 | | |
422 | 437 | | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
423 | 446 | | |
424 | 447 | | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
425 | 472 | | |
426 | 473 | | |
427 | 474 | | |
| |||
457 | 504 | | |
458 | 505 | | |
459 | 506 | | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
| 507 | + | |
470 | 508 | | |
471 | 509 | | |
472 | 510 | | |
| |||
544 | 582 | | |
545 | 583 | | |
546 | 584 | | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
| 585 | + | |
557 | 586 | | |
558 | 587 | | |
559 | 588 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
77 | | - | |
| 78 | + | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
| |||
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
102 | | - | |
| 103 | + | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
| |||
0 commit comments