Searching for Array of Objects #3098
-
I have taken an example from Website Lets says I have two objects in my index {
"id": 0,
"patient_name": "Imogen Temult",
"appointments": [
{
"date": "2022-01-01",
"doctor": "Jester Lavorre",
"ward": "psychiatry"
},
{
"date": "2019-01-01",
"doctor": "Dorian Storm"
}
]
},
{
"id": 1,
"patient_name": "Brian Temult",
"appointments": [
{
"date": "2022-01-01",
"doctor": "Dorian Storm",
"ward": "psychiatry"
},
{
"date": "2019-01-01",
"doctor": "Jester Lavorre"
}
]
}
If I do a search for appointments.doctor="Dorian Storm" and appointments.date="2022-01-01" it returns the first object and second object. I want to return all the documents where they had an appointment with "Dorian Storm" on 2022-01-01 which should only return the second. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Hello @davidvella You could transform your data as follow: {
"id": 0,
"patient_name": "Imogen Temult",
"appointments": [
"0": {
"date": "2022-01-01",
"doctor": "Jester Lavorre",
"ward": "psychiatry"
},
"1": {
"date": "2019-01-01",
"doctor": "Dorian Storm"
}
]
} And then apply this filter |
Beta Was this translation helpful? Give feedback.
-
Thanks @curquiza. I understand both those features but they don't solve what @davidvella and I have asked. The use case for this is incredibly real-world and has come up in every index I have ever created in a professional setting. I wouldn't be here otherwise if it was already possible. I really want it to be so I can ditch all other indexes and just use Meilisearch! Elasticsearch refers to them as Nested Fields; their documentation explains the issue fairly well. You (the developer) must decide before-hand if you want an Object Field or a Nested Field. Azure Cognitive Search treats standard searches similarly to how Meilisearch currently does, where subobjects are flattened and searched together, but then treats filtering unflattened. Each subdocument in an array of objects is its own filterable object independent of the other subdocuments in that field (and you must use their
Do you not see the issue? How with the current Forget everything and just compare the raw logic of these two statements. Its subtle but very different. The first searches appointments where both filters are true per sub-document. The other returns true if that parent object contains at least one appointment with a doctor of Jester Lavorre and one appointment in a psychiatry ward.
The question we are asking is how, with the index structure above, can Meilisearch filter for (1) instead of (2)? Is that possible currently because if so I can't figure it out. If you'd like a more real-world example please let me know! Edit: this seems to be another discussion on the topic: meilisearch/product#675 |
Beta Was this translation helpful? Give feedback.
-
Hey everyone, As mentioned by @madreiling and @curquiza, Meilisearch has yet to support this feature. The product discussion takes place here. If you need that feature, come vote and discuss it! Note: I'm marking that message as an answer and closing this one to direct more people to the feature request. |
Beta Was this translation helpful? Give feedback.
Hey everyone,
As mentioned by @madreiling and @curquiza, Meilisearch has yet to support this feature. The product discussion takes place here.
If you need that feature, come vote and discuss it!
Note: I'm marking that message as an answer and closing this one to direct more people to the feature request.