Aerospike Query使用Bin1 == Bin2读取所有logging
我有一个nodejs和aerospike设置。 我想知道如何运行一个查询Bin1 == Bin2
。
在SQL中
SELECT * FROM [test]t where t.EmployeeId == t.shipperid
可以这样做吗? 我总是可以查询test
集中的所有值,并在nodejs中对其进行过滤。 不过,我认为这将是非常低效的。 请让我知道是否有一个aerospike的方式来做到这一点?
您可以创build一个额外的bin, "equal_ids"
,当ID相等时设置为true。 这个bin是有一个二级索引。 然后,您可以为equal_ids==true
进行二级索引查询
这不是通过现有的查询谓词支持的,但是您可以将其表示为streamUDF 。
local function bin_match_filter(bin1, bin2) return function(rec) if rec[bin1] and rec[bin2] and (type(rec[bin1]) == type(rec[bin2])) and rec[bin1] == rec[bin2] 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 check_bins_match(stream, bin1, bin2) return stream : filter(bin_match_filter(bin1, bin2)) : map(map_record) end
您现在可以运行由辅助索引查询匹配的logging,或者通过此streamUDF进行扫描。