Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.28: /search name changes #1734

Merged
merged 4 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -432,13 +432,13 @@ search_parameter_guide_highlight_tag_1: |-
"highlightPreTag": "<span class=\"highlight\">",
"highlightPostTag": "</span>"
}'
search_parameter_guide_matches_1: |-
search_parameter_guide_show_matches_position_1: |-
curl \
-X POST 'http://localhost:7700/indexes/movies/search' \
-H 'Content-Type: application/json' \
--data-binary '{
"q": "winter feast",
"matches": true
"showMatchesPosition": true
}'
settings_guide_synonyms_1: |-
curl \
Expand Down Expand Up @@ -648,13 +648,13 @@ faceted_search_filter_1: |-
"director = \"Jordan Peele\""
]
}'
faceted_search_facets_distribution_1: |-
faceted_search_facets_1: |-
curl \
-X POST 'http://localhost:7700/indexes/movies/search' \
-H 'Content-Type: application/json' \
--data-binary '{
"q": "Batman",
"facetsDistribution": ["genres"]
"facets": ["genres"]
}'
faceted_search_walkthrough_filter_1: |-
curl \
Expand Down
4 changes: 2 additions & 2 deletions .vuepress/public/sample-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ search_parameter_guide_limit_1: |-
search_parameter_guide_retrieve_1: |-
search_parameter_guide_crop_1: |-
search_parameter_guide_highlight_1: |-
search_parameter_guide_matches_1: |-
search_parameter_guide_show_matches_position_1: |-
settings_guide_synonyms_1: |-
settings_guide_stop_words_1: |-
settings_guide_ranking_rules_1: |-
Expand All @@ -90,7 +90,7 @@ getting_started_sorting: |-
getting_started_filtering: |-
faceted_search_update_settings_1: |-
faceted_search_filter_1: |-
faceted_search_facets_distribution_1: |-
faceted_search_facets_1: |-
faceted_search_walkthrough_filter_1: |-
add_movies_json_1: |-
post_dump_1: |-
Expand Down
29 changes: 11 additions & 18 deletions learn/advanced/filtering_and_faceted_search.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,30 +278,29 @@ You can then use this filter to search for `thriller`:

### Facets distribution

When creating a faceted search interface it is often useful to have a count of how many results belong to each facet. This can be done by using the [`facetsDistribution` search parameter](/reference/api/search.md#facets-distribution) in combination with `filter` when searching.
When creating a faceted search interface it is often useful to have a count of how many results belong to each facet. This can be done by using the [`facets` search parameter](/reference/api/search.md#facets) in combination with `filter` when searching.

::: note
Meilisearch does not differentiate between facets and filters. This means that, despite its name, `facetsDistribution` can be used with any attributes added to `filterableAttributes`.
Meilisearch does not differentiate between facets and filters. This means that, despite its name, `facets` can be used with any attributes added to `filterableAttributes`.
:::

Using `facetsDistribution` will add an extra field to the returned search results containing the number of matching documents distributed among all the values of a given facet.
Using `facets` will add an extra field to the returned search results containing the number of matching documents distributed among all the values of a given facet.

In the example below, [IMDb](https://www.imdb.com) displays the facet count in parentheses next to each faceted category. This UI gives users a visual clue of the range of results available for each facet.

![IMDb facets](/faceted-search/facets-imdb.png)

#### Using facet distribution
#### Using `facets`

[`facetsDistribution` is a search parameter](/reference/api/search.md#facets-distribution) and as such must be added to a search request. It expects an array of strings. Each string is an attribute present in the `filterableAttributes` list.
[`facets` is a search parameter](/reference/api/search.md#facets) and as such must be added to a search request. It expects an array of strings. Each string is an attribute present in the `filterableAttributes` list.

Using the `facetsDistribution` search parameter adds two new keys to the returned object: `facetsDistribution` and `exhaustiveFacetsCount`.
Using the `facets` search parameter adds `facetDistribution` to the returned object.

`facetsDistribution` contains an object for every given facet. For each of these facets, there is another object containing all the different values and the count of matching documents. Note that zero values will not be returned: if there are no `romance` movies matching the query, `romance` is not displayed.
`facetDistribution` contains an object for every given facet. For each of these facets, there is another object containing all the different values and the count of matching documents. Note that zero values will not be returned: if there are no `romance` movies matching the query, `romance` is not displayed.

```json
{
"exhaustiveFacetsCount": false,
"facetsDistribution" : {
"facetDistribution" : {
"genres" : {
"horror": 50,
"comedy": 34
Expand All @@ -310,27 +309,21 @@ Using the `facetsDistribution` search parameter adds two new keys to the returne
}
```

`exhaustiveFacetsCount` is a boolean value that informs the user whether the facet count is exact or just an approximation. For performance reasons, Meilisearch chooses to use approximate facet count values when there are too many documents across several different fields.

::: warning
`exhaustiveFacetsCount` is not currently implemented in and will always return `false`.
:::

##### Example

You can write a search query that gives you the distribution of `batman` movies per genre:

<CodeSamples id="faceted_search_facets_distribution_1"/>
<CodeSamples id="faceted_search_facets_1"/>

This query would return not only the matching movies, but also the `facetsDistribution` key containing all relevant data:
This query would return not only the matching movies, but also the `facetDistribution` key containing all relevant data:

```json
{
"hits": [
],
"facetsDistribution": {
"facetDistribution": {
"genres": {
"action": 273,
"animation": 118,
Expand Down
3 changes: 1 addition & 2 deletions learn/configuration/distinct.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ After setting the distinct attribute as shown above, querying for `lee leather j
],
"offset": 0,
"limit": 20,
"nbHits": 1,
"exhaustiveNbHits": false,
"estimatedTotalHits": 1,
"processingTimeMs": 0,
"query": "lee leather jacket"
}
Expand Down
2 changes: 1 addition & 1 deletion learn/getting_started/algolia_migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ The below table compares Algolia's **API parameters** with the equivalent Meilis
| `query` | `q` |
| `attributesToRetrieve` | `attributesToRetrieve` |
| `filters` | `filter` |
| `facets` | `facetsDistribution` |
| `facets` | `facetDistribution` |
| `attributesToHighlight` | `attributesToHighlight` |
| `offset` | `offset` |
| `length` | `limit` |
Expand Down
12 changes: 4 additions & 8 deletions learn/getting_started/filtering_and_sorting.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ Let's say you only want to view meteorites that weigh less than 200g:
},
],
"nbHits": 114,
"exhaustiveNbHits": false,
"estimatedTotalHits": 114,
"query": "",
"limit": 20,
"offset": 0,
Expand Down Expand Up @@ -77,8 +76,7 @@ Let's sort the meteorites in the previous example based on mass:
},
],
"nbHits": 114,
"exhaustiveNbHits": false,
"estimatedTotalHits": 114,
"query": "",
"limit": 20,
"offset": 0,
Expand Down Expand Up @@ -132,8 +130,7 @@ Let's say you want to find out which meteorites crashed within a 210km radius of
},
],
"nbHits": 7,
"exhaustiveNbHits": false,
"estimatedTotalHits": 7,
"query": "",
"limit": 20,
"offset": 0,
Expand Down Expand Up @@ -180,8 +177,7 @@ The following command sorts meteorites by how close they were to the Taj Mahal:
},
]
"nbHits": 1000,
"exhaustiveNbHits": false,
"estimatedTotalHits": 1000,
"query": "",
"limit": 20,
"offset": 0,
Expand Down
3 changes: 1 addition & 2 deletions learn/getting_started/quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,7 @@ In the above code sample, the parameter `q` represents the search query. The doc
},
],
"nbHits": 66,
"exhaustiveNbHits": false,
"estimatedTotalHits": 66,
"query": "botman",
"limit": 20,
"offset": 0,
Expand Down
Loading