Class ApiKeyBoolQueryBuilder

All Implemented Interfaces:
NamedWriteable, VersionedNamedWriteable, Writeable, QueryBuilder, Rewriteable<QueryBuilder>, org.elasticsearch.xcontent.ToXContent, org.elasticsearch.xcontent.ToXContentObject

public final class ApiKeyBoolQueryBuilder extends BoolQueryBuilder
  • Method Details

    • build

      public static ApiKeyBoolQueryBuilder build(QueryBuilder queryBuilder, Consumer<String> fieldNameVisitor, @Nullable Authentication authentication)
      Build a bool query that is specialised for query API keys information from the security index. The method processes the given QueryBuilder to ensure: * Only fields from an allowlist are queried * Only query types from an allowlist are used * Field names used in the Query DSL get translated into corresponding names used at the index level. This helps decouple the user facing and implementation level changes. * User's security context gets applied when necessary * Not exposing any other types of documents stored in the same security index
      Parameters:
      queryBuilder - This represents the query parsed directly from the user input. It is validated and transformed (see above).
      fieldNameVisitor - This Consumer is invoked with all the (index-level) field names referred to in the passed-in query.
      authentication - The user's authentication object. If present, it will be used to filter the results to only include API keys owned by the user.
      Returns:
      A specialised query builder for API keys that is safe to run on the security index.
    • doToQuery

      protected org.apache.lucene.search.Query doToQuery(SearchExecutionContext context) throws IOException
      Overrides:
      doToQuery in class BoolQueryBuilder
      Throws:
      IOException
    • doRewrite

      protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws IOException
      Overrides:
      doRewrite in class BoolQueryBuilder
      Throws:
      IOException