Class QueryRewriteContext

java.lang.Object
org.elasticsearch.index.query.QueryRewriteContext
Direct Known Subclasses:
QueryShardContext

public class QueryRewriteContext
extends java.lang.Object
Context object used to rewrite QueryBuilder instances into simplified version.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected Client client  
    protected java.util.function.LongSupplier nowInMillis  
  • Constructor Summary

    Constructors 
    Constructor Description
    QueryRewriteContext​(org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry, NamedWriteableRegistry writeableRegistry, Client client, java.util.function.LongSupplier nowInMillis)  
  • Method Summary

    Modifier and Type Method Description
    QueryShardContext convertToShardContext()
    Returns an instance of QueryShardContext if available of null otherwise
    void executeAsyncActions​(ActionListener listener)
    Executes all registered async actions and notifies the listener once it's done.
    NamedWriteableRegistry getWriteableRegistry()  
    org.elasticsearch.common.xcontent.NamedXContentRegistry getXContentRegistry()
    The registry used to build new XContentParsers.
    boolean hasAsyncActions()
    Returns true if there are any registered async actions.
    long nowInMillis()
    Returns the time in milliseconds that is shared across all resources involved.
    void registerAsyncAction​(java.util.function.BiConsumer<Client,​ActionListener<?>> asyncAction)
    Registers an async action that must be executed before the next rewrite round in order to make progress.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • getXContentRegistry

      public org.elasticsearch.common.xcontent.NamedXContentRegistry getXContentRegistry()
      The registry used to build new XContentParsers. Contains registered named parsers needed to parse the query.
    • nowInMillis

      public long nowInMillis()
      Returns the time in milliseconds that is shared across all resources involved. Even across shards and nodes.
    • getWriteableRegistry

      public NamedWriteableRegistry getWriteableRegistry()
    • convertToShardContext

      public QueryShardContext convertToShardContext()
      Returns an instance of QueryShardContext if available of null otherwise
    • registerAsyncAction

      public void registerAsyncAction​(java.util.function.BiConsumer<Client,​ActionListener<?>> asyncAction)
      Registers an async action that must be executed before the next rewrite round in order to make progress. This should be used if a rewriteabel needs to fetch some external resources in order to be executed ie. a document from an index.
    • hasAsyncActions

      public boolean hasAsyncActions()
      Returns true if there are any registered async actions.
    • executeAsyncActions

      public void executeAsyncActions​(ActionListener listener)
      Executes all registered async actions and notifies the listener once it's done. The value that is passed to the listener is always null. The list of registered actions is cleared once this method returns.