Hierarchical Facet Search #735
Replies: 2 comments
-
Hi @bradenmacdonald , apologies for the delayed response. We've opened an issue to investigate the behavior you mentioned here: meilisearch/meilisearch#4638 |
Beta Was this translation helpful? Give feedback.
-
Thanks @macraig. I commented on that issue too. For reference, here is the code I ended up writing to search hierarchichal facets in a "best effort" fashion, despite the current limitations of the Meilisearch API: https://github.com/openedx/frontend-app-course-authoring/blob/732b7ed86cb3845fbed0471a217c065c14091b3b/src/search-modal/data/api.js#L318-L388 |
Beta Was this translation helpful? Give feedback.
-
Hi!
I'm trying to build a search experience like this using Meilisearch, where there are hierarchical tags used to categorize content. The tags come from external taxonomies and there could be thousands of tags in each taxonomy, so we want a way for users to be able to search in the "tags" filter before checking/unchecking tags to filter by.
I was hoping that the "Searching facet values" feature would support this, but it doesn't seem to work for this use case at all.
For context, we have the hierarchical tags denormalized into several fields as recommended in the guide:
tags.level0
,tags.level1
,tags.level2
,tags.level3
, etc. This works great for basic filtering and since I specifiedtags
as a filterable attribute when creating the index, I can do basic filtering using the tags. It also works with Instansearch's HierarchicalMenu widget, though we had to replace it with a custom implementation because their widget only allows selecting a single tag at a time.However, here are the problems:
client.index(indexName).searchForFacetValues({ facetName: "tags", facetQuery: "..." });
then Meilisearch gives empty results (which I guess is expected, because the API doesn't even have a way to express nested taxonomy values in the result from this API call). And if I callsearchForFacetValues
withfacetName: "tags.level0"
, it gives an error that "Attributetags.taxonomy
is not facet-searchable. To make it facet-searchable add it to thefilterableAttributes
index settings." This seems inconsistent with how filtering works in general, because for all other API methods, I only needed to includetags
in thefilterableAttributes
and it allows me to filter and facet on all the sub-fields of tags. I did try addingtags.level0
etc. tofilterableAttributes
, and it does work, but this is still problematic because I want to search the whole tree of hierarchical facets, and I would have to make at least four separate API calls to search each level and then combine the results.searchForFacetValues
does work, it's far too limited for our use case. As you can see in the screenshot, there are many tags with multiple words in the name, andsearchForFacetValues
only allows searching on the first word - which would be a confusing and broken experience for users.So, I guess this is a feature request for two things:
searchForFacetValues
to search sub-fields liketags.level0
andtags.level1
simultaneously.tags
compound field; for example,.search("Middle Word", { attributesToSearchOn: ["tags.level0", "tags.level1", ...]})
will match text from the middle of the facet names; the only problem with this approach is that it's not possible to combine with an existing overall query keyword, like thesearchForFacetValues
field allows.Relates to:
Beta Was this translation helpful? Give feedback.
All reactions