- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Jolt Transformation IF and ELSE
- Labels:
-
Apache NiFi
Created on 04-12-2021 06:28 PM - edited 04-13-2021 05:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
All,
I would like to create a new record based on the GroupTypeDescription. The value for this key could be "Individual" or "Enitity". Any help is appreciated
INPUT
{
"ConsolidatedList": [
{
"AliasType": "Primary",
"AliasTypeName": "AKA",
"Country": null,
"CountryOfBirth": "Syria",
"GroupStatus": "Asset Tweaking",
"GroupTypeDescription": "Individual",
"ID": 33233,
"LastUpdated": "2021-03-15T00:00:00",
"LastUpdatedDay": 15,
"name1": "Larry",
"name2": "Dan"
},
{
"AliasType": "AKA",
"AliasTypeName": "AKA",
"Country": null,
"CountryOfBirth": "Afghan",
"GroupStatus": "Asset Freeze Targets",
"GroupTypeDescription": "Entity",
"ID": 33233,
"LastUpdated": "2021-03-15T00:00:00",
"LastUpdatedDay": 15,
"name1": "Luna",
"name2": "Daniel"
}
]
}
EXPECTED OUTPUT
{
"RecordType": ["Entity","Individual"],
"Records": [
{
"_id": "1", // Counter
"RecordType": "Entity",
"Names": [
{
"_id": "1", //counter
"OtherName": "",
"UnparsedName": "",
"FirstName": "Luna",
"LastName": "Daniel",
"AliasType": "Primary"
}
]
},
{
"_id": "2",
"RecordType": "Individual",
"Names": [
{
"_id": "1",
"OtherName": "",
"UnparsedName": "",
"FirstName": "Larry",
"LastName": "Dan",
"AliasType": "AKA"
}
]
}
]
}
SPEC So far
[
{
"operation": "shift",
"spec": {
"ConsolidatedList": {
"*": {
"GroupTypeDescription": "Records[0].RecordsType[&1]",
"# ": "Records[0].Names.[&1].Other Name",
"# ": "Records[0].Names.[&1].UnparsedName",
"AliasType": "Records[0].Names.[&1].NameType"
}
}
}
}
]
I need to split record into objects based on the recordType. Please ignore the first name and last name.
Created 04-13-2021 10:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
While Jolt transforms are not something NiFi specific and not something I am strong with myself, you may find these links helpful to you:
https://intercom.help/godigibee/en/articles/3096940-simple-if-else-with-jolt
https://community.cloudera.com/t5/Community-Articles/Jolt-quick-reference-for-Nifi-Jolt-Processors/t...
Hope this helps,
Matt
