首页 文章

使用java将数据索引到弹性时出错

提问于
浏览
0

场景:我试图将json数据索引为弹性数据 . 我收到的错误就像

17:13:38.146 [main] ERROR com.opnlabs.lighthouse.elastic.ElasticSearchIndexer - {“root_cause”:[{“type”:“illegal_argument_exception”,“reason”:“无法合并非对象映射[map] .audits.map.font-size.map.details.map.items.myArrayList.map.selector],带有对象映射[map.audits.map.font-size.map.details.map.items.myArrayList.map . selector]“}],”type“:”illegal_argument_exception“,”reason“:”无法合并非对象映射[map.audits.map.font-size.map.details.map.items.myArrayList.map . 选择器]与对象映射[map.audits.map.font-size.map.details.map.items.myArrayList.map.selector]“}

是什么导致了这个问题?请帮忙

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);

基本上我试图将3个json值添加到弹性索引中 . 请帮我解决我做错的事 .

1 回答

  • 1

    错误消息表示您正在尝试更改现有映射 . 但是,这在Elasticsearch中是不可能的 . 创建映射后,无法更改 .

    As explained by Shay Banon himself

    您无法更改现有映射类型,需要使用正确的映射创建新索引并再次索引数据 .

    因此,您必须创建一个新索引来创建此映射 . 根据具体情况,您也可以

    • 创建一个额外的索引,或

    • 删除当前索引并从头开始重新创建 .

    当然,在后一种情况下,您将丢失索引中的所有数据,因此请做好相应准备 .

    取自这里:Can’t merge a non object mapping with an object mapping error in machine learning(beta) module

相关问题