โ04-28-2022 06:07 AM
Hi,
I have a use case of lookup function where I have to use the same expression library but the lookup will happen both on the basis of key and value pair.
Below is the expression library that I have uploaded
{
โLookupโ: {
โKey1โ: โValue1โ,
โKey2โ: โValue2โ,
โKey3โ: โValue3โ,
โKey4โ:โValue4โ
}
}
Now I will get value1 from previous snaps, I want to use value1 to retrieve data as Key1.
Can you suggest how this can be achieved?
Regards,
Shreegeet
โ04-28-2022 09:49 AM
If i understood correctly, you want to get a value from the config file, based on an incoming field in the pipeline. If thatโs correct, try this:
lib.config.Lookup.get($field)
Where โconfigโ is the name of the ecpression library, and โ$fieldโ is the incoming field (value1 in your original post).
Bojan
โ04-28-2022 02:37 PM
If you want to use the incoming value(from previous snaps) in order to retrieve the object key, then you can use the following expession:
lib.config.Lookup.keys().find(k=>lib.config.Lookup[k]==$incoming_value)
BR,
Spiro Taleski