How to update a mapping?

Hi,

I created an index with a mapping, in Java, using the
IndicesAdminClient.create call with a CreateIndexRequest.

I added a large amount of data to my index.

Now I want to alter the mapping: I wish to add some new fields, and I
also want to change the index property of one of the existing fields.

How do I accomplish this in Java? Is there a specific call to update a
mapping, or should I just re-issue the create command with the new
mapping? Will this destroy any of my old data?

I realize that I will need to update all my documents, and I am
prepared to do this, but I do not want to have to remove them all
first.

Thanks.

You can not update the mapping definition for an existing field.
So you will have to create a new mapping and reindex your docs.

I don't know if you can merge mappings in Java...

David.

Le 1 février 2012 à 22:16, Frank LaRosa frank@studyblue.com a écrit :

Hi,

I created an index with a mapping, in Java, using the
IndicesAdminClient.create call with a CreateIndexRequest.

I added a large amount of data to my index.

Now I want to alter the mapping: I wish to add some new fields, and I
also want to change the index property of one of the existing fields.

How do I accomplish this in Java? Is there a specific call to update a
mapping, or should I just re-issue the create command with the new
mapping? Will this destroy any of my old data?

I realize that I will need to update all my documents, and I am
prepared to do this, but I do not want to have to remove them all
first.

Thanks.

--
David Pilato
http://dev.david.pilato.fr/
Twitter : @dadoonet

You can add extra fields to an existing mapping, here is the code (you
can set ignore conflicts to true if you want to):

new
PutMappingRequestBuilder(client.admin().indices()).setIgnoreConflicts(true).setIndices(index).setType(type).setSource(mapping).execute().actionGet();

Ali

On Feb 1, 2:39 pm, "da...@pilato.fr" da...@pilato.fr wrote:

You can not update the mapping definition for an existing field.
So you will have to create a new mapping and reindex your docs.

I don't know if you can merge mappings in Java...

David.

Le 1 février 2012 à 22:16, Frank LaRosa fr...@studyblue.com a écrit :

Hi,

I created an index with a mapping, in Java, using the
IndicesAdminClient.create call with a CreateIndexRequest.

I added a large amount of data to my index.

Now I want to alter the mapping: I wish to add some new fields, and I
also want to change the index property of one of the existing fields.

How do I accomplish this in Java? Is there a specific call to update a
mapping, or should I just re-issue the create command with the new
mapping? Will this destroy any of my old data?

I realize that I will need to update all my documents, and I am
prepared to do this, but I do not want to have to remove them all
first.

Thanks.

--
David Pilatohttp://dev.david.pilato.fr/
Twitter : @dadoonet

Thanks for the reply.

The code is complaining if I fail to set the Type. I don't know what
to do:

(1) When I originally created the Index, I did not have to specify a
type.
(2) The "setType" function accepts a string rather than an enum, so I
have no idea what the valid types are or which one I want.

On Feb 1, 4:44 pm, Ali Loghmani loghm...@gmail.com wrote:

You can add extra fields to an existing mapping, here is the code (you
can set ignore conflicts to true if you want to):

new
PutMappingRequestBuilder(client.admin().indices()).setIgnoreConflicts(true) .setIndices(index).setType(type).setSource(mapping).execute().actionGet();

Ali

On Feb 1, 2:39 pm, "da...@pilato.fr" da...@pilato.fr wrote:

You can not update the mapping definition for an existing field.
So you will have to create a new mapping and reindex your docs.

I don't know if you can merge mappings in Java...

David.

Le 1 février 2012 à 22:16, Frank LaRosa fr...@studyblue.com a écrit :

Hi,

I created an index with a mapping, in Java, using the
IndicesAdminClient.create call with a CreateIndexRequest.

I added a large amount of data to my index.

Now I want to alter the mapping: I wish to add some new fields, and I
also want to change the index property of one of the existing fields.

How do I accomplish this in Java? Is there a specific call to update a
mapping, or should I just re-issue the create command with the new
mapping? Will this destroy any of my old data?

I realize that I will need to update all my documents, and I am
prepared to do this, but I do not want to have to remove them all
first.

Thanks.

--
David Pilatohttp://dev.david.pilato.fr/
Twitter : @dadoonet

I don't want it to automatically reindex all the documents for me. I
just want to update the mapping definition for when I add new
documents.

On Feb 1, 4:39 pm, "da...@pilato.fr" da...@pilato.fr wrote:

You can not update the mapping definition for an existing field.
So you will have to create a new mapping and reindex your docs.

I don't know if you can merge mappings in Java...

David.

Le 1 février 2012 à 22:16, Frank LaRosa fr...@studyblue.com a écrit :

Hi,

I created an index with a mapping, in Java, using the
IndicesAdminClient.create call with a CreateIndexRequest.

I added a large amount of data to my index.

Now I want to alter the mapping: I wish to add some new fields, and I
also want to change the index property of one of the existing fields.

How do I accomplish this in Java? Is there a specific call to update a
mapping, or should I just re-issue the create command with the new
mapping? Will this destroy any of my old data?

I realize that I will need to update all my documents, and I am
prepared to do this, but I do not want to have to remove them all
first.

Thanks.

--
David Pilatohttp://dev.david.pilato.fr/
Twitter : @dadoonet

Yes but if you want to modify an existing field (e.g. You want to add an analyzer), you won't be able to do it.
But if you only add new fields, it will work.

David :wink:
@dadoonet

Le 2 févr. 2012 à 00:02, Frank LaRosa frank@studyblue.com a écrit :

I don't want it to automatically reindex all the documents for me. I
just want to update the mapping definition for when I add new
documents.

On Feb 1, 4:39 pm, "da...@pilato.fr" da...@pilato.fr wrote:

You can not update the mapping definition for an existing field.
So you will have to create a new mapping and reindex your docs.

I don't know if you can merge mappings in Java...

David.

Le 1 février 2012 à 22:16, Frank LaRosa fr...@studyblue.com a écrit :

Hi,

I created an index with a mapping, in Java, using the
IndicesAdminClient.create call with a CreateIndexRequest.

I added a large amount of data to my index.

Now I want to alter the mapping: I wish to add some new fields, and I
also want to change the index property of one of the existing fields.

How do I accomplish this in Java? Is there a specific call to update a
mapping, or should I just re-issue the create command with the new
mapping? Will this destroy any of my old data?

I realize that I will need to update all my documents, and I am
prepared to do this, but I do not want to have to remove them all
first.

Thanks.

--
David Pilatohttp://dev.david.pilato.fr/
Twitter : @dadoonet

I was able to modify a field and change the index value on a field
from "no" to "not analyzed". At least, the server accepted the request
without throwing any exception. I won't know for sure if it actually
worked.

As an aside, I have a large index that took almost a week to build. It
isn't practical for me to delete it and reindex. I hope that the
developers of Elasticsearch keep people like me in mind as they
develop the product, and do not expect us to simply start over
whenever we want to make changes to our data stores.

On Feb 2, 12:08 am, David Pilato da...@pilato.fr wrote:

Yes but if you want to modify an existing field (e.g. You want to add an analyzer), you won't be able to do it.
But if you only add new fields, it will work.

David :wink:
@dadoonet

Le 2 févr. 2012 à 00:02, Frank LaRosa fr...@studyblue.com a écrit :

I don't want it to automatically reindex all the documents for me. I
just want to update the mapping definition for when I add new
documents.

On Feb 1, 4:39 pm, "da...@pilato.fr" da...@pilato.fr wrote:

You can not update the mapping definition for an existing field.
So you will have to create a new mapping and reindex your docs.

I don't know if you can merge mappings in Java...

David.

Le 1 février 2012 à 22:16, Frank LaRosa fr...@studyblue.com a écrit :

Hi,

I created an index with a mapping, in Java, using the
IndicesAdminClient.create call with a CreateIndexRequest.

I added a large amount of data to my index.

Now I want to alter the mapping: I wish to add some new fields, and I
also want to change the index property of one of the existing fields.

How do I accomplish this in Java? Is there a specific call to update a
mapping, or should I just re-issue the create command with the new
mapping? Will this destroy any of my old data?

I realize that I will need to update all my documents, and I am
prepared to do this, but I do not want to have to remove them all
first.

Thanks.

--
David Pilatohttp://dev.david.pilato.fr/
Twitter : @dadoonet

You can verify if you mapping has been updated or not by using get mapping. Some aspects can be changed, but not the "index" aspect of a field.

On Thursday, February 2, 2012 at 7:08 PM, Frank LaRosa wrote:

I was able to modify a field and change the index value on a field
from "no" to "not analyzed". At least, the server accepted the request
without throwing any exception. I won't know for sure if it actually
worked.

As an aside, I have a large index that took almost a week to build. It
isn't practical for me to delete it and reindex. I hope that the
developers of Elasticsearch keep people like me in mind as they
develop the product, and do not expect us to simply start over
whenever we want to make changes to our data stores.

On Feb 2, 12:08 am, David Pilato <da...@pilato.fr (http://pilato.fr)> wrote:

Yes but if you want to modify an existing field (e.g. You want to add an analyzer), you won't be able to do it.
But if you only add new fields, it will work.

David :wink:
@dadoonet

Le 2 févr. 2012 à 00:02, Frank LaRosa <fr...@studyblue.com (http://studyblue.com)> a écrit :

I don't want it to automatically reindex all the documents for me. I
just want to update the mapping definition for when I add new
documents.

On Feb 1, 4:39 pm, "da...@pilato.fr (http://pilato.fr)" <da...@pilato.fr (http://pilato.fr)> wrote:

You can not update the mapping definition for an existing field.
So you will have to create a new mapping and reindex your docs.

I don't know if you can merge mappings in Java...

David.

Le 1 février 2012 à 22:16, Frank LaRosa <fr...@studyblue.com (http://studyblue.com)> a écrit :

Hi,

I created an index with a mapping, in Java, using the
IndicesAdminClient.create call with a CreateIndexRequest.

I added a large amount of data to my index.

Now I want to alter the mapping: I wish to add some new fields, and I
also want to change the index property of one of the existing fields.

How do I accomplish this in Java? Is there a specific call to update a
mapping, or should I just re-issue the create command with the new
mapping? Will this destroy any of my old data?

I realize that I will need to update all my documents, and I am
prepared to do this, but I do not want to have to remove them all
first.

Thanks.

--
David Pilatohttp://dev.david.pilato.fr/
Twitter : @dadoonet

Hi Ali,

Can you tell me how to do ignore_conflicts without using java api?

Also any insight on what will happen if I make ignore_conflicts:true?
For example: will my mapping have the same field name with two
different types if I change the type of one of my field? Also if now my data
have that field, then what type(out of those 2) will ES use to index the
new data?

Thanks in advance..!!!

ankit

On Wednesday, February 1, 2012 2:44:46 PM UTC-8, Ali Loghmani wrote:

You can add extra fields to an existing mapping, here is the code (you
can set ignore conflicts to true if you want to):

new
PutMappingRequestBuilder(client.admin().indices()).setIgnoreConflicts(true).setIndices(index).setType(type).setSource(mapping).execute().actionGet();

Ali

On Feb 1, 2:39 pm, "da...@pilato.fr" da...@pilato.fr wrote:

You can not update the mapping definition for an existing field.
So you will have to create a new mapping and reindex your docs.

I don't know if you can merge mappings in Java...

David.

Le 1 février 2012 à 22:16, Frank LaRosa fr...@studyblue.com a écrit :

Hi,

I created an index with a mapping, in Java, using the
IndicesAdminClient.create call with a CreateIndexRequest.

I added a large amount of data to my index.

Now I want to alter the mapping: I wish to add some new fields, and I
also want to change the index property of one of the existing fields.

How do I accomplish this in Java? Is there a specific call to update a
mapping, or should I just re-issue the create command with the new
mapping? Will this destroy any of my old data?

I realize that I will need to update all my documents, and I am
prepared to do this, but I do not want to have to remove them all
first.

Thanks.

--
David Pilatohttp://dev.david.pilato.fr/
Twitter : @dadoonet

--