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: Faceting settings #1761

Merged
merged 14 commits into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
16 changes: 16 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ update_settings_1: |-
"twoTypos": 10
},
"disableOnAttributes": ["title"]
},
"faceting": {
"maxValuesPerFacet": 200
}
}'
reset_settings_1: |-
Expand Down Expand Up @@ -958,3 +961,16 @@ getting_started_typo_tolerance: |-
--data-binary '{
"minWordSizeForTypos": { "oneTypo": 4 }
}'
get_faceting_settings_1: |-
curl \
-X GET 'http://localhost:7700/indexes/books/settings/faceting'
update_faceting_settings_1: |-
curl \
-X POST 'http://localhost:7700/indexes/books/settings/faceting' \
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved
-H 'Content-Type: application/json' \
--data-binary '{
"maxValuesPerFacet": 2
}'
reset_faceting_settings_1: |-
curl \
-X DELETE 'http://localhost:7700/indexes/books/settings/faceting'
1 change: 1 addition & 0 deletions .vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ module.exports = {
},
'/reference/api/displayed_attributes',
'/reference/api/distinct_attribute',
'/reference/api/faceting',
'/reference/api/filterable_attributes',
'/reference/api/ranking_rules',
'/reference/api/searchable_attributes',
Expand Down
3 changes: 3 additions & 0 deletions .vuepress/public/sample-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,6 @@ updating_guide_retrieve_documents_old: |-
updating_guide_update_settings_old: |-
updating_guide_add_documents_old: |-
getting_started_typo_tolerance: |-
get_faceting_settings_1: |-
update_faceting_settings_1: |-
reset_faceting_settings_1: |-
94 changes: 94 additions & 0 deletions reference/api/faceting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Faceting

_Child route of the [settings route](/reference/api/settings.md)._

This route allows you to configure the faceting settings for an index.

Faceting settings can also be updated directly through the [global settings route](/reference/api/settings.md#update-settings) along with the other settings.

To learn more about filtering and faceting, refer to our [dedicated guide](/learn/advanced/filtering_and_faceted_search.md).

::: warning
Updating the settings means overwriting the default settings of Meilisearch. You can reset to default values using the `DELETE` routes.
:::

## Get faceting settings

<RouteHighlighter method="GET" route="/indexes/{index_uid}/settings/faceting"/>

Get the faceting settings of an index. The index [`uid`](/learn/core_concepts/indexes.md#index-uid) is required.

### Example

<CodeSamples id="get_faceting_settings_1" />

#### Response: `200 OK`

```json
{
"maxValuesPerFacet": 100
}
```

### Returned fields

#### `maxValuesPerFacet`

Maximum number of facet values returned for each facet.

## Update faceting settings

<RouteHighlighter method="PATCH" route="/indexes/{index_uid}/settings/faceting"/>

Partially update the faceting settings for an index. The index [`uid`](/learn/core_concepts/indexes.md#index-uid) is required.

### Body

#### `maxValuesPerFacet`

**Type:** integer
**Default value:** `100`
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved

Configure the maximum number of facet values returned for each facet. Values are alphabetically sorted.
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved

For example, suppose a query's search results contain a total of three values for a `colors` facet: `blue`, `green`, and `red`. If you set `maxValuesPerFacet` to `2`, Meilisearch will only return `blue` and `green` in the response body's `facetDistribution` object.

#### Example

<CodeSamples id="update_faceting_settings_1" />

#### Response: `202 Accepted`

```json
{
"uid": 1,
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved
"indexUid": "books",
"status": "enqueued",
"type": "settingsUpdate",
"enqueuedAt": "2022-04-14T20:56:44.991039Z"
}
```

You can use the returned `uid` to get more details on [the status of the task](/reference/api/tasks.md#get-task).
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved

## Reset faceting settings

Reset an index's faceting settings to their default value. The index [`uid`](/learn/core_concepts/indexes.md#index-uid) is required.

#### Example

<CodeSamples id="reset_faceting_settings_1" />

#### Response: `200 OK`

```json
{
"uid": 1,
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved
"indexUid": "books",
"status": "enqueued",
"type": "settingsUpdate",
"enqueuedAt": "2022-04-14T20:53:32.863107Z"
}
```

You can use the returned `uid` to get more details on [the status of the task](/reference/api/tasks.md#get-task).
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved
Loading