Package org.elasticsearch.index.query
Class QueryRewriteContext
- java.lang.Object
-
- org.elasticsearch.index.query.QueryRewriteContext
-
- Direct Known Subclasses:
QueryShardContext
public class QueryRewriteContext extends java.lang.ObjectContext object used to rewriteQueryBuilderinstances into simplified version.
-
-
Field Summary
Fields Modifier and Type Field Description protected Clientclientprotected java.util.function.LongSuppliernowInMillis
-
Constructor Summary
Constructors Constructor Description QueryRewriteContext(NamedXContentRegistry xContentRegistry, NamedWriteableRegistry writeableRegistry, Client client, java.util.function.LongSupplier nowInMillis)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanconvertNowRangeToMatchAll()In pre-processing contexts that happen at index time 'now' date ranges should be replaced by aMatchAllQueryBuilder.QueryShardContextconvertToShardContext()Returns an instance ofQueryShardContextif available of null otherwisevoidexecuteAsyncActions(ActionListener listener)Executes all registered async actions and notifies the listener once it's done.NamedWriteableRegistrygetWriteableRegistry()NamedXContentRegistrygetXContentRegistry()The registry used to build newXContentParsers.booleanhasAsyncActions()Returnstrueif there are any registered async actions.longnowInMillis()Returns the time in milliseconds that is shared across all resources involved.voidregisterAsyncAction(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.
-
-
-
Field Detail
-
client
protected final Client client
-
nowInMillis
protected final java.util.function.LongSupplier nowInMillis
-
-
Constructor Detail
-
QueryRewriteContext
public QueryRewriteContext(NamedXContentRegistry xContentRegistry, NamedWriteableRegistry writeableRegistry, Client client, java.util.function.LongSupplier nowInMillis)
-
-
Method Detail
-
getXContentRegistry
public NamedXContentRegistry getXContentRegistry()
The registry used to build newXContentParsers. 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 ofQueryShardContextif 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()
Returnstrueif 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 alwaysnull. The list of registered actions is cleared once this method returns.
-
convertNowRangeToMatchAll
public boolean convertNowRangeToMatchAll()
In pre-processing contexts that happen at index time 'now' date ranges should be replaced by aMatchAllQueryBuilder. Otherwise documents that should match at query time would never match and the document that have fallen outside the date range would continue to match.- Returns:
- indicates whether range queries with date ranges using 'now' are rewritten to a
MatchAllQueryBuilder.
-
-