diff options
author | Adrien Grand <jpountz@gmail.com> | 2016-11-02 09:48:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-02 09:48:49 +0100 |
commit | aa6cd93e0f860faf869e46386beea3836f635816 (patch) | |
tree | 933aff6cb175c172f7276523220cd5fdb83349c3 /core/src/main/java/org/elasticsearch/index/query/QueryRewriteContext.java | |
parent | 51717c882f23a5a5d3fae1a23477b29b4079ca4d (diff) |
Require arguments for QueryShardContext creation. (#21196)
The `IndexService#newQueryShardContext()` method creates a QueryShardContext on
shard `0`, with a `null` reader and that uses `System.currentTimeMillis()` to
resolve `now`. This may hide bugs, since the shard id is sometimes used for
query parsing (it is used to salt random score generation in `function_score`),
passing a `null` reader disables query rewriting and for some use-cases, it is
simply not ok to rely on the current timestamp (eg. percolation). So this pull
request removes this method and instead requires that all call sites provide
these parameters explicitly.
Diffstat (limited to 'core/src/main/java/org/elasticsearch/index/query/QueryRewriteContext.java')
-rw-r--r-- | core/src/main/java/org/elasticsearch/index/query/QueryRewriteContext.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/core/src/main/java/org/elasticsearch/index/query/QueryRewriteContext.java b/core/src/main/java/org/elasticsearch/index/query/QueryRewriteContext.java index ccca0af652..c8b5cf174f 100644 --- a/core/src/main/java/org/elasticsearch/index/query/QueryRewriteContext.java +++ b/core/src/main/java/org/elasticsearch/index/query/QueryRewriteContext.java @@ -86,7 +86,9 @@ public class QueryRewriteContext implements ParseFieldMatcherSupplier { return mapperService; } - /** Return the current {@link IndexReader}, or {@code null} if we are on the coordinating node. */ + /** Return the current {@link IndexReader}, or {@code null} if no index reader is available, for + * instance if we are on the coordinating node or if this rewrite context is used to index + * queries (percolation). */ public IndexReader getIndexReader() { return reader; } |