This might be something really peculiar I’m trying to do. I’m running a “river” to dynamically index all data in my couchdb.
As multiple users enter data into the system, sometimes there is a conflict in mapping (MapperParser Error). For example:
- userA adds the following data –
{"tweet" : {"fooval" : "1"}}
— elasticSearch creates a Mapping for thistweet.foovalvariable as Number (as it interprets it as a number) - userB adds the following data –
{"tweet" : {"fooval" : "false"}}
— elasticSearch tries to create a Mapping for thistweet.foovalvariable as Boolean (as it interprets it as a Boolean) and hence a MapperParser Error.
I guess you see the problem. Also I only want to do it at the level of scalar types, as I don’t want Arrays/Objects to be treated as strings. I want all scalar types to be treated as Strings while the mapping is being created.
I couldn’t find anything on the doc page, or on the forum, so thought will ask here for directions/pointers.
First of all, by default, elasticsearch is not parsing strings. So, if you will pass to elasticsearch the following JSON:
{"tweet": {"fooval": "1"}}it will treattweet.foovalas a string. If elaticsearch is parsing strings, make sure thatnumeric_detectionanddate_detectionare set to false in the mapping.On the other side, if elasticsearch receives a value as a JSON number like this:
{"tweet": {"fooval": 1}}, elasticsearch will indeed map such field as long or double. You can override this behavior by using dynamic_templates. Here is an example: