I have a use case where I need to restrict access to documents in an Elasticsearch index based on the user executing the query and one of the attributes in the document. The catch is that this is dynamic and the logic to determine if a user can see a specific document is a bit convoluted and based on data in an external database. Conceptually it would be nice if I could have a dynamic filter (e.g. plugin) configured in Elasticsearch that would take as input the connected user and the document (or a subset of its fields) and return a boolean indicating whether the document should be returned to the user.
Does such a solution exist in Elasticsearch or any third party products?