Elasticsearch JSON Processor(JSON 处理器)

x33g5p2x  于2021-03-14 发布在 ElasticSearch  
字(1.1k)|赞(0)|评价(0)|浏览(687)

原文链接 : https://www.elastic.co/guide/en/elasticsearch/reference/5.3/json-processor.html

译文链接 : http://www.apache.wiki/pages/viewpage.action?pageId=10027814

贡献者 : [那伊抹微笑],[ApacheCN],[Apache中文网]

JSON 字符串转换为一个结构化的 JSON 对象。

Table 23. Json Options(表 23. Json 选项)

Name(名称)Required(必要的)Default(默认值)Description(描述)
fieldyes-要解析的 field(字段)
target_fieldnofield将已转换的结构化对象插入的 field(字段)
add_to_rootnofalse标记强制将序列化的 json 注入到文档的顶层。在该选项使用时,不得设置 **target_field **。

假设您提供的 json 处理器使用的是如下配置 : 

{
  "json" : {
    "field" : "string_source",
    "target_field" : "json_target"
  }
}

如果以下文档被处理 : 

{
  "string_source": "{\"foo\": 2000}"
}

在经过 json 处理器操作之后,结果如下 : 

{
  "string_source": "{\"foo\": 2000}",
  "json_target": {
    "foo": 2000
  }
}

如果提供以下的配置,省略选项 target_field 设置 : 

{
  "json" : {
    "field" : "source_and_target"
  }
}

然后改 json 处理器在这个 document(文档)上操作 : 

{
  "source_and_target": "{\"foo\": 2000}"
}

结果如下 : 

{
  "source_and_target": {
    "foo": 2000
  }
}

这说明,除非在 processor(处理器)配置中明确地命名,否则 **target_field **与必要的 **field** 配置中所提供的字段相同。

相关文章

微信公众号

最新文章

更多