showMatchesPosition and arrays of objects #550
Replies: 7 comments 8 replies
-
Hi @damienalexandre 👋
Please correct, If I'm wrong. Do you want to display the {
"id": 666,
"name": "Product name",
"variations": {
"1": {
"color": "red",
"description": "Foobar",
"price": 5000,
"preview": "preview-red.jpg"
},
"2": {
"color": "pink",
"description": "Covfefe",
"price": 4000,
"preview": "preview-pink.jpg"
}
}
} I agree; it feels bad. Did you tried it? Thanks! |
Beta Was this translation helpful? Give feedback.
-
Yes it is possible. Another need I have where this is more relevant is video searching. I'm indexing the subtitles of the video and I want to display the parts of text (with the timecode to be able to jump right to it) that matches. So for each video, you get multiple matches.
Yes absolutely and it works 👍 I get the full path of the matching variations in I'm not sure about the related cost / impact on MeiliSearch though; in Elasticsearch, sending such a JSON is a big NOGO as it create A LOT of "fields". What if I have 3000 variations on a product? Is it going to explode? |
Beta Was this translation helpful? Give feedback.
-
I'm sad to report that using string keys (my workaround from the original question) are destroying the performances of MeiliSearch. I indexed 200 videos with subtitles, it may have created an very large number of fields (+1000).
I came across this page too: https://docs.meilisearch.com/learn/advanced/known_limitations.html#maximum-number-of-document-fields I will not be able to use |
Beta Was this translation helpful? Give feedback.
-
Hey, I wanted to know if there is any update or follow up to the consideration? Thank you! |
Beta Was this translation helpful? Give feedback.
-
Hello everyone! 👋 We're currently quite busy with features that have higher priority, however, we do see a need for this feature to be considered in the future. We've created a Portal in our Productboard to gauge user interest better; feel free to upvote there or share any use cases you have in this discussion. As always, thank you for your feedback! |
Beta Was this translation helpful? Give feedback.
-
Adding feedback from #655 by @labadcloyd I have a document in an index like so: {
"id": "9ef0e1cb-0c15-4cf0-a655-6e83af162bcb",
"ingredient_mapping": [
{
"ingredient_name": "Croissants",
"ingredient_variant_Name": "cheese",
},
{
"ingredient_name": "Croissants",
"ingredient_variant_Name": "butter",
},
{
"ingredient_name": "Croissants",
"ingredient_variant_Name": "apple",
}
],
"name": "Croissants",
"name_owner": "USDA"
} If im going to search for the term "Croissants butter" it would most likely return this entire object. But if there was a way to know at which index of the array "ingredient_mapping" the match was then it would really help a lot. This is similar to showMatchesPosition but the index of the object in the array would be returned, not the index of the string. EDIT: I've queried the above document with showMatcherPosition and this is what it returns: {
"hits": [
{
"_matchesPosition": {
"ingredient_details.ingredient_variant_name": [
{
"length": 6,
"start": 0
}
],
"name": [
{
"length": 10,
"start": 0
}
]
},
"id": 129,
"ingredient_details": [
{
"ingredient_mapping_id": 1950,
"ingredient_subvariant_name": "",
"ingredient_variant_name": "cheese"
},
{
"ingredient_mapping_id": 1951,
"ingredient_subvariant_name": "",
"ingredient_variant_name": "butter"
},
{
"ingredient_mapping_id": 1952,
"ingredient_subvariant_name": "",
"ingredient_variant_name": "apple"
}
],
"name": "Croissants",
"name_owner": "USDA"
}
],
"estimatedTotalHits": 1,
"limit": 20,
"processingTimeMs": 1,
"query": "croissant butter"
} Is there a way we can add the index to the array in the "_matchesPosition" field data? |
Beta Was this translation helpful? Give feedback.
-
When working on a PR for this, I encountered some implementation questions that I would like to check with the devs first. Hence this comment. Another motivational exampleI manage lecture recordings where each video has a metadata field What I propose to changeInclude the array index in the keys of {
"id":"123",
"names": ["foo", "bar", "catnip"]
} Searching for "_matchesPosition": {
"names[2]": [ // <- new
{
"length": 3,
"start": 0
}
]
} This is technically a breaking change, however I would argue that it's reasonable to include this change in a new anyway: currently, the Implementation questions(CC @irevoire since you coded permissive-json-pointer and are likely relevant here) The relevant code is here: https://github.com/meilisearch/meilisearch/blob/30f3c303897e478352e69bc1f647dda383081160/meilisearch/src/search/mod.rs#L1731-L1770
One option is to change it in the As an aside: I noticed that the When copying |
Beta Was this translation helpful? Give feedback.
-
I'm trying out MeiliSearch and I stuck with a functionality.
Imagine a simple product in a store, it has multiple variants:
When I search product, for example "pink", I want this product to be displayed.
But I also want to display the appropriate and most relevant variant price, color and preview.
I was hoping the
showMatchesPosition
option would tell me which child is matched but it's not:At the same time, the
_matchesPosition
response is not usable. In the presence of an array of objets, we don't know the position of the object in the array so having string offsets of matches inside one of the object cannot be used (maybe this should be a bug report).Back in Elasticsearch I was using the inner hits option to get my variants but that's also because there is no
showMatchesPosition
option available.A proposal for MeiliSearch could be to add the object position in the path? Like:
As a workaround maybe I should transform my array of objects in a big object?
But that sound bad for some reasons.
WDYT?
Beta Was this translation helpful? Give feedback.
All reactions