ElasticSearch 5: MapperParser exception when inserting data

My initial mapping was

{ "vehiclemodel": { "properties": { "price": { "type": "double" } } } } 

Later I updated the display below

 { "vehiclemodel": { "properties": { "price": { "type": "double", "fields": { "exShowroomPrice": { "type": "double" } } } } } } 

Now, when I add Data1 , it is added, but when I add Data2 , it throws an exception below

Data1 :

 { "price": 36992043 } 

Data2 :

 { "price": { "exShowroomPrice": 36992043 } } 

Exception :

 { 'index': { '_index': 'notes', '_type': 'vehiclemodel', '_id': 'fb85823a-021b-468c-91d9-8db5f001ee06', 'status': 400, 'error': { 'type': 'mapper_parsing_exception', 'reason': 'failed to parse [price]', 'caused_by': { 'type': 'json_parse_exception', 'reason': 'Current token (START_OBJECT) not numeric, can not use numeric value accessors\n at [Source: org.elasticsear ch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@ 6e2393ee; line: 1, column: 277]' } } } } 

My vehiclemodel collection has both data types in MongoDB . I am using a mongo connector to synchronize btw mongo and ES data. When I try to sync, I get the exception above.

0
elasticsearch elasticsearch-plugin elasticsearch-5
source share
2 answers

Your comparison is wrong for what I assume you want to achieve.

fields matching allows you to index the same field with various analyzers, for example (see related documents). Therefore, in your case, you click

 { "price" : 1923 } 

and ES will store it twice, once as price and once under the price.exShowroomPrice contour.

You could just add a completely separate property, the hierarchy does not need to be maintained. For example, a mapping like:

 { "vehiclemodel": { "properties": { "price": { "type": "double" }, "exShowroomPrice": { "type": "double" } } } } 

Then send the data as follows:

 { "price" : 1923 "exShowroomPrice" : 1800 } 

I don't know how mongo-connector works, but there should be a way to map these fields, which I would suggest.

+1
source share

Fields in elasticsearch mappings are thought to index the same field in different ways, for example, treating an input field as a string or a keyword. Thus, you defined the price as double, but elasticsearch detects {}, so this exception is thrown. You have to redo your data there.

0
source share

All Articles