how can i store elasticsearch settings+mappings in one file (like schema.xml for Solr)

StackOverflow https://stackoverflow.com/questions/7828982

  •  27-10-2019
  •  | 
  •  

Question

How can I store elasticsearch settings+mappings in one file (like schema.xml for Solr)? Currently, when I want to make a change to my mapping, I have to delete my index settings and start again. Am I missing something?

I don't have a large data set as of now. But in preparation for a large amount of data that will be indexed, I'd like to be able to modify the settings and some how reindex without starting completely fresh each time. Is this possible and if so, how?

Was it helpful?

Solution

These are really multiple questions disguised as one. Nevertheless:

How can I store elasticsearch settings+mappings in one file (like schema.xml for Solr)?

First, note, that you don't have to specify mapping for lots of types, such as dates, integers, or even strings (when the default analyzer is OK for you).

You can store settings and mappings in various ways, in ElasticSearch < 1.7:

  1. In the main elasticsearch.yml file
  2. In an index template file
  3. In a separate file with mappings

Currently, when I want to make a change to my mapping, I have to delete my index settings and start again. Am I missing something?

You have to re-index data, when you change mapping for an existing field. Once your documents are indexed, the engine needs to reindex them, to use the new mapping.

Note, that you can update index settings, in specific cases, such as number_of_replicas, "on the fly".

I'd like to be able to modify the settings and some how reindex without starting completely fresh each time. Is this possible and if so, how?

As said: you must reindex your documents, if you want to use a completely new mapping for them.

If you are adding, not changing mapping, you can update mappings, and new documents will pick it up when being indexed.

OTHER TIPS

Since Elasticsearch 2.0:

It is no longer possible to specify mappings in files in the config directory.

Find the documentation link here.

It's also not possible anymore to store index templates within the config location (path.conf) under the templates directory.

The path.conf (/etc/default/elasticsearch by default on Ubuntu) stores now only environment variables including heap size, file descriptors.

You need to create your templates with curl.

If you are really desperate, you could create your indexes and then backup your data directory and then use this one as your "template" for new Elasticsearch clusters.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top