Reputation: 95
Scenario : I am trying to index json data into elastic . I am getting an error like
17:13:38.146 [main] ERROR com.opnlabs.lighthouse.elastic.ElasticSearchIndexer - {"root_cause":[{"type":"illegal_argument_exception","reason":"Can't merge a non object mapping [map.audits.map.font-size.map.details.map.items.myArrayList.map.selector] with an object mapping [map.audits.map.font-size.map.details.map.items.myArrayList.map.selector]"}],"type":"illegal_argument_exception","reason":"Can't merge a non object mapping [map.audits.map.font-size.map.details.map.items.myArrayList.map.selector] with an object mapping [map.audits.map.font-size.map.details.map.items.myArrayList.map.selector]"}
What is causing the issue ? Please help
Code
JSONObject newJsonObject = new JSONObject();
JSONObject log = jsonObject.getJSONObject("audits");
JSONObject log1 = jsonObject.getJSONObject("categories");
newJsonObject.put("audits", log);
newJsonObject.put("categories", log1);
newJsonObject.put("timeStamp", time);
Index index = new Index.Builder(newJsonObject).index(mongoIndexName+"1").type("data").build();
DocumentResult a = client.execute(index);
Basically i m trying to add 3 json values into elastic index. Please help me with what i m doing wrong.
Upvotes: 0
Views: 295
Reputation: 15908
The error message means that you are trying to change an existing mapping. However, that is not possible in Elasticsearch. Once a mapping has been created, it cannot be changed.
As explained by Shay Banon himself:
You can't change existing mapping type, you need to create a new index with the correct mapping and index the data again.
So you must create a new index to create this mapping. Depending on the situation, you either
Of course in the latter case you will lose all data in the index, so prepare accordingly.
Taken from here : Can’t merge a non object mapping with an object mapping error in machine learning(beta) module
Upvotes: 1