Hi Shay,
First of all thank you for elasticsearch.
Is there a way where I can use bitwise operator on integer field to
filter a search query based on group membership where each group is
assigned to a bit in an integer field.
Say a index with the following type is created:
curl -XPUT 'http://localhost:9200/testindex/restricteddocument/1' -d
'{ "name" : "document A",
"title" : "testing Elastic Search access
control",
"groupmembership": 25}'
curl -XPUT 'http://localhost:9200/testindex/restricteddocument/2' -d
'{ "name" : "document B",
"title" : "testing Elastic Search access
control",
"groupmembership": 19}'
curl -XPUT 'http://localhost:9200/testindex/restricteddocument/3' -d
'{ "name" : "document C",
"title" : "testing Elastic Search access
control",
"groupmembership": 11}'
Hence the Group membership of each document would be:
document A = 0000 0000 0001 1001
document B = 0000 0000 0001 0011
document C = 0000 0000 0000 1011
And the following users and their groupmembership are:
"user 01" has the following groupmembership: 0000 ... 0000 0000
0001 (ie int 1)
"user 02" has the following groupmembership: 0000 ... 0000 0000
1000 (ie int 8)
"user 03" has the following groupmembership: 0000 ... 0000 0001
0000 (ie int 16)
"user 04" has the following groupmembership: 0000 ... 0000 0000
0010 (ie int 2)
Is there way to use an integer bitwise filter in elasticsearch where I
can make query that returned
specific documents according to users groupmembership.
example:
query made by using "user 01" groupmembership bitwise filter would
return
document A, document B, and document C
query made by using "user 02" groupmembership bitwise filter would
return
document A, document C
query made by using "user 03" groupmembership bitwise filter would
return
document A, document B
query made by using "user 04" groupmembership bitwise filter would
return
document B, document C
I know that lucene has extension to do this, but I am not sure how I
can do this on elasticsearch.
I know that I could create a proxy wrapper to this. However it would
not be very efficient, as the query itself would have to return all
document matching other filter rules. In addition it would not work
well for query with "size" and "from" restriction. For example I would
not be able to create query which get the first five document for
"user 02" in a single query.
Is there a better way to do this, or should I be using the faceting
facility to solve this issue?
Many Thanks for your help.