meilisearch: Wrong nbHits when using distinct attribute
There’s an example in meilisearch documentation https://docs.meilisearch.com/reference/features/distinct.html#example
As shown below, the dataset contains three documents representing different versions of a Lee jeans leather jacket.
[
{
"id": 1,
"description": "Leather jacket",
"brand": "Lee jeans",
"color": "brown",
"product_id": "123456"
},
{
"id": 2,
"description": "Leather jacket",
"brand": "Lee jeans",
"color": "black",
"product_id": "123456"
},
{
"id": 3,
"description": "Leather jacket",
"brand": "Lee jeans",
"color": "blue",
"product_id": "123456"
}
]
After setting the distinct attribute (product_id
), querying for lee leather jacket would only return the first document found.
{
"hits": [
{
"id": 1,
"description": "Leather jacket",
"brand": "Lee jeans",
"color": "brown",
"product_id": "123456"
}
],
"offset": 0,
"limit": 20,
"nbHits": 1,
"exhaustiveNbHits": false,
"processingTimeMs": 0,
"query": "lee leather jacket"
}
Example shows nbHits: 1
is expected. I agree with that nbHits
value. Nevertheless in our project it returns nbHits: 3
, it counts every document from the dataset.
Meilisearch versions: 0.22.0, 0.25.2
P.S. Facet distribution counts every document from the dataset (3 rather than 1), despite there’s a distinct attribute.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (9 by maintainers)
Commits related to this issue
- Merge #489 489: fix distinct count bug r=ManyTheFish a=MarinPostma fix https://github.com/meilisearch/meilisearch/issues/2152 I think the issue was that we didn't take off the excluded candidates f... — committed to meilisearch/milli by bors[bot] 2 years ago
- Merge #489 489: fix distinct count bug r=curquiza a=MarinPostma fix https://github.com/meilisearch/meilisearch/issues/2152 I think the issue was that we didn't take off the excluded candidates from... — committed to meilisearch/milli by bors[bot] 2 years ago
- Merge #489 489: fix distinct count bug r=curquiza a=MarinPostma fix https://github.com/meilisearch/meilisearch/issues/2152 I think the issue was that we didn't take off the excluded candidates from... — committed to meilisearch/milli by bors[bot] 2 years ago
- Merge #489 489: fix distinct count bug r=curquiza a=MarinPostma fix https://github.com/meilisearch/meilisearch/issues/2152 I think the issue was that we didn't take off the excluded candidates from... — committed to meilisearch/milli by bors[bot] 2 years ago
@curquiza I have to create a test case, because I’m not allowed to expose our product details.
I have opened a pr on milli’s side to fix that, it should make it to 0.27.0
Hello @bsurai thanks for your report, we will investigate on it
Thank you so much @bsurai We’ll dig into it asap! Thanks again for making us improve Meilisearch
@curquiza I’ve created a new repository contain dataset, meilisearch settings, test case and screenshots. https://github.com/bsurai/meilisearch-distinct-documents
Issue has been created too https://github.com/meilisearch/meilisearch/issues/2532