@@ -116,10 +116,12 @@ make ingest
116
116
117
117
## Elasticsearch Mappings
118
118
119
- Mappings apply to search index, not source.
119
+ Mappings apply to search index, not source. The mappings are stored in index templates on application startup.
120
+ These templates will be used implicitly when creating new Collection and Item indices.
120
121
121
122
122
123
## Managing Elasticsearch Indices
124
+ ### Snapshots
123
125
124
126
This section covers how to create a snapshot repository and then create and restore snapshots with this.
125
127
@@ -219,3 +221,52 @@ curl -X "POST" "http://localhost:8080/collections" \
219
221
220
222
Voila! You have a copy of the collection now that has a resource URI (` /collections/my-collection-copy ` ) and can be
221
223
correctly queried by collection name.
224
+
225
+ ### Reindexing
226
+ This section covers how to reindex documents stored in Elasticsearch/OpenSearch.
227
+ A reindex operation might be useful to apply changes to documents or to correct dynamically generated mappings.
228
+
229
+ The index templates will make sure that manually created indices will also have the correct mappings and settings.
230
+
231
+ In this example, we will make a copy of an existing Item index ` items_my-collection-000001 ` but change the Item identifier to be lowercase.
232
+
233
+ ``` shell
234
+ curl -X " POST" " http://localhost:9200/_reindex" \
235
+ -H ' Content-Type: application/json' \
236
+ -d $' {
237
+ "source": {
238
+ "index": "items_my-collection-000001"
239
+ },
240
+ "dest": {
241
+ "index": "items_my-collection-000002"
242
+ },
243
+ "script": {
244
+ "source": "ctx._source.id = ctx._source.id.toLowerCase()",
245
+ "lang": "painless"
246
+ }
247
+ }'
248
+ ```
249
+
250
+ If we are happy with the data in the newly created index, we can move the alias ` items_my-collection ` to the new index ` items_my-collection-000002 ` .
251
+ ``` shell
252
+ curl -X " POST" " http://localhost:9200/_aliases" \
253
+ -h ' Content-Type: application/json' \
254
+ -d $' {
255
+ "actions": [
256
+ {
257
+ "remove": {
258
+ "index": "*",
259
+ "alias": "items_my-collection"
260
+ }
261
+ },
262
+ {
263
+ "add": {
264
+ "index": "items_my-collection-000002",
265
+ "alias": "items_my-collection"
266
+ }
267
+ }
268
+ ]
269
+ }'
270
+ ```
271
+
272
+ The modified Items with lowercase identifiers will now be visible to users accessing ` my-collection ` in the STAC API.
0 commit comments