Yes, it is possible but you need to use a stream UDF for the second/third/… WHERE-clause. You can choose the most selective condition as your WHERE and implement any further filtering through server-side UDFs.
You would first query for records where from = val1 and apply the following stream UDF on the matched records
local function from_to_filter(val1, val2)
return function(rec)
if (rec['from'] == val1 and rec['to'] == val2) or
(rec['from'] == val2 and rec['to'] == val1) then
return true
end
return false
end
end
local function map_record(rec)
local ret = map()
for i, bin_name in ipairs(record.bin_names(rec)) do
ret[bin_name] = rec[bin_name]
end
return ret
end
function from_to_match(stream, val1, val2)
return stream : filter(from_to_filter(val1, val2)) : map(map_record)
end