1

I have an index and type. I used mapping and ngram analyzer. The problem is when I want to use mapping and ngram analyzer for a new type under same index, it gives me an error and force me to remove my index.

But I don't want to remove my index for new types for each mapping operation because I might continue to add new types under same index. Removing my index and indexing all documents and types again will be time and data loss for me.

Do you have any solution for this?

3
  • how are you adding the mapping for a new type in an index? Commented Oct 21, 2014 at 18:38
  • with a script, here: pastebin.com/HQCNzY8L Commented Oct 21, 2014 at 20:09
  • in the above script you are also trying to update the settings of an index you can't do that without closing the index. Commented Oct 21, 2014 at 20:39

1 Answer 1

1

You can add new types to mapping of an existing index without having to reindex the old documents of pre-existing type.You can read about it in update mapping.

For example if you have an index "TEST" and you want to create a new type "type_new". You could run the following :

curl -XPUT 'http://<server>/TEST/_mapping/type_new' -d '
{
    "TYPE_NEW" : {
        "properties" : {
            "subject" : {"type" : "string", "store" : true }
        }
    }
}'

However if you are going to add a new analyzer to the existing index then you would need to close the index update the settings and then reopen.You can look at update settings for more information.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks a lot for your good answer keety. It works for me. I dont need to delete my index anymore. But I really wonder that do I have to remove my type whenever I want to re-mapping? Is there any way to remapping without deleting type? IF not, I will accept your answer. Thanks a lot.
curl -XPUT 'http://<server>/TEST/_mapping/type_new' adds a new type to the existing mapping but does not delete the previous types. After adding a new type you can check all the existing types on an index curl -XGET 'http://<server>/<index>/_mapping/"
Thanks for help. If u have any idea have a look also this question? stackoverflow.com/questions/26504261/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.