Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 248
jbattle Avatar asked Oct 19 '11 22:10

jbattle


1 Answers

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.

like image 122
karmi Avatar answered Oct 16 '22 01:10

karmi