update_by_query用于多字段

时间:2017-08-25 15:18:13

标签: elasticsearch elasticsearch-2.0

我在索引中添加了现有字段multi field的新rawresponse)。由于新的多字段raw将没有数据。我试图从源代码添加数据,如下所示。

POST /y_metrics/response/_update_by_query
{
  "script":{
    "inline":  "ctx._source.response['raw'] = ctx._source.response;"
  },
  "query": {
        "match_all": {}
    }
}

失败:

 "type": "missing_property_exception",
 "reason": "No such property: raw for class: java.lang.String"

第二次尝试:

POST /y_metrics/response/_update_by_query
{
  "script":{
    "inline":  "ctx._source['response.raw'] = ctx._source.response;"
  },
  "query": {
        "match_all": {}
    }
}

失败:

    "type": "mapper_parsing_exception",
    "reason": "Field name [response.raw] cannot contain '.'"

显然,这个问题似乎是因为"。"。但在这种情况下,如何才能访问multi field?我读到de_dot过滤器在我的案例中有用吗?

1 个答案:

答案 0 :(得分:1)

如果将字段添加到现有字段(因此是多字段),则无需使用脚本,只需使用reindex,Elasticsearch将处理其余字段。您可以通过查询调用删除更新的script部分。

相关问题