Update mapping on existing index

Hi there,

I've been working on an application for some time, and our requirements have changed somewhat, such that I've found myself needing to change the mappings on my index from the dynamic ones to some more tailored ones (with term vectors and such like).

Is it possible for me to update the mappings on an existing index and allow elasticsearch to re-index the documents (which I assume while expensive is possible, since ES has the source documents stored in the _source field), or do I have to re-create the index from scratch? My unscientific testing thus far suggests the latter, but I was hoping I was just doing something wrong.

Thanks,
Andrew
Andrew Harvey / Developer
lexer
m/
t/ +61 2 9019 6379
w/ http://lexer.com.au
Help put an end to whaling. Visit http://www.givewhalesavoice.com.au/

Please consider the environment before printing this email
This email transmission is confidential and intended solely for the person or organisation to whom it is addressed. If you are not the intended recipient, you must not copy, distribute or disseminate the information, or take any action in relation to it and please delete this e-mail. Any views expressed in this message are those of the individual sender, except where the send specifically states them to be the views of any organisation or employer. If you have received this message in error, do not open any attachment but please notify the sender (above). This message has been checked for all known viruses powered by McAfee.

For further information visit http://www.mcafee.com/us/threat_center/default.asp
Please rely on your own virus check as no responsibility is taken by the sender for any damage rising out of any virus infection this communication may contain.

This message has been scanned for malware by Websense. www.websense.com

Hi Andrew

Is it possible for me to update the mappings on an existing index and allow

elasticsearch to re-index the documents (which I assume while expensive is
possible, since ES has the source documents stored in the _source field), or
do I have to re-create the index from scratch? My unscientific testing thus
far suggests the latter, but I was hoping I was just doing something wrong.

Your testing is correct I'm afraid.

What I do is create the index name with the current time as a suffix, eg:

myindex_1277386794

Then I create an alias 'myindex' which points to 'myindex_1277386794'.
Internally, my application just uses 'myindex'.

when I need to change the mapping, i create a new 'myindex_1277400000', add
the new mapping, read the data from the old index, and index to the new
index.

Once complete (and I've accounted for anything that has changed since the
reindexing process started), i update the alias to point to the new index.

clint