【问题标题】:Error while indexing data to elastic using java使用java将数据索引到弹性时出错
【发布时间】:2019-04-22 23:50:00
【问题描述】:

场景:我正在尝试将 json 数据索引到 elastic 中。我收到类似的错误

17:13:38.146 [主要] 错误 com.opnlabs.lighthouse.elastic.ElasticSearchIndexer - {"root_cause":[{"type":"illegal_argument_exception","re​​ason":"不能 合并非对象映射 [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","re​​ason":"不能 合并非对象映射 [map.audits.map.font-size.map.details.map.items.myArrayList.map.selector] 使用对象映射 [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 值添加到弹性索引中。请帮我解决我做错的事情。

【问题讨论】:

    标签: java spring-boot elasticsearch


    【解决方案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

    【讨论】:

      猜你喜欢
      • 2021-01-01
      • 2015-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-03
      • 2014-09-01
      • 2020-08-16
      相关资源
      最近更新 更多