0

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.

1 Answer 1

1

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

  • create an additional index, or
  • delete the current index and re-create it from scratch.

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.