summaryrefslogtreecommitdiff
path: root/core/src/test/java/org/elasticsearch/search/rescore/QueryRescoreBuilderTests.java
diff options
context:
space:
mode:
authorSimon Willnauer <simonw@apache.org>2016-02-11 10:45:49 +0100
committerSimon Willnauer <simonw@apache.org>2016-02-11 10:45:49 +0100
commit8bdc7362a61eaf984f5e279d98033a7a5c7970ef (patch)
tree346fffb931d459bf44d7ecf621b72fc77e173fd8 /core/src/test/java/org/elasticsearch/search/rescore/QueryRescoreBuilderTests.java
parentebcbe5d4c58c7c1f6a25356e670e94ccf1435e57 (diff)
Add infrastructure to rewrite query buidlers
QueryBuilders today do all their heavy lifting in toQuery() which can be too late for several operations. For instance if we want to fetch geo shapes on the coordinating node we need to do all this before we create the actual lucene query which happens on the shard itself. Also optimizations for request caching need to be done to the query builder rather than the query which then in-turn needs to be serialized again. This commit adds the basic infrastructure for query rewriting and moves the heavy lifting into the rewrite method for the following queries: * `WrapperQueryBuilder` * `GeoShapeQueryBuilder` * `TermsQueryBuilder` * `TemplateQueryBuilder` Other queries like `MoreLikeThisQueryBuilder` still need to be fixed / converted. The nice sideeffect of this is that queries like template queries will now also match the request cache if their non-template equivalent has been cached befoore. In the future this will allow to add optimizataion like rewriting time-based queries into primitives like `match_all_docs` or `match_no_docs` based on the currents shards bounds. This is especially appealing for indices that are read-only ie. never change.
Diffstat (limited to 'core/src/test/java/org/elasticsearch/search/rescore/QueryRescoreBuilderTests.java')
-rw-r--r--core/src/test/java/org/elasticsearch/search/rescore/QueryRescoreBuilderTests.java4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/src/test/java/org/elasticsearch/search/rescore/QueryRescoreBuilderTests.java b/core/src/test/java/org/elasticsearch/search/rescore/QueryRescoreBuilderTests.java
index 01f7e33244..37f81e3d33 100644
--- a/core/src/test/java/org/elasticsearch/search/rescore/QueryRescoreBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/search/rescore/QueryRescoreBuilderTests.java
@@ -160,7 +160,7 @@ public class QueryRescoreBuilderTests extends ESTestCase {
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build();
IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(randomAsciiOfLengthBetween(1, 10), indexSettings);
// shard context will only need indicesQueriesRegistry for building Query objects nested in query rescorer
- QueryShardContext mockShardContext = new QueryShardContext(idxSettings, null, null, null, null, null, null, indicesQueriesRegistry) {
+ QueryShardContext mockShardContext = new QueryShardContext(idxSettings, null, null, null, null, null, indicesQueriesRegistry) {
@Override
public MappedFieldType fieldMapper(String name) {
StringFieldMapper.Builder builder = MapperBuilders.stringField(name);
@@ -170,7 +170,7 @@ public class QueryRescoreBuilderTests extends ESTestCase {
for (int runs = 0; runs < NUMBER_OF_TESTBUILDERS; runs++) {
RescoreBuilder<?> rescoreBuilder = randomRescoreBuilder();
- QueryRescoreContext rescoreContext = (QueryRescoreContext) rescoreBuilder.build(mockShardContext);
+ QueryRescoreContext rescoreContext = rescoreBuilder.build(mockShardContext);
XContentParser parser = createParser(rescoreBuilder);
QueryRescoreContext parsedRescoreContext = (QueryRescoreContext) new RescoreParseElement().parseSingleRescoreContext(parser, mockShardContext);