I have in aerospike db a record like this:
| MAP(‘{“unknown_tcs2-spsv-me-diameterapp-0_20240611111830111_16270”:{“deviceName”:”unknown_tcs2-spsv-me-diameterapp-0_20240611111830111_16270″, “allowOverage”:0, “pwdEncrypted”:0, “e164”:[“393401234567”], “creationTime”:1718097510112, “ldapsearch”:0, “dev |
that I receive as result of the following query: select devices from spspd1.InfrequentlyChangingData. I need a lua file in order to find in all results the record with specific e164. Some one have an idea?
Regards,
R.
I tried with this lua filter:
— Lua function to filter records based on e164 value
local function filter_by_e164(rec, e164_value)
local devices = rec[‘devices’]
if devices ~= nil then
aerospike:log(aerospike.INFO, “DEBUG: Devices found in record: ” .. tostring(devices))
-- Function to find e164 value in a list
local function findE164(e164_list, e164_value)
aerospike:log(aerospike.INFO, "DEBUG: Searching for e164 value: " .. e164_value)
for idx, e164 in ipairs(e164_list) do
aerospike:log(aerospike.INFO, "DEBUG: Checking e164 value: " .. tostring(e164))
if e164 == e164_value then
aerospike:log(aerospike.INFO, "DEBUG: Found e164 value in device: " .. tostring(e164))
return true
end
end
return false
end
-- Iterate over devices
for key, device in map.pairs(devices) do
aerospike:log(aerospike.INFO, "DEBUG: Processing device: " .. tostring(device))
if device['e164'] ~= nil and type(device['e164']) == "table" then
if findE164(device['e164'], e164_value) then
aerospike:log(aerospike.INFO, "DEBUG: Match found for device: " .. tostring(device))
return true
end
end
end
end
return false
end
function filter_devices(stream, e164_value)
local function filter(rec)
return filter_by_e164(rec, e164_value)
end
return stream : filter(filter)
end
: filter(filter)
end
executing it in this way:
AGGREGATE filter_by_e164.filter_devices(‘393481234567’) ON spspd1.InfrequentlyChangingData
Roberto Brigantino is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.