Skip to content

Mappings and reindex

  • Elasticsearch

Elasticsearch adds new fields to an existing mapping but does not change existing ones. The mapping editor knows the difference: it applies what can change in place, and for anything else it plans a reindex into a new index and moves clients over to it.

  1. Open the index panel (Open index (mappings, settings…) from the index’s menu) and pick the Mappings tab. The field list on the left shows every field and multi-field with its type.
  2. Edit the mapping in the editor on the right.
  3. Choose Check changes to compare it with the current mapping. Each field change is listed as added, updated, changed or removed, with the reason.
  4. If the plan says These changes apply in place., choose Apply in place. Querybara sends PUT /<index>/_mapping.

New fields and multi-fields, and a few parameters (such as ignore_above, search_analyzer and meta), apply in place. A changed type or another parameter, or a field left out, needs a new index: the plan then says Existing field mappings cannot change: this needs a reindex into a new index.

  1. On the Mappings tab, choose Reindex with this mapping…, or choose Reindex… on the Overview tab. With nothing in the mapping editor, the current mapping is used.
  2. Enter the New index name.
  3. Choose what happens to clients when the copy is done:
    • move the index’s aliases to the new index in one step (offered when it has aliases);
    • delete the old index and give its name to the new index as an alias, so clients keep the name;
    • leave the old index as it is.
  4. Review the numbered steps, then choose Run the plan…. When the plan deletes the old index, or the profile confirms writes, one confirmation covers every step.

The plan creates the new index with the copyable settings of the old one and the new mapping, starts _reindex as a server task, refreshes the new index, and then moves the aliases in one _aliases call or replaces the old index. Open in console puts the same steps into a console instead, as requests you can edit and send yourself.

While the plan runs, a bar above the tabs shows the current step, a progress bar of documents copied out of the total, version conflicts and the running time, read from the Tasks API. Cancel cancels the reindex task. A failed or cancelled copy stops before the aliases move, so clients keep using the old index.

Documents Querybara 0.1.1 · built frombc9f5aa