How to search on 2 sets in aerospike database using java?

Suppose I have 2 sets i.e. set 1 and set 2 where common bin is ‘userid’

I want to get intersection of userid in both sets. How to achieve this in java?

Are you looking for existence of userid bin or where userid is within a range or userid equals some value?

Is userid a string or integer?

If userid is an integer, you can create a secondary index on userid and query with a range filter.

Lets say there are 2 sets

set 1: userid (int) name (string) …

set 2: userid (int) address (string) …

how can I search for userid which is present in both the sets?

for example user ID 5 is present in both the sets, how can I search for the same?

Scan set1 and store userids as key in hashmap. Scan set2 and lookup userid in hashmap.