The LookupActor
is a Coral Actor that can enrich data via the lookup table provided in its constructor.
The LookupActor has "type": "lookup"
. The params
value contains the following fields:
field | type | required | description |
---|---|---|---|
key |
string | yes | name of the key field |
lookup |
JSON object | yes | the lookup table |
function |
string | yes | enrich , filter or map |
match |
string | no | exact or startswith |
default |
JSON object | no | when there is no match, the default is used when defined |
The function
field in the constructor defines the behavior of the LookupActor
.
This LookUpActor
will now wait for any incoming trigger messages and will look at the “city” field.
It will merge the “country” and “population” fields into the output message since “function” is set to “enrich”.
If this is the input:
Then enrich
will emit this output:
If the function is set to filter
, the output is
but only if the “city” key is found in the lookup map. If it is not found, the input object is not emitted.
In the case of map
, the output is the looked up object if it exists, else, nothing is emitted:
The standard behaviour is to use an exact match. When match
is set to “startswith”, a check is done if the key is a string of which a substring occurs in the lookup map. If there are multiple matches, one of them is used, which one is undefined.
The standard behaviour when there is no match is to do nothing: for check and filter nothing is emitted, for enrich nothing will be added to the output. When a default is given, this is used when there are no matches, so check and filter emit the default and enrich enriches with the default. The default is a template like used by the JsonActor.
The LookupActor
accepts any JSON as trigger.
The function
of the LookupActor
determines what is emitted.
enrich
always emits the original JSON object. If lookup values are found, these are added to the original JSON object.filter
emits the unenriched, original JSON when it is found in the lookup table. If it is not found, nothing is emitted.check
emits the lookup value when it is found, otherwise, nothing is emitted.The LookupActor
does not keep state.
The LookupActor
does not collect state from other actors.
The LookupActor
does not provide timer actions.