deepset-ai / deepset-ai/haystack
Update Document.__eq__ to intelligently compare floats
Open
@sjrl is already working on this.
Since Jun 30, 2026.
P3
- Dominant language
- Python
- Stars
- 26.6k
- Forks
- 3.2k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 194
Description
Unsure if this would classify as a bug or a feature, but the Document equality method does a direct dict comparison between two documents.
I think this is potentially sub-optimal in regards to when the score value is set in the Document. It's possible that all other aspects of two Documents match except the score value could differ only slightly due to float imprecision. For example,
from haystack import Document
doc1 = Document(content="doc1", id="1", score=0.123456782)
doc2 = Document(content="doc1", id="1", score=0.12345678)
doc1 == doc2
# False
To me this feels misleading since I'd normally say these two Documents should be considered the same.
Contributor 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.
Assessment
This issue has not been assessed yet.