EN ET

Reindexer

Reindexer is a tool for making copies or subsets of Elasticsearch indices. Reindexer can be used for various data management tasks:

  • Making a copy of an index;

  • Merging multiple indices into one;

  • Making a random subset of an index;

  • Making a subset based on predefined query;

  • Renaming fields;

  • Updating Elasticsearch field types.

Creation

Parameters

description:

Name of the Reindexing task.

indices:

List of Elasticsearch indices (datasets) to reindex.

fields:

List of fields to reindex, i.e. transfer to the new index. By default, all the fields in the source index are selected.

query:

Specified Elasticsearch Search query. If left empty (and random_size is not defined), all documents from the source index are transferred to the new one.

new_index:

Name of the target index.

random_size:

Random subset size. If defined, new index is constructed of given number of random documents. If left empty, all the documents in the source index (or in accordance with restricted search query) are reindexed.

field_type:

List of new Elasticsearch field types in the following format:

[{"field_name": "new_field_type"}]

GUI

For creating a new Reindexing task, navigate to “Tools” -> “Reindexer” as seen in Fig. 24.

_images/reindexer_nav.png

Fig. 24 Reindexer navigation

If the navigation is successful, you should see a panel similar to Fig. 25 with “Create” button in the top left corner of the page.

_images/reindexer_create_button.png

Fig. 25 Reindexer creation button

Clicking on the “Create” button opens a new modal window with title “New Reindexer” as depicted in Fig. 26.

_images/reindexer_create_new.png

Fig. 26 Empty Reindexer creation view

Fill the required fields and click on the “Create” button in the bottom right corner of the window (Fig. 27).

_images/reindexer_create.png

Fig. 27 Filled Reindexer creation view

The created Reindexer can now be seen as the first (or only, if no previous Reindexers exist under the project) row in the table of Reindex tasks (Fig. 28).

_images/reindexer_task_list.png

Fig. 28 List of Reindexer tasks.

API

Reference: http://localhost:8000/api/v1/redoc/#operation/projects_reindexer_create

Endpoint /projects/{project_pk}/reindexer/

Example:

curl -X POST "http://localhost:8000/api/v1/projects/1/reindexer/" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Token 8229898dccf960714a9fa22662b214005aa2b049" \
-d '{
      "description": "reindex imdb reviews",
      "indices": ["imdb_reviews"],
      "fields": ["review_text", "doc_id"],
      "new_index": "imdb_reviews_copy"
    }'

Response:

{
    "id": 81,
    "url": "https://localhost:8000/api/v1/projects/1/reindexer/1/",
    "author_username": "my_username",
    "description": "rewindex imdb reviews",
    "fields": ["review_text", "doc_id"],
    "query": "{\"query\": {\"match_all\": {}}}",
    "new_index": "imdb_reviews_copy",
    "random_size": 0,
    "field_type": [],
    "task": {
        "id": 153610,
        "status": "created",
        "progress": 0.0,
        "step": "",
        "errors": "[]",
        "time_started": "2020-10-27T11:37:06.276108+02:00",
        "last_update": null,
        "time_completed": null,
        "total": 0,
        "num_processed": 0
    }
}