我使用Logstash JDBC输入插件为Elasticsearch索引我的PostgreSQL数据。我有两个名为REQUEST
和ASSIGNMENT
的表格,如下所示。
如何使用Logstash将两个表索引为一个类型为REQUEST
的Elasticsearch文档,其中包含所有子ASSIGNMENT
记录的嵌套数组?
Table: REQUEST
REQUEST_ID | POC
---------- | ----------------
1234 | Jon Snow
1256 | Tyrion Lannister
Table: ASSIGNMENT
ASSIGN_ID | REQUEST_ID | STATUS | CREATED
--------- | ---------- | ------- | ----------
2345 | 1234 | New | 2017-01-06
2364 | 1234 | Working | 2017-03-12
2399 | 1234 | Working | 2017-05-20
5736 | 1256 | New | 2017-06-28
这就是我想要的Elasticsearch文档。它是搜索结果的_source
值的示例:
"_source": {
"request_id": "1234",
"poc": "Jon Snow",
"assignments": [
{
"assign_id": "2345",
"status": "New",
"created": "2017-01-06"
},
{
"assign_id": "2364",
"status": "Working",
"created": "2017-03-12"
},
{
"assign_id": "2399",
"status": "Working",
"created": "2017-05-20"
}
]
}