Distinct attribute

is a field whose value will always be unique in the returned documents.

Distinct attribute can also be updated directly through the global settings route along with the other settings.

NOTE

Updating the settings means overwriting the default settings of MeiliSearch. You can reset to default values using the DELETE routes.

GET

Get the field of an index.

Path Variables

  1. $ curl \
  1. client.index('movies').getDistinctAttribute()
  1. client.index('movies').get_distinct_attribute()
  1. $client->index('movies')->getDistinctAttribute();
  1. index.distinct_attribute
  1. client.Settings("movies").GetDistinctAttribute()
  1. let distinct_attribute: Option<String> = movies.get_distinct_attribute().await.unwrap();

Response: 200 Ok

  1. "movie_id"

POST

Update the distinct attribute field of an index.

Path Variables

Body

.

Example

  1. -X POST 'http://localhost:7700/indexes/movies/settings/distinct-attribute' \
  2. --data '"movie_id"'
  1. client.index('movies').updateDistinctAttribute('movie_id')
  1. client.index('movies').update_distinct_attribute('movie_id')
  1. $client->index('movies')->updateDistinctAttribute('movie_id');
  1. index.update_distinct_attribute('movie_id')
    1. let progress: Progress = movies.set_distinct_attribute("movie_id").await.unwrap();

    Response: 202 Accepted

    1. {
    2. "updateId": 1
    3. }

    This updateId allows you to track the current update.

    DELETE

    Reset the field of an index to its default value.

    Path Variables

    Example

    1. $ curl \
    2. -X DELETE 'http://localhost:7700/indexes/movies/settings/distinct-attribute'
    1. client.index('movies').resetDistinctAttribute()
    1. client.index('movies').reset_distinct_attribute()
    1. $client->index('movies')->resetDistinctAttribute();
    1. index.reset_distinct_attribute
    1. client.Settings("movies").ResetDistinctAttribute()
    1. let progress: Progress = movies.reset_distinct_attribute().await.unwrap();

    Response: 202 Accepted

    1. {
    2. "updateId": 1

    This updateId allows you to .