Bulk index cannot change type for index with more than one shard

Hi,

While bulk indexing I got error:

Bulk error [index]: {"_index":"one","status":400,"_id":"00c98d00-d8c4-46ff-9178-d4b863bd8871","error":{"reason":"mapper [meta.relevance] cannot be changed from type [long] to [float]","type":"illegal_argument_exception"},"_type":"one"}

Yes, it is possible to have values which can looks like as long or float in documents of the same type. But issue is more interesting. I see this error only if I created index with more than one shard, but with one shard I not see it with the same data. How can it be?

It is complicated and I'm not sure I could explain it properly. It has to do with the values coming in essentially random order and Elasticsearch inferring the type from the first one it sees. If there are two shards then it does it in parallel and tries to make the types. And then there is coerce.

The fix for all this is to define the mappings up front or use a template or the like to force the decision. Docs:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.