简体   繁体   中英

Error while indexing data to elastic using java

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 im trying to add 3 json values into elastic index. Please help me with what im doing wrong.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM