Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

InMemoryDocumentStore: count_unique_metadata_by_filter and get_metadata_field_unique_values disagree on int/float/bool values

Open Beginner friendly
#13,040 1 comment 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@julian-risch is already working on this.

Since Oct 2, 2026.

  • #13071 by @CHeeRiNG-CHiCKeN — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
databases

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

P3

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_filter deduplicates with a plain set of _make_metadata_value_hashable(value). Scalars pass through unchanged, and True == 1 == 1.0 with equal hashes in Python, so the set merges them.
  • get_metadata_field_unique_values deduplicates 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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from deepset-ai/haystack

All issues in deepset-ai/haystack

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.