meilisearch: Query with filter on nested object field returns empty hits
Meilisearch version 0.10.1
Any document in my products index look like:
{
"id": ...,
"productName": ...,
"sellers": [
{
"sellerName": "Seller 1",
...
},
{
"sellerName": "Seller 2",
...
}
]
}
I need to filter products by seller, so my request looks like:
curl --get 'http://localhost:7700/indexes/products/search' \
--data-urlencode 'q=laptop' \
--data-urlencode 'filters=sellers.sellerName= "Seller 1"'
Even if I have many “laptop” products for “Seller 1”, the query response is empty.
{"hits":[],"offset":0,"limit":20,"nbHits":1348,"exhaustiveNbHits":false,"processingTimeMs":10,"query":"laptop"}
In Meilisearch version 0.10.0 I receive an error for the same query:
{"message":"filter parsing error: parsing error on line 1 at column 1: expected other"}
Is this a bug or the feature for filtering nested fields is not supported? Will it be supported soon?
I would also appreciate some advice on how to solve my problem.
Thanks!
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 15 (9 by maintainers)
Ok thank you @irevoire for the precision 👌 For people reading this, nested fields might be available in v0.27.0 (will be released in May) @irevoire is working on it currently 😃
I don’t know what is the metric for “enough traction”. I am currently evaluating Meilisearch as an alternative for Elasticsearch (as other would be). And this is clearly one the biggest drawback against Elasticsearch.
I am not sure how we can proceed without the Facet filtering through flattening (the proposed approach). I don’t see it as enough solution that works for most use cases.
Hey @Stevemoretz, yes, the nested fields have been merged for v0.27.0 as expected and have been available since in all upcoming versions! 😁
Now you can write
attributes.value_id = 2
in your filter, and it’ll work out of the box ifattributes
orattributes.value_id
are filterable. (And you don’t need to specify anything for meilisearch to understand what is nested) If you encounter any problem why trying to use them, please fill in a new issue 👍Oh, actually we already chatted on the meilisearch community slack channel; the problem is that we don’t handle the nested fields. I don’t think we need to open a new issue for that.
Hey, We’ve decided not to implement this feature, it adds complexity that we don’t want for the time being. It seems that most for most usecases, flattening would achieve the required result. We may reconsider if we get enough traction, so feel free to comment. Cheers!
FYI, facet filtering (#631) has just been merged into master