Skip to content

Commit 5e7cd90

Browse files
committed
formmatting
1 parent 511c421 commit 5e7cd90

3 files changed

Lines changed: 28 additions & 16 deletions

File tree

integrations/opensearch/src/haystack_integrations/document_stores/opensearch/document_store.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -343,25 +343,25 @@ def _deserialize_search_hits(hits: list[dict[str, Any]]) -> list[Document]:
343343
out = []
344344
# Fields that are not metadata (should stay at top level)
345345
non_meta_fields = {"id", "content", "embedding", "blob", "sparse_embedding", "score"}
346-
346+
347347
for hit in hits:
348348
data = hit["_source"].copy()
349-
349+
350350
# Reconstruct metadata dict from flattened fields
351351
meta = {}
352352
fields_to_remove = []
353353
for key, value in data.items():
354354
if key not in non_meta_fields:
355355
meta[key] = value
356356
fields_to_remove.append(key)
357-
357+
358358
# Remove metadata fields from top level and add them to meta
359359
for key in fields_to_remove:
360360
data.pop(key, None)
361-
361+
362362
if meta:
363363
data["meta"] = meta
364-
364+
365365
if "highlight" in hit:
366366
if "meta" not in data:
367367
data["meta"] = {}

integrations/opensearch/tests/test_document_store.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ def test_get_field_min_max(self, document_store: OpenSearchDocumentStore):
704704
min_max_single = document_store.get_field_min_max("meta.single_value")
705705
assert min_max_single["min"] == 42
706706
assert min_max_single["max"] == 42
707-
707+
708708
# Test with float values
709709
min_max_score = document_store.get_field_min_max("meta.rating")
710710
assert min_max_score["min"] == pytest.approx(5.2)
@@ -767,6 +767,8 @@ def test_get_field_unique_values(self, document_store: OpenSearchDocumentStore):
767767
assert priority_count == 3
768768

769769
# Test with search term on integer field
770-
unique_priorities_filtered, priority_count = document_store.get_field_unique_values("meta.priority", "Doc 1", 0, 10)
770+
unique_priorities_filtered, priority_count = document_store.get_field_unique_values(
771+
"meta.priority", "Doc 1", 0, 10
772+
)
771773
assert set(unique_priorities_filtered) == {"1"}
772-
assert priority_count == 1
774+
assert priority_count == 1

integrations/opensearch/tests/test_document_store_async.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -523,24 +523,32 @@ async def test_get_field_unique_values(self, document_store: OpenSearchDocumentS
523523
assert lang_count == 3
524524

525525
# Test pagination - first page
526-
unique_values_page1, total_count = await document_store.get_field_unique_values_async("meta.category", None, 0, 2)
526+
unique_values_page1, total_count = await document_store.get_field_unique_values_async(
527+
"meta.category", None, 0, 2
528+
)
527529
assert len(unique_values_page1) == 2
528530
assert total_count == 3
529531
assert all(val in ["A", "B", "C"] for val in unique_values_page1)
530532

531533
# Test pagination - second page
532-
unique_values_page2, total_count = await document_store.get_field_unique_values_async("meta.category", None, 2, 2)
534+
unique_values_page2, total_count = await document_store.get_field_unique_values_async(
535+
"meta.category", None, 2, 2
536+
)
533537
assert len(unique_values_page2) == 1
534538
assert total_count == 3
535539
assert unique_values_page2[0] in ["A", "B", "C"]
536540

537541
# Test with search term - filter by content matching "Python"
538-
unique_values_filtered, total_count = await document_store.get_field_unique_values_async("meta.category", "Python", 0, 10)
542+
unique_values_filtered, total_count = await document_store.get_field_unique_values_async(
543+
"meta.category", "Python", 0, 10
544+
)
539545
assert set(unique_values_filtered) == {"A"} # Only category A has documents with "Python" in content
540546
assert total_count == 1
541547

542548
# Test with search term - filter by content matching "Java"
543-
unique_values_java, total_count = await document_store.get_field_unique_values_async("meta.category", "Java", 0, 10)
549+
unique_values_java, total_count = await document_store.get_field_unique_values_async(
550+
"meta.category", "Java", 0, 10
551+
)
544552
assert set(unique_values_java) == {"B"} # Only category B has documents with "Java" in content
545553
assert total_count == 1
546554

@@ -552,13 +560,15 @@ async def test_get_field_unique_values(self, document_store: OpenSearchDocumentS
552560
Document(content="Doc 4", meta={"priority": 3}),
553561
]
554562
await document_store.write_documents_async(int_docs)
555-
unique_priorities, priority_count = await document_store.get_field_unique_values_async("meta.priority", None, 0, 10)
563+
unique_priorities, priority_count = await document_store.get_field_unique_values_async(
564+
"meta.priority", None, 0, 10
565+
)
556566
assert set(unique_priorities) == {"1", "2", "3"}
557567
assert priority_count == 3
558568

559569
# Test with search term on integer field
560-
unique_priorities_filtered, priority_count = await document_store.get_field_unique_values_async("meta.priority", "Doc 1", 0, 10)
570+
unique_priorities_filtered, priority_count = await document_store.get_field_unique_values_async(
571+
"meta.priority", "Doc 1", 0, 10
572+
)
561573
assert set(unique_priorities_filtered) == {"1"}
562574
assert priority_count == 1
563-
564-

0 commit comments

Comments
 (0)