How to implement custom security results trimming as plugin

Hello, Elastic community!

I need to implement trimming for any query results according to some logic. Ideally, it would be great to have some integration point in Elasticsearch using plugin which will be called for each item in query result where we can check is it allowed to return the item or not based on some document Id ('Id' field).

Something like this

foreach(item in queryResult)
{
    var id = item.getField("Id')
    if (CanUserViewThisDocument(id))
    {
         AddToQueryResult(item)
    }
}

CanUserViewThisDocument function suppose to be quite fast.

One way implement results trimming is to express trimming rule as a Query and use BitSet operations on initial query results (like here https://stackoverflow.com/a/41034500). Unfortunately, it's not possible to express the trimming rule as Query or List of Ids.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.