Filtering on ACL's - Do not get the expected result

These are my documents:

$ curl -XPUT 'http://localhost:9200/test/item/1' -d '{
"title" : "item 1",
"securitylevels" : [
{"usergroupcontentaccess" : [1,1,100]}
]
}'

$ curl -XPUT 'http://localhost:9200/test/item/2' -d '{
"title" : "item 2",
"securitylevels" : [
{ "usergroupcontentaccess" : [1,1,0] },
{ "usergroupcontentaccess" : [2,1,100] }
]
}'

Which says:
On item 1
group 1 has accesstype 1 and accesslevel 100

Which means that somebody in group 1 can view the item

and

On item 2
group 1 has accesstype 1 and accesslevel 0
group 2 has accesstype 1 and accesslevel 100

Which means that somebody in group 1 can not view the item and somebody
in group 2 can.

Now I like to query all the items someone in group 1 is allowed to view:

$ curl -XPOST 'http://localhost:9200/test/_search' -d '{
"query" : {
"filtered" : {
"query" : { "match_all" : {} },
"filter" : {
"terms" : { "securitylevels.usergroupcontentaccess" : [1,1,100],
"execution" : "and" }
}
}
}
}'

I expect only one result, e.g. item 1, but I get both.

Another approach:

$ curl -XPOST 'http://localhost:9200/test/_search' -d '{
"query" : {
"terms" : { "securitylevels.usergroupcontentaccess" : [1,1,100],
"minimum_match" : "3" }
}
}'

Gives me also both records.

What do I miss? I'm using ES 0.9.0RC2

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Erwin,

You need to use the nested field type for the field 'securitylevels':

This allows ES to respect the inner object structure in your documents. If
the nested type isn't used the document structure is completely flatend and
then at search time all usergroupcontentaccess values are just associated
to your root document, which results in 2 hits.

If you use the nested type, you also need to use the nested filter in your
case:

Martijn

On 18 April 2013 11:15, Erwin Rijss erijss@gmail.com wrote:

These are my documents:

$ curl -XPUT 'http://localhost:9200/test/item/1' -d '{
"title" : "item 1",
"securitylevels" : [
{"usergroupcontentaccess" : [1,1,100]}
]
}'

$ curl -XPUT 'http://localhost:9200/test/item/2' -d '{
"title" : "item 2",
"securitylevels" : [
{ "usergroupcontentaccess" : [1,1,0] },
{ "usergroupcontentaccess" : [2,1,100] }
]
}'

Which says:
On item 1
group 1 has accesstype 1 and accesslevel 100

Which means that somebody in group 1 can view the item

and

On item 2
group 1 has accesstype 1 and accesslevel 0
group 2 has accesstype 1 and accesslevel 100

Which means that somebody in group 1 can not view the item and somebody
in group 2 can.

Now I like to query all the items someone in group 1 is allowed to view:

$ curl -XPOST 'http://localhost:9200/test/_search' -d '{
"query" : {
"filtered" : {
"query" : { "match_all" : {} },
"filter" : {
"terms" : { "securitylevels.usergroupcontentaccess" : [1,1,100],
"execution" : "and" }
}
}
}
}'

I expect only one result, e.g. item 1, but I get both.

Another approach:

$ curl -XPOST 'http://localhost:9200/test/_search' -d '{
"query" : {
"terms" : { "securitylevels.usergroupcontentaccess" : [1,1,100],
"minimum_match" : "3" }
}
}'

Gives me also both records.

What do I miss? I'm using ES 0.9.0RC2

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Met vriendelijke groet,

Martijn van Groningen

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Thnx!

On Thursday, April 18, 2013 1:10:03 PM UTC+2, Martijn v Groningen wrote:

Hi Erwin,

You need to use the nested field type for the field 'securitylevels':
Elasticsearch Platform — Find real-time answers at scale | Elastic

This allows ES to respect the inner object structure in your documents. If
the nested type isn't used the document structure is completely flatend and
then at search time all usergroupcontentaccess values are just associated
to your root document, which results in 2 hits.

If you use the nested type, you also need to use the nested filter in your
case:
Elasticsearch Platform — Find real-time answers at scale | Elastic

Martijn

On 18 April 2013 11:15, Erwin Rijss <eri...@gmail.com <javascript:>>wrote:

These are my documents:

$ curl -XPUT 'http://localhost:9200/test/item/1' -d '{
"title" : "item 1",
"securitylevels" : [
{"usergroupcontentaccess" : [1,1,100]}
]
}'

$ curl -XPUT 'http://localhost:9200/test/item/2' -d '{
"title" : "item 2",
"securitylevels" : [
{ "usergroupcontentaccess" : [1,1,0] },
{ "usergroupcontentaccess" : [2,1,100] }
]
}'

Which says:
On item 1
group 1 has accesstype 1 and accesslevel 100

Which means that somebody in group 1 can view the item

and

On item 2
group 1 has accesstype 1 and accesslevel 0
group 2 has accesstype 1 and accesslevel 100

Which means that somebody in group 1 can not view the item and
somebody in group 2 can.

Now I like to query all the items someone in group 1 is allowed to view:

$ curl -XPOST 'http://localhost:9200/test/_search' -d '{
"query" : {
"filtered" : {
"query" : { "match_all" : {} },
"filter" : {
"terms" : { "securitylevels.usergroupcontentaccess" : [1,1,100],
"execution" : "and" }
}
}
}
}'

I expect only one result, e.g. item 1, but I get both.

Another approach:

$ curl -XPOST 'http://localhost:9200/test/_search' -d '{
"query" : {
"terms" : { "securitylevels.usergroupcontentaccess" : [1,1,100],
"minimum_match" : "3" }
}
}'

Gives me also both records.

What do I miss? I'm using ES 0.9.0RC2

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
Met vriendelijke groet,

Martijn van Groningen

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.