diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index f52df5f960..754ab197a3 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -312,32 +312,28 @@ get_version_1: |- -X GET 'http://localhost:7700/version' distinct_attribute_guide_1: |- curl \ - -X PATCH 'http://localhost:7700/indexes/jackets/settings' \ + -X PUT 'http://localhost:7700/indexes/jackets/settings/distinct-attribute' \ -H 'Content-Type: application/json' \ - --data-binary '{ "distinctAttribute": "product_id" }' + --data-binary '"product_id"' field_properties_guide_searchable_1: |- curl \ - -X PATCH 'http://localhost:7700/indexes/movies/settings' \ + -X PUT 'http://localhost:7700/indexes/movies/settings/searchable-attributes' \ -H 'Content-Type: application/json' \ - --data-binary '{ - "searchableAttributes": [ + --data-binary '[ "title", "overview", "genres" - ] - }' + ]' field_properties_guide_displayed_1: |- curl \ - -X PATCH 'http://localhost:7700/indexes/movies/settings' \ + -X PUT 'http://localhost:7700/indexes/movies/settings/displayed-attributes' \ -H 'Content-Type: application/json' \ - --data-binary '{ - "displayedAttributes": [ + --data-binary '[ "title", "overview", "genres", "release_date" - ] - }' + ]' filtering_guide_1: |- curl \ -X POST 'http://localhost:7700/indexes/movies/search' \ diff --git a/learn/configuration/displayed_searchable_attributes.md b/learn/configuration/displayed_searchable_attributes.md index fb165a5708..fc32dfdea4 100644 --- a/learn/configuration/displayed_searchable_attributes.md +++ b/learn/configuration/displayed_searchable_attributes.md @@ -2,10 +2,24 @@ By default, whenever a document is added to Meilisearch, all new attributes found in it are automatically added to two lists: -- [`searchableAttributes`](/learn/configuration/displayed_searchable_attributes.md#the-searchableattributes-list): Attributes whose values are searched for matching query words - [`displayedAttributes`](/learn/configuration/displayed_searchable_attributes.md#displayed-fields): Attributes whose fields are displayed in documents +- [`searchableAttributes`](/learn/configuration/displayed_searchable_attributes.md#the-searchableattributes-list): Attributes whose values are searched for matching query words + +By default, every field in a document is **displayed** and **searchable**. These properties can be modified in the [settings](/reference/api/settings.md). + +## Displayed fields + +The fields whose attributes are added to the [`displayedAttributes` list](/reference/api/settings.md#displayed-attributes) are **displayed in each matching document**. + +Documents returned upon search contain only displayed fields. If a field attribute is not in the displayed-attribute list, the field won't be added to the returned documents. -This means that by default, every field in a document is **searchable** and **displayed**. These properties can be modified in the [settings](/reference/api/settings.md). +**By default, all field attributes are set as displayed**. + +#### Example + +Suppose you manage a database that contains information about movies. By adding the following settings, documents returned upon search will contain the fields `title`, `overview`, `release_date` and `genres`. + + ## Searchable fields @@ -54,24 +68,6 @@ Suppose that you manage a database of movies with the following fields: `id`, `o -## Displayed fields - -The fields whose attributes are added to the [`displayedAttributes` list](/reference/api/settings.md#displayed-attributes) are **displayed in each matching document**. - -Documents returned upon search contain only displayed fields. - -**By default, all field attributes are set as displayed**. - -Therefore, if a field attribute is not in the displayed-attribute list, the field won't be added to the returned documents. - -This list can be restricted to a selected set of attributes in the settings. - -#### Example - -Suppose you manage a database that contains information about movies. By adding the following settings, documents returned upon search will contain the fields `title`, `overview`, `release_date` and `genres`. - - - ## Data storing All fields are stored in the database. **This behavior cannot be changed**.