From 7a209cc600ed5ad4c4dd78e00f98eaee346c00f7 Mon Sep 17 00:00:00 2001 From: Colin Goodheart-Smithe Date: Wed, 23 Sep 2015 20:52:44 +0100 Subject: [PATCH] more test fixes --- .../index/query/IdsQueryBuilder.java | 11 ++++++-- .../elasticsearch/search/SearchService.java | 1 + .../search/fetch/FetchSubPhaseContext.java | 2 +- .../query/plugin/DummyQueryParserPlugin.java | 28 ++++++++++++++++++- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/index/query/IdsQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/IdsQueryBuilder.java index b85db4b66b1..1c3b912885e 100644 --- a/core/src/main/java/org/elasticsearch/index/query/IdsQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/IdsQueryBuilder.java @@ -31,7 +31,12 @@ import org.elasticsearch.index.mapper.Uid; import org.elasticsearch.index.mapper.internal.UidFieldMapper; import java.io.IOException; -import java.util.*; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; /** * A query that will return only documents matching specific ids (and a type). @@ -144,14 +149,14 @@ public class IdsQueryBuilder extends AbstractQueryBuilder { @Override protected IdsQueryBuilder doReadFrom(StreamInput in) throws IOException { - IdsQueryBuilder idsQueryBuilder = new IdsQueryBuilder(in.readStringArray()); + IdsQueryBuilder idsQueryBuilder = new IdsQueryBuilder(in.readOptionalStringArray()); idsQueryBuilder.addIds(in.readStringArray()); return idsQueryBuilder; } @Override protected void doWriteTo(StreamOutput out) throws IOException { - out.writeStringArray(types); + out.writeOptionalStringArray(types); out.writeStringArray(ids.toArray(new String[ids.size()])); } diff --git a/core/src/main/java/org/elasticsearch/search/SearchService.java b/core/src/main/java/org/elasticsearch/search/SearchService.java index 1e6dbd98575..1e3d15bb692 100644 --- a/core/src/main/java/org/elasticsearch/search/SearchService.java +++ b/core/src/main/java/org/elasticsearch/search/SearchService.java @@ -820,6 +820,7 @@ public class SearchService extends AbstractLifecycleComponent { for (String field : source.fieldDataFields()) { fieldDataFieldsContext.add(new FieldDataField(field)); } + fieldDataFieldsContext.setHitExecutionNeeded(true); } if (source.highlighter() != null) { XContentParser highlighterParser = null; diff --git a/core/src/main/java/org/elasticsearch/search/fetch/FetchSubPhaseContext.java b/core/src/main/java/org/elasticsearch/search/fetch/FetchSubPhaseContext.java index 237f43519fa..981408b1bdd 100644 --- a/core/src/main/java/org/elasticsearch/search/fetch/FetchSubPhaseContext.java +++ b/core/src/main/java/org/elasticsearch/search/fetch/FetchSubPhaseContext.java @@ -33,7 +33,7 @@ public class FetchSubPhaseContext { /** * Set if this phase should be executed at all. */ - void setHitExecutionNeeded(boolean hitExecutionNeeded) { + public void setHitExecutionNeeded(boolean hitExecutionNeeded) { this.hitExecutionNeeded = hitExecutionNeeded; } diff --git a/core/src/test/java/org/elasticsearch/index/query/plugin/DummyQueryParserPlugin.java b/core/src/test/java/org/elasticsearch/index/query/plugin/DummyQueryParserPlugin.java index 7f27ee1621c..beb5b723c62 100644 --- a/core/src/test/java/org/elasticsearch/index/query/plugin/DummyQueryParserPlugin.java +++ b/core/src/test/java/org/elasticsearch/index/query/plugin/DummyQueryParserPlugin.java @@ -23,9 +23,15 @@ import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; import org.apache.lucene.search.Weight; +import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.index.query.*; +import org.elasticsearch.index.query.AbstractQueryBuilder; +import org.elasticsearch.index.query.BaseQueryParser; +import org.elasticsearch.index.query.QueryBuilder; +import org.elasticsearch.index.query.QueryParseContext; +import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.indices.IndicesModule; import org.elasticsearch.plugins.Plugin; @@ -64,6 +70,26 @@ public class DummyQueryParserPlugin extends Plugin { public String getWriteableName() { return NAME; } + + @Override + protected DummyQueryBuilder doReadFrom(StreamInput in) throws IOException { + return new DummyQueryBuilder(); + } + + @Override + protected void doWriteTo(StreamOutput out) throws IOException { + // Do Nothing + } + + @Override + protected int doHashCode() { + return 0; + } + + @Override + protected boolean doEquals(DummyQueryBuilder other) { + return true; + } } public static class DummyQueryParser extends BaseQueryParser {