我有一个流程,旨在使用 Get twitter 处理器提取推文,我使用 JOLTTransformJSON 处理器来提取包括主题标签在内的一些属性,我的 Jolt 规范如下
[
{
"operation": "shift",
"spec": {
"entities": {
"hashtags": {
"*": "hashtags"
}
},
"text": "content",
"id": "id",
"timestamp_ms": "timestamp",
"retweet_count": "retweetcount",
"url": "url"
}
},
{
"operation": "default",
"spec": {
"type": "twitter"
}
},
{
"operation": "cardinality",
"spec": {
"hashtags": "MANY"
}
}
]
当 twitter 输出包含主题标签时,JOLTTransformJSON 处理器输出将以下列方式为我提供这些主题标签
{
"hashtags": [{
"text": "Venus",
"indices": [16,
22]
},
{
"text": "Cancer",
"indices": [69,
76]
},
{
"text": "ascendant",
"indices": [86,
96]
}],
"content": "acmc_clock_euro #Venus is now (16h58m01s UT) setting at 10°32'50.2'' #Cancer opposite #ascendant at Helsinki, SF",
"id": 895332436975931393,
"timestamp": "1502298862104",
"retweetcount": 0,
"url": "https://twitter.com/pe602/status/895332436975931393",
"type": "twitter"
}
但是如果 hashtags 数组为空,如下所示
"entities": {
"hashtags": []
输出将不包含主题标签,如果 twitter 操作没有使用 JOLT 处理器的主题标签,我如何使输出具有主题标签元素但带有一个空数组。