MergeMappingException when putting empty mapping

I PUT the following json:
{"mytype":{}}
to:
indexname/mytype/_mapping

I'm getting the following error:
{
"error": "MergeMappingException[Merge failed with failures {[mapper
[myProp] of different type, current_type [string], merged_type
[ObjectMapper]]}]",
"status":400
}

Is this an expected error?

What I'm trying to do:

  • clear the mapping
  • reindex an object so that it uses the dynamic_templates again to
    reaply them.
  • queue all items of the type to be resaved eventually.

I'm aware that reindexing a new mapping is a feature that's allready
being worked on, but for now I'd like to do the reindexing manually.

When I don't try to put an empty mapping, but get the mappping first:

curl -XGET 'indexname/mytype/_mapping' > mapping.json

I alter the mapping.json (I'm trying to add "index" : "not_analyzed"
to a property)

And then I try to PUT the mapping again:

curl -XPUT 'indexname/mytype/_mapping' -d '
...contents from json file...
'

I also get the error:
mapper [otherProp] has different index values, mapper [otherProp] has
different index_analyzer, mapper [otherProp] has different
search_analyzer

I probably assume that I can change the "index" of a property while
there is data in the index for this type...

You can't change the mapping of a field that is already mapping (its index
aspect for example).

On Wed, May 16, 2012 at 7:42 PM, Jaap Taal jaap@q42.nl wrote:

When I don't try to put an empty mapping, but get the mappping first:

curl -XGET 'indexname/mytype/_mapping' > mapping.json

I alter the mapping.json (I'm trying to add "index" : "not_analyzed"
to a property)

And then I try to PUT the mapping again:

curl -XPUT 'indexname/mytype/_mapping' -d '
...contents from json file...
'

I also get the error:
mapper [otherProp] has different index values, mapper [otherProp] has
different index_analyzer, mapper [otherProp] has different
search_analyzer

I probably assume that I can change the "index" of a property while
there is data in the index for this type...