ElasticSearch PutMapping API: MapperParsingException. Root type mapping is not empty after parsing

I have a river on my local instance of ES 1.3.4 and JDBC for MySql 1.3.4.4

This river works fine and imports data into ES. Problem. I am faced with the fact that one of the fields is a text field and contains spaces. For example, "Real-time calculator." ES indexes it as “real”, “time” and “calculator” instead of “real-time calculator”.

So, I am creating a mapping using the below JSON:

{ "sale_test": { "properties": { "Client": { "index": "not_analyzed", "type": "string" }, "OfferRGU": { "type": "long" }, "SaleDate": { "format": "dateOptionalTime", "type": "date" }, "State": { "type": "string" } } } } 

and command:

 curl -XPUT http://localhost:9200/my_index/_mapping/my_type 

But I get the error mentioned below:

 > {"error":"MapperParsingException[Root type mapping not empty after > parsing! Remaining fields: [sale_test : > {properties={Client={type=string, index=not_analyzed}, > OfferRGU={type=long}, SaleDate={type=date, format=dateOptionalTime}, > State={type=string}}}]]","status":400} 

When I try to view the current mapping using the command below:

 curl -XGET http://localhost:9200/dgses/sale_test_river/_mapping 

I only get this: {}

Thanks for your help.

+5
source share
1 answer

Your type is incompatible; in the API call, my_type type

 curl -XPUT http://localhost:9200/my_index/_mapping/my_type 

then it becomes sale_test in the JSON message.

Having a consistent type will fix your problem:

 curl -XPUT http://localhost:9200/my_index/_mapping/sale_test -d ' { "sale_test": { "properties": { "Client": {"type": "string", "index": "not_analyzed" }, "OfferRGU": { "type": "long" }, "SaleDate": { "type": "date", "format": "dateOptionalTime" }, "State": { "type": "string" } } } }' 

Here you have both a new index and a new type:

 curl -XGET http://localhost:9200/dgses/sale_test_river/_mapping 

Fixing the index and type gives me:

 curl -XGET http://localhost:9200/my_index/sale_test/_mapping?pretty { "myindex" : { "mappings" : { "sale_test" : { "properties" : { "Client" : { "type" : "string", "index" : "not_analyzed" }, "OfferRGU" : { "type" : "long" }, "SaleDate" : { "type" : "date", "format" : "dateOptionalTime" }, "State" : { "type" : "string" } } } } } } 
+7
source

Source: https://habr.com/ru/post/1207897/


All Articles