Skip to content

Commit 12cb544

Browse files
bors[bot]bidoubiwa
andauthored
Merge #682
682: Add compatibility with hierarchicalMenu/breadcrumb/RatingsMenu in readme r=bidoubiwa a=bidoubiwa Per `@gmourier` tests, these widgets are compatible provided that you meet the requirements. For example the document structure and the settings. Co-authored-by: Charlotte Vermandel <[email protected]> Co-authored-by: cvermand <[email protected]>
2 parents 3a95896 + 69a9a9f commit 12cb544

File tree

1 file changed

+68
-21
lines changed

1 file changed

+68
-21
lines changed

README.md

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,11 @@ List of all the components that are available in [instantSearch](https://github.
195195
### Table Of Widgets
196196

197197
-[InstantSearch](#-instantsearch)
198-
-[index](#-index)
198+
- [index](#-index)
199199
-[SearchBox](#-searchbox)
200200
-[Configure](#-configure)
201-
-[ConfigureRelatedItems](#-configure-related-items)
202-
-[Autocomplete](#-autocomplete)
201+
- [ConfigureRelatedItems](#-configure-related-items)
202+
- [Autocomplete](#-autocomplete)
203203
-[Voice Search](#-voice-search)
204204
-[Insight](#-insight)
205205
-[Middleware](#-middleware)
@@ -209,27 +209,27 @@ List of all the components that are available in [instantSearch](https://github.
209209
-[Highlight](#-highlight)
210210
-[Snippet](#-snippet)
211211
-[Geo Search](#-geo-search)
212-
-[Answers](#-answers)
212+
- [Answers](#-answers)
213213
-[RefinementList](#-refinementlist)
214-
- [HierarchicalMenu](#-hierarchicalmenu)
214+
- [HierarchicalMenu](#-hierarchicalmenu)
215215
-[RangeSlider](#-rangeslider)
216216
-[Menu](#-menu)
217217
-[currentRefinements](#-currentrefinements)
218218
-[RangeInput](#-rangeinput)
219219
-[MenuSelect](#-menuselect)
220220
-[ToggleRefinement](#-togglerefinement)
221221
-[NumericMenu](#-numericmenu)
222-
- [RatingMenu](#-ratingmenu)
222+
- [RatingMenu](#-ratingmenu)
223223
-[ClearRefinements](#-clearrefinements)
224224
-[Pagination](#-pagination)
225225
-[HitsPerPage](#-hitsperpage)
226-
- [Breadcrumb](#-breadcrumb)
226+
- [Breadcrumb](#-breadcrumb)
227227
-[Stats](#-stats)
228-
-[Analytics](#-analytics)
229-
-[QueryRuleCustomData](#-queryrulecustomdata)
230-
-[QueryRuleContext](#-queryrulecontext)
228+
- [Analytics](#-analytics)
229+
- [QueryRuleCustomData](#-queryrulecustomdata)
230+
- [QueryRuleContext](#-queryrulecontext)
231231
-[SortBy](#-sortby)
232-
-[RelevantSort](#-relevantsort)
232+
- [RelevantSort](#-relevantsort)
233233
-[Routing](#-routing)
234234

235235

@@ -606,15 +606,52 @@ instantsearch.widgets.refinementList({
606606
})
607607
```
608608

609-
### HierarchicalMenu
609+
### HierarchicalMenu
610610

611611
[Hierarchical menu references](https://www.algolia.com/doc/api-reference/widgets/hierarchical-menu/js/)
612612

613-
The `hierarchicalMenu` widget is used to create a navigation based on a hierarchy of facet attributes. It is commonly used for categories with subcategories.
613+
The `hierarchicalMenu` widget is used to create navigation based on a hierarchy of facet attributes. It is commonly used for categories with subcategories. See [usage](#hierarchical-menu-usage) below.
614614

615-
No compatibility because Meilisearch does not support hierarchical facets.
615+
- ✅ container: The CSS Selector or HTMLElement to insert the refinements. _required_
616+
- ✅ attribute: The name of the attributes to generate the menu with. _required_.
617+
- ✅ limit: How many facet values to retrieve.
618+
- ✅ showMore: Whether to display a button that expands the number of items.
619+
- ✅ showMoreLimit: The maximum number of displayed items (min `2`).
620+
- ❌ separator: The level separator used in the records. (default `>`).
621+
- 🤷‍♀️ rootPath: The prefix path to use if the first level is not the root level.
622+
- ❌ showParentLevel: Whether to show the siblings of the selected parent level of the current refined value.
623+
- ✅ sortBy: How to sort refinements. [See guide](https://www.algolia.com/doc/api-reference/widgets/hierarchical-menu/js/#widget-param-sortby)
624+
- ✅ templates: The templates to use for the widget.- ✅ templates: The templates to use for the widget.
625+
- ✅ cssClasses: The CSS classes to override.
626+
627+
#### Hierarchical Menu Usage
628+
To make it work with Meilisearch your documents must have a specific structure, an explanation of the structure can [be found here](https://www.algolia.com/doc/api-reference/widgets/hierarchical-menu/js/#requirements).
629+
630+
Contrary to `instantsearch.js`, the hierarchical fields are added in [`filterableAttributes`](https://docs.meilisearch.com/reference/api/filterable_attributes.html#update-filterable-attributes).
631+
632+
Example:
633+
Give the following document structure:
634+
```json
635+
{
636+
"id": 1,
637+
"name": "Basic T-shirt",
638+
"categories.lvl0": "Men",
639+
"categories.lvl1": "Men > clothes",
640+
"categories.lvl2": "Men > clothes > t-shirt"
641+
}
642+
```
643+
644+
You have to add the fields `categories.lvl0`, `categories.lvl1` and `categories.lvl2` in the `filterableAttributes` in your Meilisearch settings.
645+
```json
646+
{
647+
"filterableAttributes": [
648+
"categories.lvl0",
649+
"categories.lvl1",
650+
"categories.lvl2"
651+
]
652+
}
653+
```
616654

617-
If you'd like get nested facets/hierarchical facets implemented, please vote for it in the [roadmap](https://roadmap.meilisearch.com/c/97-nested-facets?utm_medium=social&utm_source=portal_share).
618655

619656
### ✅ RangeSlider
620657

@@ -761,13 +798,19 @@ The `numericMenu` widget displays a list of numeric filters in a list. Those num
761798
- ✅ cssClasses: The CSS classes to override.
762799
- ✅ transformItems: function receiving the items, called before displaying them.
763800

764-
### RatingMenu
801+
### RatingMenu
765802

766803
[Rating menu references](https://www.algolia.com/doc/api-reference/widgets/rating-menu/js/)
767804

768805
The `RatingMenu` widget lets the user refine search results by clicking on stars. The stars are based on the selected attribute.
769806

770-
No compatibility because Meilisearch does not support integers as facet and instantSearch uses facets information to showcase the UI elements.
807+
- ✅ container: The CSS Selector or HTMLElement to insert the widget into. _required_
808+
- ✅ attribute: The name of the attribute in the document. _required_.
809+
- ✅ max: The maximum value for the rating. This value is exclusive, which means the number of stars will be the provided value, minus one.
810+
- ✅ templates: The templates to use for the widget.
811+
- ✅ cssClasses: The CSS classes to override.
812+
813+
Contrary to `instantsearch.js`, To be able to use `RatingMenu` the field containing the rating has to be added in the [`filterableAttributes`](https://docs.meilisearch.com/reference/api/filterable_attributes.html#update-filterable-attributes) setting in your index settings.
771814

772815
### ✅ ClearRefinements
773816

@@ -819,15 +862,19 @@ The `hitsPerPage` widget displays a dropdown menu to let the user change the num
819862
- ✅ cssClasses: The CSS classes to override.
820863
- ✅ transformItems: function receiving the items, called before displaying them.
821864

822-
### Breadcrumb
865+
### Breadcrumb
823866

824867
[Breadcrumb references](https://www.algolia.com/doc/api-reference/widgets/breadcrumb/js/)
825868

826-
The `breadcrumb` widget is a secondary navigation scheme that lets the user see where the current page is in relation to the facet’s hierarchy.
869+
The `breadcrumb` widget is a secondary navigation scheme that lets the user see where the current page is in relation to the facet’s hierarchy. The `HierarchicalMenu` widget has the same requirements, see its [usage](#hierarchical-menu-usage) to make breadcrumb work.
827870

828-
No compatibility because Meilisearch does not support hierarchical facets.
871+
- ✅ container: The CSS Selector or HTMLElement to insert the refinements. _required_
872+
- ✅ attribute: The name of the attributes to generate the menu with. _required_.
873+
- ❌ separator: The level separator used in the records. (default `>`).
874+
- 🤷‍♀️ rootPath: The prefix path to use if the first level is not the root level.
875+
- ✅ templates: The templates to use for the widget.- ✅ templates: The templates to use for the widget.
876+
- ✅ cssClasses: The CSS classes to override.
829877

830-
If you'd like get nested facets implemented, please vote for it in the [roadmap](https://roadmap.meilisearch.com/c/97-nested-facets?utm_medium=social&utm_source=portal_share).
831878

832879
### ✅ Stats
833880

0 commit comments

Comments
 (0)