DLS optimization for rewrite to match all #80904
Labels
>enhancement
:Security/Authorization
Roles, Privileges, DLS/FLS, RBAC/ABAC
Team:Security
Meta label for security team
A possible way to limit users from searching cold or frozen tiers is to setup DLS with a terms query for the
_tier
field. If an index does not match the requested_tier
, rewriting the query to the shard results in aMatchNoDocsQuery
, which is handled well by DLS, caching only that the index is unavailable. However, if the role does not contain any other query parts than for the_tier
field, the rewrite will result in aMatchAllDocsQuery
. There is an optimization for this case too, but it does not kick in until after the query ran populating a bitset of all the documents in the shard. Instead we can optimize this by checking if the rewritten role query becomesMatchAllDocsQuery
and use the specialmatch_all
bitset directly in this case. This would hopefully nearly eliminate the shard level overhead of having a role query with only a_tier
predicate. There is room for further improvements, but we can consider those outside this issue.The text was updated successfully, but these errors were encountered: