You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An index is an entity that gathers a set of documents with its own settings.
4
-
5
-
It can be comparable to a table in `SQL`, or a collection in MongoDB.
3
+
An index is a group of documents with associated settings. It is comparable to a table in `SQL` or a collection in MongoDB.
6
4
7
5
An index is defined by a `uid` and contains the following information:
8
6
9
-
- One primary key
10
-
- Default settings that can be configured as needed: relevancy rules, synonyms, stop words, and field properties.
7
+
- One [primary key](#primary-key)
8
+
- Customizable [settings](#index-settings)
9
+
- An arbitrary number of documents
11
10
12
11
#### Example
13
12
14
-
Suppose you manage [a database that contains information about movies](https://imdb.com/). You would probably want to keep multiple types of documents, such as movies, TV shows, actors, directors, and more. Each of these categories would be represented by an index in Meilisearch.
13
+
Suppose you manage a database that contains information about movies, similar to [IMDb](https://imdb.com/). You would probably want to keep multiple types of documents, such as movies, TV shows, actors, directors, and more. Each of these categories would be represented by an index in Meilisearch.
15
14
16
-
Each index holds information about the fields found in the documents, including how they are handled by Meilisearch and their order of importance. In addition, each has its own set of synonyms, relevancy rules, and stop words. **The settings of one index don't impact other indexes.**
15
+
Using an index's settings, you can customize search behavior for that index. For example, a `movies` index might contain documents with fields like `movie_id`, `title`, `genre`, `overview`, and `release_date`. Using settings, you could make a movie's `title` have a bigger impact on search results than its `overview`, or make the `movie_id` field non-searchable.
17
16
18
-
For example, it means you could create on the same server synonyms for a`movies` index and different synonyms for a`costumes` index.
17
+
One index's settings do not impact other indexes. For example, you could use a different list of synonyms for your`movies` index than for your`costumes` index, even if they're on the same server.
19
18
20
19
## Index creation
21
20
22
-
An index is created the first time documents are added to it or manually using the [create index endpoint](/reference/api/indexes.md#create-an-index).
23
-
24
-
#### Example
25
-
26
-
Let's use the [add or replace documents endpoint](/reference/api/documents.md#add-or-replace-documents) to add documents to a new Meilisearch instance without an index.
27
-
28
-
We will create an index called `movies`. The code below will create the `movies` index and add a sample document to it.
29
-
30
-
<CodeSamplesid="add_or_replace_documents_1" />
21
+
Meilisearch automatically creates an index the first time you add a document. You can also create one manually using the [create index endpoint](/reference/api/indexes.md#create-an-index).
31
22
32
23
## Index UID
33
24
34
-
The `uid` is the **unique** identifier of a given index. It is used on every `indexes/{index_uid}` route as the `{index_uid}` parameter.
35
-
36
-
The `uid` must be an integer or a string containing only alphanumeric characters `a-z A-Z 0-9`, hyphens `-` and underscores `_`.
25
+
The `uid` is the **unique identifier** of an index. It is set when creating the index and must be an integer or string containing only alphanumeric characters `a-z A-Z 0-9`, hyphens `-` and underscores `_`.
37
26
38
-
The `uid` is set at [index creation time](/reference/api/indexes.md#create-an-index). Once a `uid`has been defined for an index, you cannot create another index with the same `uid` and the identifier **cannot be changed anymore**.
27
+
**Once defined, the `uid`cannot be changed**, and you cannot create another index with the same `uid`.
39
28
40
29
```json
41
30
{
@@ -48,55 +37,96 @@ The `uid` is set at [index creation time](/reference/api/indexes.md#create-an-in
48
37
49
38
## Primary key
50
39
51
-
An index is a collection of documents. All documents have a primary key, which is a mandatory field. This field is composed of a primary key attribute name and a unique value. All documents in a given index share the same primary key attribute but a different unique value.
40
+
Every index has a primary key: a required attribute that must be present in all documents in the index. Each document must have a unique value associated with this attribute.
52
41
53
-
The primary key's attribute name **must** be known by the index. You can [set a primary key for an index or let it be inferred by Meilisearch](/learn/core_concepts/primary_key.md#setting-the-primary-key).
42
+
The primary key serves to identify each document, such that two documents in an index can never be completely identical. If you add two documents with the same value for the primary key, they will be treated as the same document: one will overwrite the other. If you try adding documents, and even a single one is missing theprimarykey, none of the documents will be stored.
54
43
55
-
[Learn more about document primary key](/learn/core_concepts/primary_key.md#primary-key-2)
44
+
You can set the primary key for an index or let it be inferred by Meilisearch. Read more about [setting the primary key](/learn/core_concepts/primary_key.md#setting-the-primary-key).
56
45
57
-
## Relevancy rules
46
+
[Learn more about the primary field](/learn/core_concepts/primary_key.md)
58
47
59
-
Each index applies its own relevancy rules. All indexes are created with the same built-in ranking rules executed in a default order. Once your first document has been added, the index will record how the attributes must be sorted. Their order of importance will be deduced from their order of appearance in the document.
48
+
## Index settings
60
49
61
-
For example, suppose your first document lists attributes in the following order:
50
+
Index settings can be thought of as a JSON object containing many different options for customizing search behavior.
62
51
63
-
```
64
-
id, title, overview, release_date
65
-
```
52
+
You can customize the following index settings:
53
+
54
+
-[Ranking rules](#ranking-rules)
55
+
-[Distinct attribute](#distinct-attribute)
56
+
-[Synonyms](#synonyms)
57
+
-[Filterable attributes](#filterable-attributes)
58
+
-[Sortable attributes](#sortable-attributes)
59
+
-[Stop words](#stop-words)
60
+
-[Displayed and searchable attributes](#displayed-and-searchable-attributes)
61
+
-[Typo tolerance](#typo-tolerance)
66
62
67
-
A document containing matches in its `title` field will be considered more relevant than a document only containing matches in its `overview`.
63
+
To change index settings, use the [update settings endpoint](/reference/api/settings.md#update-settings) or any of the [child routes](/reference/api/settings.md#all-settings).
68
64
69
-
You can alter the order in which ranking rules take effect, or define custom ranking rules to return certain results first.
65
+
### Ranking rules
66
+
67
+
Meilisearch uses ranking rules to sort matching documents so that the most relevant documents appear at the top. All indexes are created with the same built-in ranking rules executed in default order. The order of these rules matters: the first rule has the most impact, and the last rule has the least.
68
+
69
+
You can alter this order or define custom ranking rules to return certain results first. This can be done using the [update settings endpoint](/reference/api/settings.md#update-settings) or the [update ranking rules endpoint](/reference/api/ranking_rules.md#update-ranking-rules).
70
70
71
71
[Learn more about ranking rules](/learn/core_concepts/relevancy.md)
72
72
73
-
## Synonyms
73
+
### Distinct attribute
74
+
75
+
If your dataset contains multiple similar documents, you may want to return only one on search. Suppose you have numerous black jackets in different sizes in your `costumes` index; setting `costume_name` as the distinct attribute will mean Meiliserch will not return more than one black jacket with the same `costume_name`.
74
76
75
-
In your dataset, you may decide to create synonyms for words which have the same meaning. To do so, **a set of synonyms can be defined for an index**. Even though they are different, they should be treated similarly. If either of the associated words is searched, the same results shall be displayed.
77
+
Designate the distinct attribute using the [update settings endpoint](/reference/api/settings.md#update-settings) or the [update distinct attribute endpoint](/reference/api/distinct_attribute.md#update-distinct-attribute). **You can only set one field as the distinct attribute per index.**
76
78
77
-
Since synonyms are linked to a given index, they won't apply to any other index on the same Meilisearch instance.
79
+
[Learn more about distinct attribute](/learn/configuration/distinct.md)
80
+
81
+
### Synonyms
82
+
83
+
Your dataset may contain words with similar meanings. For these, you can define a list of synonyms: words that will be treated as the same or similar for search purposes.
84
+
85
+
Since synonyms are defined for a given index, they won't apply to any other index on the same Meilisearch instance. You can create your list of synonyms using the [update settings endpoint](/reference/api/settings.md#update-settings) or the [update synonyms endpoint](/reference/api/synonyms.md#update-synonyms).
78
86
79
87
[Learn more about synonyms](/learn/configuration/synonyms.md)
80
88
81
-
## Stop words
89
+
### Filterable attributes
90
+
91
+
Filtering allows you to refine your search based on different categories. For example, you could search for all movies of a certain `genre`, e.g., `Science Fiction`, with a `rating` above `8`.
92
+
93
+
Before filtering on any document attribute, you must add it to `filterableAttributes` using the [update settings endpoint](/reference/api/settings.md#update-settings) or the [update filterable attributes endpoint](/reference/api/filterable_attributes.md#update-filterable-attributes). Then, make a search query using the [`filter` search parameter](/reference/api/search.md#filter).
94
+
95
+
[Learn more about filtering](/learn/advanced/filtering_and_faceted_search.md)
96
+
97
+
### Sortable attributes
82
98
83
-
Sometimes you may want to ignore certain words in documents and search queries. To do so, **a set of stop words can be defined for an index**. Unless you actually need them, some words neither add semantic value nor context. Besides, they are often too frequent (for example, `the` or `of` in English).
99
+
By default, Meilisearch orders results according to their relevancy. You can alter this sorting behavior to show certain results first.
84
100
85
-
Words added to the [stop words list](/reference/api/stop_words.md) will be ignored during search. In addition to improving relevancy, designating common words as stop words also greatly improves performance.
101
+
Add the attributes you'd like to sort by to `sortableAttributes` using the [update settings endpoint](/reference/api/settings.md#update-settings) or the [update sortable attributes endpoint](/reference/api/sortable_attributes.md#update-sortable-attributes). You can then use the [`sort` search parameter](/reference/api/search.md#sort) to sort your results in ascending or descending order.
86
102
87
-
For example, suppose you want to search for `the great gatsby`. You would prefer to receive documents containing the terms `great gatsby`, rather than documents containing the terms `the great`, or just `the`. In this case, adding `the` to the stop word list would improve performance and make search results more relevant.
103
+
[Learn more about sorting](/learn/advanced/sorting.md)
104
+
105
+
### Stop words
106
+
107
+
Your dataset may contain words you want to ignore during search because, for example, they don't add semantic value or occur too frequently (e.g., `the` or `of` in English). You can add these words to the [stop words list](/reference/api/stop_words.md) and Meilisearch will ignore them during search.
108
+
109
+
Change your index's stop words list using the [update settings endpoint](/reference/api/settings.md#update-settings) or the [update stop words endpoint](/reference/api/stop_words.md#update-stop-words). In addition to improving relevancy, designating common words as stop words greatly improves performance.
88
110
89
111
[Learn more about stop words](/reference/api/stop_words.md)
90
112
91
-
## Field properties
113
+
### Displayed and searchable attributes
114
+
115
+
By default, every document field is searchable and displayed in response to search queries. However, you can choose to set some fields as non-searchable, non-displayed, or both.
116
+
117
+
You can update these field attributes using the [update settings endpoint](/reference/api/settings.md#update-settings), or the respective endpoints for [displayed attributes](/reference/api/displayed_attributes.md#update-displayed-attributes) and [searchable attributes](/reference/api/searchable_attributes.md#update-searchable-attributes).
118
+
119
+
[Learn more about displayed and searchable attributes](/learn/configuration/displayed_searchable_attributes.md)
92
120
93
-
By default, every document field is searchable and returned on search queries.
121
+
### Typo tolerance
94
122
95
-
Fields can have either or both or none of the following properties that can be modified in the [settings](/reference/api/settings.md):
123
+
Typo tolerance is a built-in feature that helps you find relevant results even when your search queries contain spelling mistakes or typos, e.g., typing `chickne` instead of `chicken`. This setting allows you to do the following for your index:
96
124
97
-
-**Searchable**: The content of searchable fields is used by Meilisearch to assess the relevancy of a document.
98
-
-**Displayed**: Documents returned upon search contain only displayed fields.
125
+
- Enable or disable typo tolerance
126
+
- Configure the minimum word size for typos
127
+
- Disable typos on specific words
128
+
- Disable typos on specific document attributes
99
129
100
-
By default, each field is stored and this behavior cannot be changed.
130
+
You can update the typo tolerance settings using the [update settings endpoint](/reference/api/settings.md#update-settings) or the [update typo tolerance endpoint](/reference/api/typo_tolerance.md#update-typo-tolerance).
101
131
102
-
[Learn more about field properties](/learn/configuration/displayed_searchable_attributes.md)
132
+
[Learn more about typo tolerance](/learn/configuration/typo_tolerance.md)
0 commit comments