首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >更新elasticsearch中的对象

更新elasticsearch中的对象
EN

Stack Overflow用户
提问于 2019-04-01 01:41:07
回答 1查看 161关注 0票数 0

我正在尝试更新elasticsearch中的对象,但我收到了下一条错误消息:

Elasticsearch异常[type=mapper_parsing_exception,errorMessages的reason=object映射尝试将字段errorMessages解析为对象,但找到了具体的值]

This is my mappings:

{
.hierarchies: {
  mappings: {
   hierarchy: {
    dynamic: "strict",
   _all: {
      enabled: false
    },
    properties: {
      errorFlag: {
       type: "keyword"
     },
      errorMessages: {
        properties: {
           isFavourite: {
             type: "text"
        },
          message: {
             type: "text"
         }
       }
     },

  }
 }
}

我要更新的信息是这样的:

"errorMessages" -> "{"isFavourite":"yes","message":"hola"}"

我使用rest客户端连接器和object UpdateRequest:

 UpdateRequest updateRequest = new UpdateRequest(
                collection,
                type,
                id);

        updateRequest.doc(document);
        updateRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
        try {
            return esConnector.getRestClient().update(
                    updateRequest, RequestOptions.DEFAULT);
        } catch (IOException e) {
            throw new ElasticsearchGenericException("Error updating document " + collection + " > " + type + " id: " + id + " (Reason: " + e.getMessage() + ")");
        }
    }

文档的值是带有errorMessages的json。这是UpdateRequest对象:

索引更新{ source{"errorMessages":"{\"isFavourite\":\"yes\",,

,doc[.hierarchiesZEqi1GkByxIcUBtfsLRV {nullnull,doc_as_upsertfalse \“\”:\“hola\”}“}}],scripted_upsertfalse,detect_nooptrue}

对这个问题有什么想法吗?

EN

回答 1

Stack Overflow用户

发布于 2019-04-01 11:16:32

errorMessages应该表示为对象数组,如下所示,而不是字符串值:

{
  "errorMessages": [
    {
      "isFavourite": "yes",
      "message": "hola"
    }
  ]
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55443666

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档