Class ApiKeyBoolQueryBuilder

java.lang.Object
org.elasticsearch.index.query.AbstractQueryBuilder<org.elasticsearch.index.query.BoolQueryBuilder>
org.elasticsearch.index.query.BoolQueryBuilder
org.elasticsearch.xpack.security.support.ApiKeyBoolQueryBuilder
All Implemented Interfaces:
org.elasticsearch.common.io.stream.NamedWriteable, org.elasticsearch.common.io.stream.VersionedNamedWriteable, org.elasticsearch.common.io.stream.Writeable, org.elasticsearch.index.query.QueryBuilder, org.elasticsearch.index.query.Rewriteable<org.elasticsearch.index.query.QueryBuilder>, org.elasticsearch.xcontent.ToXContent, org.elasticsearch.xcontent.ToXContentObject

public class ApiKeyBoolQueryBuilder extends org.elasticsearch.index.query.BoolQueryBuilder
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent

    org.elasticsearch.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.xcontent.ToXContent.MapParams, org.elasticsearch.xcontent.ToXContent.Params

    Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable

    org.elasticsearch.common.io.stream.Writeable.Reader<V extends Object>, org.elasticsearch.common.io.stream.Writeable.Writer<V extends Object>
  • Field Summary

    Fields inherited from class org.elasticsearch.index.query.BoolQueryBuilder

    ADJUST_PURE_NEGATIVE_DEFAULT, NAME

    Fields inherited from class org.elasticsearch.index.query.AbstractQueryBuilder

    boost, BOOST_FIELD, DEFAULT_BOOST, NAME_FIELD, queryName

    Fields inherited from interface org.elasticsearch.index.query.Rewriteable

    MAX_REWRITE_ROUNDS

    Fields inherited from interface org.elasticsearch.xcontent.ToXContent

    EMPTY_PARAMS
  • Method Summary

    Modifier and Type
    Method
    Description
    build(org.elasticsearch.index.query.QueryBuilder queryBuilder, org.elasticsearch.xpack.core.security.authc.Authentication authentication)
    Build a bool query that is specialised for query API keys information from the security index.
    protected org.elasticsearch.index.query.QueryBuilder
    doRewrite(org.elasticsearch.index.query.QueryRewriteContext queryRewriteContext)
     
    protected org.apache.lucene.search.Query
    doToQuery(org.elasticsearch.index.query.SearchExecutionContext context)
     

    Methods inherited from class org.elasticsearch.index.query.BoolQueryBuilder

    adjustPureNegative, adjustPureNegative, doEquals, doHashCode, doWriteTo, doXContent, extractInnerHitBuilders, filter, filter, fromXContent, getWriteableName, hasClauses, minimumShouldMatch, minimumShouldMatch, minimumShouldMatch, must, must, mustNot, mustNot, setMaxNestedDepth, should, should

    Methods inherited from class org.elasticsearch.index.query.AbstractQueryBuilder

    addValidationError, boost, boost, checkNegativeBoost, declareStandardFields, equals, getName, hashCode, parseInnerQueryBuilder, parseInnerQueryBuilder, printBoostAndQueryName, queryName, queryName, requireValue, rewrite, throwParsingExceptionOnMultipleFields, toQuery, toString, toXContent, writeTo

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.elasticsearch.index.query.QueryBuilder

    getMinimalSupportedVersion

    Methods inherited from interface org.elasticsearch.xcontent.ToXContentObject

    isFragment
  • Method Details

    • build

      public static ApiKeyBoolQueryBuilder build(org.elasticsearch.index.query.QueryBuilder queryBuilder, @Nullable org.elasticsearch.xpack.core.security.authc.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).
      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(org.elasticsearch.index.query.SearchExecutionContext context) throws IOException
      Overrides:
      doToQuery in class org.elasticsearch.index.query.BoolQueryBuilder
      Throws:
      IOException
    • doRewrite

      protected org.elasticsearch.index.query.QueryBuilder doRewrite(org.elasticsearch.index.query.QueryRewriteContext queryRewriteContext) throws IOException
      Overrides:
      doRewrite in class org.elasticsearch.index.query.BoolQueryBuilder
      Throws:
      IOException