在索引文档上的Elasticsearch在带有date,month,year的日期字段旁边添加新字段

时间:2019-08-16 08:35:35

标签: elasticsearch ingest

我不确定用Elasticsearch是否可行,但是我想在检测到日期字段的同一位置自动添加新字段。 例如,这是索引上的映射:

"properties":{"somedatefield1":"Date","orders":{"type":"Array","properties":{"orderNo":"Number","somedatefield2":"Date"},"Persons":{"type":"Array","properties":{"Name":"Text","Attributes":{"type":"Object","properties":{"age":"Number","dateofbirth":"Date"}}}}}    

自动提取所有日期字段,并在同一父位置上使用Day字段,Month字段和Year字段自动创建新字段。将文档编入索引时,它将看起来像这样:

 "properties": { "emp_somedatefield1_dd": { "type": "long" }, "emp_somedatefield1_mm": { "type": "long" }, "emp_somedatefield1_yy": { "type": "long" }, "Persons": { "type": "nested", "properties": { "Attributes": { "type": "nested", "properties": { "dateofbirth": { "format": "yyyy-MM-dd", "type": "date" }, "emp_dateofbirth_dd": { "type": "long" }, "emp_dateofbirth_mm": { "type": "long" }, "emp_dateofbirth_yy": { "type": "long" }, "emp_trigger_dateofbirth": { "type": "text" }, "age_empanalyzed": { "type": "text" }, "age": { "type": "long", "fields": { "normalize": { "normalizer": "my_normalizer", "type": "keyword" }, "keyword": { "type": "keyword" } } } } }, "Name_empanalyzed": { "type": "text" }, "Name": { "type": "keyword", "fields": { "normalize": { "normalizer": "my_normalizer", "type": "keyword" }, "keyword": { "type": "keyword" } } } } }, "emp_trigger_somedatefield1": { "type": "text" }, "somedatefield1": { "format": "yyyy-MM-dd", "type": "date" }, "orders": { "type": "nested", "properties": { "emp_somedatefield2_dd": { "type": "long" }, "emp_somedatefield2_mm": { "type": "long" }, "emp_somedatefield2_yy": { "type": "long" }, "orderNo": { "type": "long", "fields": { "normalize": { "normalizer": "my_normalizer", "type": "keyword" }, "keyword": { "type": "keyword" } } }, "orderNo_empanalyzed": { "type": "text" }, "emp_trigger_somedatefield2": { "type": "text" }, "somedatefield2": { "format": "yyyy-MM-dd", "type": "date" } } } }     

我一直在研究将Piplane Api与日期处理器/ Foreach处理器结合使用,但我不知道如何进行这项工作。

谢谢

0 个答案:

没有答案