Skip to content

Commit 4e850a9

Browse files
Merge #915
915: Beta: Multi index search and disjunctive facet search r=bidoubiwa a=bidoubiwa see #888 Body of the release: ## ⚠️ Breaking change - Facets behavior changed and uses `disjunctive facet search` see #884 added in #888 ## 🚀 Enchancement - The `Index` widget is now compatible with instant-meilisearch #888 Thanks again to `@bidoubiwa!` 🎉 Co-authored-by: Charlotte Vermandel <[email protected]> Co-authored-by: cvermand <[email protected]>
2 parents c6bbe66 + 63c2f96 commit 4e850a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2638
-766
lines changed

.changeset/fresh-tables-clap.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
"@meilisearch/instant-meilisearch": minor
3+
---
4+
5+
- Change the behavior of the `or` operator parameter on the [`RefinmentList`](https://www.algolia.com/doc/api-reference/widgets/refinement-list/js/) widget.
6+
7+
⚠️ This impacts the facet distribution number
8+
9+
## Drawback
10+
11+
Currently, for each `facet value` selected in a different `facet` a separate request is made to Meilisearch. Plus, an additional one containing all the facets filters. It results in tedious search requests and a high bandwidth cost.
12+
For example, if I select `Adventure` on genres and `Multiplayer` on players, one request is made with both facet filters, one with only `genres=Adventure` and one with only `players=Multiplayer`
13+
14+
In the next release of Meilisearch, a new `multi-search` API route is planned to be released (see [PR](https://github.com/meilisearch/meilisearch/pull/3417)). When it is released, the work-around will be removed and only one HTTP request will be done in all cases!
15+
16+
17+
## Explanation
18+
19+
The way the `facetDistribution` is calculated changed. The `facetDistribution` shows the numbers of hits for each facet. For example:
20+
21+
Given the following facet:
22+
23+
```
24+
Genres
25+
- [ ] Adventure 7
26+
```
27+
28+
The `facetDistribution` provides the information that there are `7` hits containing the adventure genre.
29+
30+
For the example, let's take the following facets:
31+
32+
```
33+
Genres
34+
- [ ] Adventure 7
35+
- [ ] Action 5
36+
- [ ] Science Fiction 5
37+
Players
38+
- [ ] Multiplayer 11
39+
- [ ] Single player 7
40+
```
41+
42+
Before, when selecting a facet value in a certain facet, the distribution of that facet was impacted.
43+
44+
```
45+
- [x] Adventure 7
46+
- [ ] Action 3 // <- number changed from 5 to 3
47+
- [ ] Science Fiction 1 // <- number changed from 5 to 1
48+
Players
49+
- [ ] Multiplayer 6
50+
- [ ] Single player 3
51+
```
52+
53+
With the new behavior, the distributed number are not changed when facet values are selected inside the same facet because a facet distribution is computed with a dedicated search request.
54+
55+
```
56+
Genres
57+
- [x] Adventure 7
58+
- [ ] Action 5 // <- number did not change
59+
- [ ] Science Fiction 5 // <- number did not change
60+
Players
61+
- [ ] Multiplayer 6
62+
- [ ] Single player 3
63+
```
64+
65+
```
66+
Genres
67+
- [x] Adventure 7 // changed because of Multiplayer
68+
- [ ] Action 4
69+
- [ ] Science Fiction 3
70+
Players
71+
- [x] Multiplayer 6
72+
- [ ] Single player 3
73+
```
74+
75+
This is the conventional way of calculating the facet distribution. Similar to Algolia's behavior. If you prefer the old behavior, please consider opening an issue.
76+
77+
See [complete explanation here](https://github.com/meilisearch/instant-meilisearch/issues/884)

.changeset/pre.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

.changeset/rich-wasps-tell.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@meilisearch/instant-meilisearch": minor
3+
---
4+
5+
- Compatibility with the `Index` widget is added.
6+
7+
## Drawback
8+
9+
Currently, for each index a request is made on, a separated request is made to Meilisearch. For example, if you have two indexes on which to search, two http requests are made.
10+
11+
In the next release of Meilisearch, a new `multi-search` API route is planned to be released (see [PR](https://github.com/meilisearch/meilisearch/pull/3417)). When it is released, the work-around will be removed and only one HTTP request will be done in all cases!

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ List of all the components that are available in [instantSearch](https://github.
275275
### Table Of Widgets
276276

277277
-[InstantSearch](#-instantsearch)
278-
- [index](#-index)
278+
- [index](#-index)
279279
-[SearchBox](#-searchbox)
280280
-[Configure](#-configure)
281281
-[ConfigureRelatedItems](#-configure-related-items)
@@ -344,15 +344,13 @@ const search = instantsearch({
344344
})
345345
```
346346

347-
### Index
347+
### Index
348348

349349
[Index references](https://www.algolia.com/doc/api-reference/widgets/index-widget/js/)
350350

351351
`Index` is the component that lets you apply widgets to a dedicated index. It’s useful if you want to build an interface that targets multiple indices.
352352

353-
Not compatible as Meilisearch does not support federated search on multiple indexes.
354-
355-
If you'd like to see federated search implemented please vote for it in the [roadmap](https://roadmap.meilisearch.com/c/74-multi-index-search?utm_medium=social&utm_source=portal_share).
353+
Using this component, instant-meilisearch does an http-request for each different `Index` widget added. More http requests are made when using the [`RefinementList`](#✅-refinementlist) widget.
356354

357355
### ✅ SearchBox
358356

@@ -677,6 +675,9 @@ The `refinementList` widget is one of the most common widgets you can find in a
677675
- ✅ templates: The templates to use for the widget.
678676
- ✅ cssClasses: The CSS classes to override.
679677

678+
The `RefinementList` widget uses the `disjunctive facet search` principle when using the `or` operator. For each different facet category used, an additional http call is made.
679+
For example, if I ask for `color=green` and `size=2`, three http requests are made. One for the hits, one for the `color` facet distribution, and one for the `size` facet distribution. To provide feedback on the subject, refer to [this discussion](https://github.com/meilisearch/product/issues/54).
680+
680681
The following example will create a UI component with the a list of genres on which you will be able to facet.
681682

682683
```js

0 commit comments

Comments
 (0)