InMemoryDocumentStore: count_unique_metadata_by_filter and get_metadata_field_unique_values disagree on int/float/bool values
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Locate the InMemoryDocumentStore implementations of count_unique_metadata_by_filter and get_metadata_field_unique_values, then inspect the existing tests covering metadata uniqueness. Reproduce the mixed int, float, and bool cases and add regression coverage. Done means both APIs report the same unique values and count while existing tests continue to pass.
Written by the indexing model from the issue text.
Description
On the same documents, count_unique_metadata_by_filter and get_metadata_field_unique_values disagree on how many unique values a metadata field has when the values mix int, float, and bool.
Reproduction (current main, 2ae9acd):
from haystack import Document
from haystack.document_stores.in_memory import InMemoryDocumentStore
store = InMemoryDocumentStore()
store.write_documents([
Document(content="a", meta={"page": 1}),
Document(content="b", meta={"page": 1.0}),
])
print(store.count_unique_metadata_by_filter(filters={}, metadata_fields=["page"]))
# {'page': 1}
values, total = store.get_metadata_field_unique_values("page", size=100)
print(values, total)
# [1, 1.0] 2
The count says one unique value; the values endpoint returns two for the same field on the same documents. Mixing booleans in makes it worse: True, 1, and 1.0 all collapse into one entry in the count, while the values endpoint lists all three.
Cause:
count_unique_metadata_by_filterdeduplicates with a plain set of_make_metadata_value_hashable(value). Scalars pass through unchanged, andTrue == 1 == 1.0with equal hashes in Python, so the set merges them.get_metadata_field_unique_valuesdeduplicates on(type(value).__name__, _make_metadata_value_hashable(value)), so the same values stay distinct.
Mixed int/float metadata is common when values come from different ingest paths (JSON parsing, pandas), so a UI built on these two endpoints would show a count that does not match the values it lists.
I would expect the two APIs to agree on what a unique value is. Keying the count by type name plus value, same as the values endpoint, keeps the existing tests passing. Happy to open a PR with that change if you confirm the direction.
- Dominant language
- Python
- Stars
- 26.8k
- Forks
- 3.3k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 258
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from deepset-ai/haystack
-
CSVToDocument accepts an unsupported conversion_mode and silently converts in row modePossibly taken @Lesereingrape claimed this 16 days ago. OpenP3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
deepset-ai/haystack#13070 ·
Maintainers usually reply within 1 day
-
PPTXToDocument drops soft line breaks when link_format is markdown or plainPossibly taken @bogdankostic claimed this 6 days ago. OpenP3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
deepset-ai/haystack#13043 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
AutoMergingRetriever raises ValueError when a matched document has no parent (for example the root document)Possibly taken @julian-risch claimed this 18 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
deepset-ai/haystack#13029 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
CSVToDocument row mode fails on CR-separated CSV inputPossibly taken @julian-risch claimed this 17 days ago. OpenP3
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
deepset-ai/haystack#13022 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
CSVToDocument row mode drops a real extra_columns field on ragged rowsMay be free again A pull request for this issue was closed without being merged. Openhandled internally P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
deepset-ai/haystack#12994 · 1 comment ·
Maintainers usually reply within 1 day
All issues in deepset-ai/haystack
Similar issues
-
tunneld on Windows: Wi-Fi devices are not discovered because uvicorn runs on a ProactorEventLoopOpen
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
doronz88/pymobiledevice3#2051 ·
Maintainers usually reply within 1 day
-
Remove DatacircleOpen
Difficulty 1/5 Under an hour Newbie friendliness 90/100
collabnix/awesome-mcp-lists#230 ·
Maintainers usually reply within 9 days
-
Groc schedules with out of range values pass config validation and fail later when the scheduler is builtPossibly taken @auraseb claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
autowarefoundation/autoware_carla_scenario#342 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ianktoo/project-monitor#14 ·