Lookup Map
Overview
Lookup map allows attaching/replacing the values of object properties according to predefined values in a predefined lookup array.
A good example for this would be when you have an policy type Id and to give it a meaning it is possible using Lookup Map to attach (or replace) the id with more meaningful title.
Example input
{
"policy": {
"policyTypeId": 23
},
"reference": [{ "policyTypeId": 23, "title": "Car Insurance" }]
}
Example result
{
"doc": {
"policy": {
"policyTypeId": 23,
"policyType": "Car Insurance"
},
"reference": [
{
"policyTypeId": 23,
"title": "Car Insurance"
}
]
},
"errors": []
}
Here after running the flow we have attached the policyType title from the reference lookup array to the policy to make the returned data more meaningful to consumers of the API.
Configuration
Lookup map definitions (maps)
Target path (maps[].targetPath)- node in thedoccontext where to place the resolved value.Search by path (maps[].searchByPathValue)- node in thedoc, from which to take value that will be matched against the value in lookup value arraySearch by value (maps[].searchByValue)- value to be searched as key in lookup (required ifSearch by pathis not defined).
Lookup properties (maps[].lookup)
Source Path (maps[].lookup.sourcePath)- node indoccontext where the lookup array is locatedSource Lookup (maps[].lookup.sourceLookup)- array of lookup values (ifSource Pathis not provided it is possible to manually provide these values)Lookup Key Path (maps[].lookup.lookupKeyPath)- path inside the lookup array item to which the value will be compared against (if this value is equal toSearch by pathvalue then the lookup array item will be matched)Lookup Value path (maps[].lookup.lookupValuePath)- path inside the lookup array item from which to take value to place in original object (inTarget pathconfigured inLookup map definitions)
Example
Flow input
{
"policy": {
"policyTypeId": 23
},
"reference": [
{
"policyTypeId": 23,
"title": "Car Insurance"
}
]
}
Step configuration
steps:
- stepType: lookup
config:
maps:
- lookup:
sourcePath: reference
lookupKeyPath: policyTypeId
lookupValuePath: title
targetPath: policy.policyType
searchByPathValue: policy.policyTypeId
name: Lookup Map
description: ""
condition: ""
Example flow
tags: []
steps:
- stepType: lookup
config:
maps:
- lookup:
sourcePath: reference
lookupKeyPath: policyTypeId
lookupValuePath: title
targetPath: policy.policyType
searchByPathValue: policy.policyTypeId
name: Lookup Map
description: ""
condition: ""
sampleData:
policy:
policyTypeId: 23
reference:
- policyTypeId: 23
title: Car Insurance