Skip to content

Commit 1d0851a

Browse files
add index renaming documentation
1 parent 41975b1 commit 1d0851a

File tree

2 files changed

+28
-29
lines changed

2 files changed

+28
-29
lines changed

learn/getting_started/indexes.mdx

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ While implicit index creation is more convenient, requiring only a single API re
3737

3838
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 `_`.
3939

40-
**Once defined, the `uid` cannot be changed**, and you cannot create another index with the same `uid`.
41-
4240
```json
4341
{
4442
"uid": "movies",
@@ -47,6 +45,8 @@ The `uid` is the **unique identifier** of an index. It is set when creating the
4745
}
4846
```
4947

48+
You can change an index's `uid` using the [`/indexes` API route](/reference/api/indexes#update-an-index).
49+
5050
## Primary key
5151

5252
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.
@@ -63,16 +63,23 @@ Index settings can be thought of as a JSON object containing many different opti
6363

6464
You can customize the following index settings:
6565

66-
- [Displayed and searchable attributes](#displayed-and-searchable-attributes)
67-
- [Distinct attribute](#distinct-attribute)
68-
- [Faceting](#faceting)
69-
- [Filterable attributes](#filterable-attributes)
70-
- [Pagination](#pagination)
71-
- [Ranking rules](#ranking-rules)
72-
- [Sortable attributes](#sortable-attributes)
73-
- [Stop words](#stop-words)
74-
- [Synonyms](#synonyms)
75-
- [Typo tolerance](#typo-tolerance)
66+
- [Index creation](#index-creation)
67+
- [Implicit index creation](#implicit-index-creation)
68+
- [Explicit index creation](#explicit-index-creation)
69+
- [Index UID](#index-uid)
70+
- [Primary key](#primary-key)
71+
- [Index settings](#index-settings)
72+
- [Displayed and searchable attributes](#displayed-and-searchable-attributes)
73+
- [Distinct attribute](#distinct-attribute)
74+
- [Faceting](#faceting)
75+
- [Filterable attributes](#filterable-attributes)
76+
- [Pagination](#pagination)
77+
- [Ranking rules](#ranking-rules)
78+
- [Sortable attributes](#sortable-attributes)
79+
- [Stop words](#stop-words)
80+
- [Synonyms](#synonyms)
81+
- [Typo tolerance](#typo-tolerance)
82+
- [Swapping indexes](#swapping-indexes)
7683

7784
To change index settings, use the [update settings endpoint](/reference/api/settings#update-settings) or any of the child routes.
7885

reference/api/indexes.mdx

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,6 @@ Update an index's [primary key](/learn/getting_started/primary_key#primary-key).
164164

165165
To change the primary key of an index that already contains documents, you must first delete all documents in that index. You may then change the primary key and index your dataset again.
166166

167-
<Note>
168-
It is not possible to change an index's `uid`.
169-
</Note>
170-
171167
### Path parameters
172168

173169
| Name | Type | Description |
@@ -179,6 +175,7 @@ It is not possible to change an index's `uid`.
179175
| Name | Type | Default value | Description |
180176
| :----------------- | :-------------- | :------------ | :---------------------------------------------------------------------------------------- |
181177
| **`primaryKey`** * | String / `null` | N/A | [`Primary key`](/learn/getting_started/primary_key#primary-field) of the requested index |
178+
| **`uid`** * | String / `null` | N/A | New `uid` of the requested index |
182179

183180
### Example
184181

@@ -230,33 +227,28 @@ You can use the response's `taskUid` to [track the status of your request](/refe
230227

231228
## Swap indexes
232229

233-
```http
234-
POST /swap-indexes
235-
```
236-
237230
<RouteHighlighter method="POST" path="/swap-indexes" />
238231

239-
Swap the documents, settings, and task history of two or more indexes. **You can only swap indexes in pairs.** However, a single request can swap as many index pairs as you wish.
232+
Swap the documents, settings, and task history of two or more indexes. **You can only swap indexes in pairs.** A single request can swap as many index pairs as you wish.
240233

241-
Swapping indexes is an atomic transaction: **either all indexes are successfully swapped, or none are.**
234+
Swapping indexes is an atomic transaction: **either all indexes in a request are successfully swapped, or none are.** You can swap multiple pairs of indexes with a single request. To do so, there must be one object for each pair of indexes to be swapped.
242235

243236
Swapping `indexA` and `indexB` will also replace every mention of `indexA` by `indexB` and vice-versa in the task history. `enqueued` tasks are left unmodified.
244237

245238
[To learn more about index swapping, refer to this short guide.](/learn/getting_started/indexes#swapping-indexes)
246239

247240
### Body
248241

249-
An array of objects. Each object has only one key: `indexes`.
242+
An array of objects with the following fields:
250243

251-
| Name | Type | Default value | Description |
252-
| :------------- | :--------------- | :------------ | :----------------------------------------- |
253-
| **`indexes`*** | Array of strings | N/A | Array of the two `indexUid`s to be swapped |
244+
| Name | Type | Default value | Description |
245+
| :------------- | :--------------- | :------------ | :------------------------------------------------- |
246+
| **`indexes`** | Array of strings | N/A | Array of the two `indexUid`s to be swapped |
247+
| **`rename`** | Boolean | `false` | If `true`, renames an index instead of swapping it |
254248

255249
Each `indexes` array must contain only two elements: the `indexUid`s of the two indexes to be swapped. Sending an empty array (`[]`) is valid, but no swap operation will be performed.
256250

257-
<Note>
258-
You can swap multiple pairs of indexes with a single request. To do so, there must be one object for each pair of indexes to be swapped.
259-
</Note>
251+
Use `rename: false` if you are swapping two existing indexes. Use `rename: true` if the second index in your array does not exist.
260252

261253
### Example
262254

0 commit comments

Comments
 (0)