Thanks Mikhail.
I realize that the example is not exactly what I'm looking for. Let me try it this way: let's say each document has 0 to 5 locks:
00000 -- no lock, anyone can access this document.
10000 -- user with key 1 can access this document.
10010 -- user with keys 1 and 4 to access this document.
In search query, I'd like to use the user's keys to filter search results: user with key "10000" can access 1st and 2nd documents. User with "01111" can only access 1st document.
In real world problem, I may need to define 200 locks for all documents. What I'm looking for is long bitwise operation in Elastic.
Thanks for reading it.