newMostAvaiableUsages) {
for (NodeStats nodeStats : nodeStatsArray) {
diff --git a/core/src/main/java/org/elasticsearch/cluster/health/ClusterHealthStatus.java b/core/src/main/java/org/elasticsearch/cluster/health/ClusterHealthStatus.java
index 6d3e136eb1a..a261d28f537 100644
--- a/core/src/main/java/org/elasticsearch/cluster/health/ClusterHealthStatus.java
+++ b/core/src/main/java/org/elasticsearch/cluster/health/ClusterHealthStatus.java
@@ -20,10 +20,16 @@
package org.elasticsearch.cluster.health;
+import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.io.stream.StreamOutput;
+import org.elasticsearch.common.io.stream.Writeable;
+
+import java.io.IOException;
+
/**
*
*/
-public enum ClusterHealthStatus {
+public enum ClusterHealthStatus implements Writeable {
GREEN((byte) 0),
YELLOW((byte) 1),
RED((byte) 2);
@@ -38,7 +44,21 @@ public enum ClusterHealthStatus {
return value;
}
- public static ClusterHealthStatus fromValue(byte value) {
+ @Override
+ public void writeTo(StreamOutput out) throws IOException {
+ out.writeByte(value);
+ }
+
+ /**
+ * Read from a stream.
+ *
+ * @throws IllegalArgumentException if the value is unrecognized
+ */
+ public static ClusterHealthStatus readFrom(StreamInput in) throws IOException {
+ return fromValue(in.readByte());
+ }
+
+ public static ClusterHealthStatus fromValue(byte value) throws IOException {
switch (value) {
case 0:
return GREEN;
diff --git a/core/src/main/java/org/elasticsearch/cluster/metadata/AliasValidator.java b/core/src/main/java/org/elasticsearch/cluster/metadata/AliasValidator.java
index 64da04e6511..735916504da 100644
--- a/core/src/main/java/org/elasticsearch/cluster/metadata/AliasValidator.java
+++ b/core/src/main/java/org/elasticsearch/cluster/metadata/AliasValidator.java
@@ -141,7 +141,7 @@ public class AliasValidator extends AbstractComponent {
private static void validateAliasFilter(XContentParser parser, QueryShardContext queryShardContext) throws IOException {
QueryParseContext queryParseContext = queryShardContext.newParseContext(parser);
- QueryBuilder> queryBuilder = QueryBuilder.rewriteQuery(queryParseContext.parseInnerQueryBuilder(), queryShardContext);
+ QueryBuilder queryBuilder = QueryBuilder.rewriteQuery(queryParseContext.parseInnerQueryBuilder(), queryShardContext);
queryBuilder.toFilter(queryShardContext);
}
}
diff --git a/core/src/main/java/org/elasticsearch/common/geo/GeoPoint.java b/core/src/main/java/org/elasticsearch/common/geo/GeoPoint.java
index 7713157422e..5d1250a5148 100644
--- a/core/src/main/java/org/elasticsearch/common/geo/GeoPoint.java
+++ b/core/src/main/java/org/elasticsearch/common/geo/GeoPoint.java
@@ -38,7 +38,7 @@ public final class GeoPoint {
}
/**
- * Create a new Geopointform a string. This String must either be a geohash
+ * Create a new Geopoint from a string. This String must either be a geohash
* or a lat-lon tuple.
*
* @param value String to create the point from
diff --git a/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java b/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java
index 8df43f687f6..ec56103e7a0 100644
--- a/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java
+++ b/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java
@@ -736,6 +736,29 @@ public abstract class StreamInput extends InputStream {
return null;
}
+ /**
+ * Read a {@link List} of {@link Streamable} objects, using the {@code constructor} to instantiate each instance.
+ *
+ * This is expected to take the form:
+ *
+ * List<MyStreamableClass> list = in.readStreamList(MyStreamableClass::new);
+ *
+ *
+ * @param constructor Streamable instance creator
+ * @return Never {@code null}.
+ * @throws IOException if any step fails
+ */
+ public List readStreamableList(Supplier constructor) throws IOException {
+ int count = readVInt();
+ List builder = new ArrayList<>(count);
+ for (int i=0; i list) throws IOException {
+ writeVInt(list.size());
+ for (Streamable obj: list) {
+ obj.writeTo(this);
+ }
+ }
+
/**
* Writes a list of {@link Writeable} objects
*/
- public void writeList(List list) throws IOException {
+ public void writeList(List extends Writeable> list) throws IOException {
writeVInt(list.size());
- for (T obj: list) {
+ for (Writeable obj: list) {
obj.writeTo(this);
}
}
diff --git a/core/src/main/java/org/elasticsearch/common/xcontent/XContentBuilder.java b/core/src/main/java/org/elasticsearch/common/xcontent/XContentBuilder.java
index 4367b15fd52..3fa182e3727 100644
--- a/core/src/main/java/org/elasticsearch/common/xcontent/XContentBuilder.java
+++ b/core/src/main/java/org/elasticsearch/common/xcontent/XContentBuilder.java
@@ -113,6 +113,10 @@ public final class XContentBuilder implements BytesStream, Releasable {
return this;
}
+ public boolean isPrettyPrint() {
+ return generator.isPrettyPrint();
+ }
+
public XContentBuilder lfAtEnd() {
generator.usePrintLineFeedAtEnd();
return this;
diff --git a/core/src/main/java/org/elasticsearch/common/xcontent/XContentGenerator.java b/core/src/main/java/org/elasticsearch/common/xcontent/XContentGenerator.java
index f23ae441989..a2cceae8367 100644
--- a/core/src/main/java/org/elasticsearch/common/xcontent/XContentGenerator.java
+++ b/core/src/main/java/org/elasticsearch/common/xcontent/XContentGenerator.java
@@ -20,7 +20,6 @@
package org.elasticsearch.common.xcontent;
import org.elasticsearch.common.bytes.BytesReference;
-
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
@@ -34,6 +33,8 @@ public interface XContentGenerator extends Closeable {
void usePrettyPrint();
+ boolean isPrettyPrint();
+
void usePrintLineFeedAtEnd();
void writeStartArray() throws IOException;
diff --git a/core/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContentGenerator.java b/core/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContentGenerator.java
index 4148148e507..e74ab01bd6a 100644
--- a/core/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContentGenerator.java
+++ b/core/src/main/java/org/elasticsearch/common/xcontent/json/JsonXContentGenerator.java
@@ -104,6 +104,11 @@ public class JsonXContentGenerator implements XContentGenerator {
prettyPrint = true;
}
+ @Override
+ public boolean isPrettyPrint() {
+ return this.prettyPrint;
+ }
+
@Override
public void usePrintLineFeedAtEnd() {
writeLineFeedAtEnd = true;
diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java b/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java
index cc37504360c..d200ca5b07b 100644
--- a/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java
+++ b/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java
@@ -402,7 +402,7 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen
// connect to the node, see if we manage to do it, if not, bail
if (!nodeFoundByAddress) {
logger.trace("[{}] connecting (light) to {}", sendPingsHandler.id(), finalNodeToSend);
- transportService.connectToNodeLight(finalNodeToSend, timeout.getMillis());
+ transportService.connectToNodeLightAndHandshake(finalNodeToSend, timeout.getMillis());
} else {
logger.trace("[{}] connecting to {}", sendPingsHandler.id(), finalNodeToSend);
transportService.connectToNode(finalNodeToSend);
diff --git a/core/src/main/java/org/elasticsearch/gateway/AsyncShardFetch.java b/core/src/main/java/org/elasticsearch/gateway/AsyncShardFetch.java
index cd6268d04ec..b74507a4acc 100644
--- a/core/src/main/java/org/elasticsearch/gateway/AsyncShardFetch.java
+++ b/core/src/main/java/org/elasticsearch/gateway/AsyncShardFetch.java
@@ -35,9 +35,11 @@ import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.transport.ReceiveTimeoutTransportException;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -57,24 +59,24 @@ public abstract class AsyncShardFetch implements Rel
/**
* An action that lists the relevant shard data that needs to be fetched.
*/
- public interface List, NodeResponse extends BaseNodeResponse> {
+ public interface Lister, NodeResponse extends BaseNodeResponse> {
void list(ShardId shardId, String[] nodesIds, ActionListener listener);
}
protected final ESLogger logger;
protected final String type;
private final ShardId shardId;
- private final List, T> action;
+ private final Lister, T> action;
private final Map> cache = new HashMap<>();
private final Set nodesToIgnore = new HashSet<>();
private boolean closed;
@SuppressWarnings("unchecked")
- protected AsyncShardFetch(ESLogger logger, String type, ShardId shardId, List extends BaseNodesResponse, T> action) {
+ protected AsyncShardFetch(ESLogger logger, String type, ShardId shardId, Lister extends BaseNodesResponse, T> action) {
this.logger = logger;
this.type = type;
this.shardId = shardId;
- this.action = (List, T>) action;
+ this.action = (Lister, T>) action;
}
@Override
@@ -167,7 +169,7 @@ public abstract class AsyncShardFetch implements Rel
* the shard (response + failures), issuing a reroute at the end of it to make sure there will be another round
* of allocations taking this new data into account.
*/
- protected synchronized void processAsyncFetch(ShardId shardId, T[] responses, FailedNodeException[] failures) {
+ protected synchronized void processAsyncFetch(ShardId shardId, List responses, List failures) {
if (closed) {
// we are closed, no need to process this async fetch at all
logger.trace("{} ignoring fetched [{}] results, already closed", shardId, type);
@@ -276,9 +278,9 @@ public abstract class AsyncShardFetch implements Rel
@Override
public void onFailure(Throwable e) {
- FailedNodeException[] failures = new FailedNodeException[nodesIds.length];
- for (int i = 0; i < failures.length; i++) {
- failures[i] = new FailedNodeException(nodesIds[i], "total failure in fetching", e);
+ List failures = new ArrayList<>(nodesIds.length);
+ for (String nodeId : nodesIds) {
+ failures.add(new FailedNodeException(nodeId, "total failure in fetching", e));
}
processAsyncFetch(shardId, null, failures);
}
diff --git a/core/src/main/java/org/elasticsearch/gateway/Gateway.java b/core/src/main/java/org/elasticsearch/gateway/Gateway.java
index 4da789b43fc..0e6b1959279 100644
--- a/core/src/main/java/org/elasticsearch/gateway/Gateway.java
+++ b/core/src/main/java/org/elasticsearch/gateway/Gateway.java
@@ -82,7 +82,7 @@ public class Gateway extends AbstractComponent implements ClusterStateListener {
int requiredAllocation = Math.max(1, minimumMasterNodesProvider.get());
- if (nodesState.failures().length > 0) {
+ if (nodesState.hasFailures()) {
for (FailedNodeException failedNodeException : nodesState.failures()) {
logger.warn("failed to fetch state from node", failedNodeException);
}
@@ -91,7 +91,7 @@ public class Gateway extends AbstractComponent implements ClusterStateListener {
ObjectFloatHashMap indices = new ObjectFloatHashMap<>();
MetaData electedGlobalState = null;
int found = 0;
- for (TransportNodesListGatewayMetaState.NodeGatewayMetaState nodeState : nodesState) {
+ for (TransportNodesListGatewayMetaState.NodeGatewayMetaState nodeState : nodesState.getNodes()) {
if (nodeState.metaData() == null) {
continue;
}
@@ -119,7 +119,7 @@ public class Gateway extends AbstractComponent implements ClusterStateListener {
Index index = (Index) keys[i];
IndexMetaData electedIndexMetaData = null;
int indexMetaDataCount = 0;
- for (TransportNodesListGatewayMetaState.NodeGatewayMetaState nodeState : nodesState) {
+ for (TransportNodesListGatewayMetaState.NodeGatewayMetaState nodeState : nodesState.getNodes()) {
if (nodeState.metaData() == null) {
continue;
}
diff --git a/core/src/main/java/org/elasticsearch/gateway/GatewayAllocator.java b/core/src/main/java/org/elasticsearch/gateway/GatewayAllocator.java
index e76e8085e86..15cd0e2bf63 100644
--- a/core/src/main/java/org/elasticsearch/gateway/GatewayAllocator.java
+++ b/core/src/main/java/org/elasticsearch/gateway/GatewayAllocator.java
@@ -125,7 +125,7 @@ public class GatewayAllocator extends AbstractComponent {
class InternalAsyncFetch extends AsyncShardFetch {
- public InternalAsyncFetch(ESLogger logger, String type, ShardId shardId, List extends BaseNodesResponse, T> action) {
+ public InternalAsyncFetch(ESLogger logger, String type, ShardId shardId, Lister extends BaseNodesResponse, T> action) {
super(logger, type, shardId, action);
}
diff --git a/core/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayMetaState.java b/core/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayMetaState.java
index 0fd1fd35809..2d0b894939d 100644
--- a/core/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayMetaState.java
+++ b/core/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayMetaState.java
@@ -43,14 +43,15 @@ import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.atomic.AtomicReferenceArray;
/**
*
*/
-public class TransportNodesListGatewayMetaState extends TransportNodesAction {
+public class TransportNodesListGatewayMetaState extends TransportNodesAction {
public static final String ACTION_NAME = "internal:gateway/local/meta_state";
@@ -61,7 +62,7 @@ public class TransportNodesListGatewayMetaState extends TransportNodesAction nodesList = new ArrayList<>();
- final List failures = new ArrayList<>();
- for (int i = 0; i < responses.length(); i++) {
- Object resp = responses.get(i);
- if (resp instanceof NodeGatewayMetaState) { // will also filter out null response for unallocated ones
- nodesList.add((NodeGatewayMetaState) resp);
- } else if (resp instanceof FailedNodeException) {
- failures.add((FailedNodeException) resp);
- } else {
- logger.warn("unknown response type [{}], expected NodeLocalGatewayMetaState or FailedNodeException", resp);
- }
- }
- return new NodesGatewayMetaState(clusterName, nodesList.toArray(new NodeGatewayMetaState[nodesList.size()]),
- failures.toArray(new FailedNodeException[failures.size()]));
+ protected NodesGatewayMetaState newResponse(Request request, List responses, List failures) {
+ return new NodesGatewayMetaState(clusterName, responses, failures);
}
@Override
@@ -142,47 +130,30 @@ public class TransportNodesListGatewayMetaState extends TransportNodesAction {
- private FailedNodeException[] failures;
-
NodesGatewayMetaState() {
}
- public NodesGatewayMetaState(ClusterName clusterName, NodeGatewayMetaState[] nodes, FailedNodeException[] failures) {
- super(clusterName, nodes);
- this.failures = failures;
- }
-
- public FailedNodeException[] failures() {
- return failures;
+ public NodesGatewayMetaState(ClusterName clusterName, List nodes, List failures) {
+ super(clusterName, nodes, failures);
}
@Override
- public void readFrom(StreamInput in) throws IOException {
- super.readFrom(in);
- nodes = new NodeGatewayMetaState[in.readVInt()];
- for (int i = 0; i < nodes.length; i++) {
- nodes[i] = new NodeGatewayMetaState();
- nodes[i].readFrom(in);
- }
+ protected List readNodesFrom(StreamInput in) throws IOException {
+ return in.readStreamableList(NodeGatewayMetaState::new);
}
@Override
- public void writeTo(StreamOutput out) throws IOException {
- super.writeTo(out);
- out.writeVInt(nodes.length);
- for (NodeGatewayMetaState response : nodes) {
- response.writeTo(out);
- }
+ protected void writeNodesTo(StreamOutput out, List nodes) throws IOException {
+ out.writeStreamableList(nodes);
}
}
-
public static class NodeRequest extends BaseNodeRequest {
public NodeRequest() {
}
- NodeRequest(String nodeId, TransportNodesListGatewayMetaState.Request request) {
+ NodeRequest(String nodeId) {
super(nodeId);
}
diff --git a/core/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java b/core/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java
index bdeb6d1660f..675c0088082 100644
--- a/core/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java
+++ b/core/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java
@@ -48,9 +48,7 @@ import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.atomic.AtomicReferenceArray;
/**
* This transport action is used to fetch the shard version from each node during primary allocation in {@link GatewayAllocator}.
@@ -63,7 +61,7 @@ public class TransportNodesListGatewayStartedShards extends
TransportNodesListGatewayStartedShards.NodeRequest,
TransportNodesListGatewayStartedShards.NodeGatewayStartedShards>
implements
- AsyncShardFetch.List {
public static final String ACTION_NAME = "internal:gateway/local/started_shards";
@@ -77,7 +75,8 @@ public class TransportNodesListGatewayStartedShards extends
IndexNameExpressionResolver indexNameExpressionResolver,
NodeEnvironment env) {
super(settings, ACTION_NAME, clusterName, threadPool, clusterService, transportService, actionFilters,
- indexNameExpressionResolver, Request::new, NodeRequest::new, ThreadPool.Names.FETCH_SHARD_STARTED);
+ indexNameExpressionResolver, Request::new, NodeRequest::new, ThreadPool.Names.FETCH_SHARD_STARTED,
+ NodeGatewayStartedShards.class);
this.nodeEnv = env;
}
@@ -110,23 +109,9 @@ public class TransportNodesListGatewayStartedShards extends
}
@Override
- protected NodesGatewayStartedShards newResponse(Request request, AtomicReferenceArray responses) {
- final List nodesList = new ArrayList<>();
- final List failures = new ArrayList<>();
- for (int i = 0; i < responses.length(); i++) {
- Object resp = responses.get(i);
- if (resp instanceof NodeGatewayStartedShards) { // will also filter out null response for unallocated ones
- nodesList.add((NodeGatewayStartedShards) resp);
- } else if (resp instanceof FailedNodeException) {
- failures.add((FailedNodeException) resp);
- } else {
- logger.warn("unknown response type [{}], expected NodeLocalGatewayStartedShards or FailedNodeException",
- resp);
- }
- }
- return new NodesGatewayStartedShards(clusterName,
- nodesList.toArray(new NodeGatewayStartedShards[nodesList.size()]),
- failures.toArray(new FailedNodeException[failures.size()]));
+ protected NodesGatewayStartedShards newResponse(Request request,
+ List responses, List failures) {
+ return new NodesGatewayStartedShards(clusterName, responses, failures);
}
@Override
@@ -217,36 +202,19 @@ public class TransportNodesListGatewayStartedShards extends
public static class NodesGatewayStartedShards extends BaseNodesResponse {
- private FailedNodeException[] failures;
-
- public NodesGatewayStartedShards(ClusterName clusterName, NodeGatewayStartedShards[] nodes,
- FailedNodeException[] failures) {
- super(clusterName, nodes);
- this.failures = failures;
+ public NodesGatewayStartedShards(ClusterName clusterName, List nodes,
+ List failures) {
+ super(clusterName, nodes, failures);
}
@Override
- public FailedNodeException[] failures() {
- return failures;
+ protected List readNodesFrom(StreamInput in) throws IOException {
+ return in.readStreamableList(NodeGatewayStartedShards::new);
}
@Override
- public void readFrom(StreamInput in) throws IOException {
- super.readFrom(in);
- nodes = new NodeGatewayStartedShards[in.readVInt()];
- for (int i = 0; i < nodes.length; i++) {
- nodes[i] = new NodeGatewayStartedShards();
- nodes[i].readFrom(in);
- }
- }
-
- @Override
- public void writeTo(StreamOutput out) throws IOException {
- super.writeTo(out);
- out.writeVInt(nodes.length);
- for (NodeGatewayStartedShards response : nodes) {
- response.writeTo(out);
- }
+ protected void writeNodesTo(StreamOutput out, List nodes) throws IOException {
+ out.writeStreamableList(nodes);
}
}
@@ -258,7 +226,7 @@ public class TransportNodesListGatewayStartedShards extends
public NodeRequest() {
}
- NodeRequest(String nodeId, Request request) {
+ public NodeRequest(String nodeId, Request request) {
super(nodeId);
this.shardId = request.shardId();
}
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/ParseContext.java b/core/src/main/java/org/elasticsearch/index/mapper/ParseContext.java
index 931fbebede2..33476b48cc3 100644
--- a/core/src/main/java/org/elasticsearch/index/mapper/ParseContext.java
+++ b/core/src/main/java/org/elasticsearch/index/mapper/ParseContext.java
@@ -326,11 +326,6 @@ public abstract class ParseContext {
return in.externalValue();
}
- @Override
- public StringBuilder stringBuilder() {
- return in.stringBuilder();
- }
-
@Override
public void addDynamicMapper(Mapper update) {
in.addDynamicMapper(update);
@@ -366,8 +361,6 @@ public abstract class ParseContext {
private Field uid, version;
- private StringBuilder stringBuilder = new StringBuilder();
-
private AllEntries allEntries = new AllEntries();
private List dynamicMappers = new ArrayList<>();
@@ -526,16 +519,6 @@ public abstract class ParseContext {
return this.allEntries;
}
- /**
- * A string builder that can be used to construct complex names for example.
- * Its better to reuse the.
- */
- @Override
- public StringBuilder stringBuilder() {
- stringBuilder.setLength(0);
- return this.stringBuilder;
- }
-
@Override
public void addDynamicMapper(Mapper mapper) {
dynamicMappers.add(mapper);
@@ -736,12 +719,6 @@ public abstract class ParseContext {
return clazz.cast(externalValue());
}
- /**
- * A string builder that can be used to construct complex names for example.
- * Its better to reuse the.
- */
- public abstract StringBuilder stringBuilder();
-
/**
* Add a new mapper dynamically created while parsing.
*/
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/Uid.java b/core/src/main/java/org/elasticsearch/index/mapper/Uid.java
index 414a00d8eed..70acbcd82c3 100644
--- a/core/src/main/java/org/elasticsearch/index/mapper/Uid.java
+++ b/core/src/main/java/org/elasticsearch/index/mapper/Uid.java
@@ -123,13 +123,6 @@ public final class Uid {
return ref;
}
- public static BytesRef createUidAsBytes(BytesRef type, BytesRef id, BytesRefBuilder spare) {
- spare.copyBytes(type);
- spare.append(DELIMITER_BYTES);
- spare.append(id);
- return spare.get();
- }
-
public static BytesRef[] createUidsForTypesAndId(Collection types, Object id) {
return createUidsForTypesAndIds(types, Collections.singletonList(id));
}
@@ -149,11 +142,7 @@ public final class Uid {
}
public static String createUid(String type, String id) {
- return createUid(new StringBuilder(), type, id);
- }
-
- public static String createUid(StringBuilder sb, String type, String id) {
- return sb.append(type).append(DELIMITER).append(id).toString();
+ return type + DELIMITER + id;
}
public static boolean hasDelimiter(BytesRef uid) {
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java
index 81977fe6caf..89e2d8409d5 100644
--- a/core/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java
+++ b/core/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java
@@ -36,7 +36,6 @@ import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.joda.DateMathParser;
import org.elasticsearch.common.joda.FormatDateTimeFormatter;
import org.elasticsearch.common.joda.Joda;
-import org.elasticsearch.common.network.InetAddresses;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.Fuzziness;
import org.elasticsearch.common.util.LocaleUtils;
@@ -152,7 +151,7 @@ public class DateFieldMapper extends FieldMapper implements AllFieldMapper.Inclu
if (propNode == null) {
throw new MapperParsingException("Property [null_value] cannot be null.");
}
- builder.nullValue(InetAddresses.forString(propNode.toString()));
+ builder.nullValue(propNode.toString());
iterator.remove();
} else if (propName.equals("ignore_malformed")) {
builder.ignoreMalformed(TypeParsers.nodeBooleanValue("ignore_malformed", propNode, parserContext));
@@ -561,7 +560,7 @@ public class DateFieldMapper extends FieldMapper implements AllFieldMapper.Inclu
dateAsString = dateAsObject.toString();
}
} else {
- dateAsString = context.parser().text();
+ dateAsString = context.parser().textOrNull();
}
if (dateAsString == null) {
@@ -615,6 +614,11 @@ public class DateFieldMapper extends FieldMapper implements AllFieldMapper.Inclu
if (includeDefaults || ignoreMalformed.explicit()) {
builder.field("ignore_malformed", ignoreMalformed.value());
}
+
+ if (includeDefaults || fieldType().nullValue() != null) {
+ builder.field("null_value", fieldType().nullValueAsString());
+ }
+
if (includeInAll != null) {
builder.field("include_in_all", includeInAll);
} else if (includeDefaults) {
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java
index 2c3a9a5c83e..f1088652988 100644
--- a/core/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java
+++ b/core/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java
@@ -366,8 +366,15 @@ public class NumberFieldMapper extends FieldMapper implements AllFieldMapper.Inc
BYTE("byte", NumericType.BYTE) {
@Override
Byte parse(Object value) {
- if (value instanceof Byte) {
- return (Byte) value;
+ if (value instanceof Number) {
+ double doubleValue = ((Number) value).doubleValue();
+ if (doubleValue < Byte.MIN_VALUE || doubleValue > Byte.MAX_VALUE) {
+ throw new IllegalArgumentException("Value [" + value + "] is out of range for a byte");
+ }
+ if (doubleValue % 1 != 0) {
+ throw new IllegalArgumentException("Value [" + value + "] has a decimal part");
+ }
+ return ((Number) value).byteValue();
}
if (value instanceof BytesRef) {
value = ((BytesRef) value).utf8ToString();
@@ -426,6 +433,13 @@ public class NumberFieldMapper extends FieldMapper implements AllFieldMapper.Inc
@Override
Short parse(Object value) {
if (value instanceof Number) {
+ double doubleValue = ((Number) value).doubleValue();
+ if (doubleValue < Short.MIN_VALUE || doubleValue > Short.MAX_VALUE) {
+ throw new IllegalArgumentException("Value [" + value + "] is out of range for a short");
+ }
+ if (doubleValue % 1 != 0) {
+ throw new IllegalArgumentException("Value [" + value + "] has a decimal part");
+ }
return ((Number) value).shortValue();
}
if (value instanceof BytesRef) {
@@ -485,6 +499,13 @@ public class NumberFieldMapper extends FieldMapper implements AllFieldMapper.Inc
@Override
Integer parse(Object value) {
if (value instanceof Number) {
+ double doubleValue = ((Number) value).doubleValue();
+ if (doubleValue < Integer.MIN_VALUE || doubleValue > Integer.MAX_VALUE) {
+ throw new IllegalArgumentException("Value [" + value + "] is out of range for an integer");
+ }
+ if (doubleValue % 1 != 0) {
+ throw new IllegalArgumentException("Value [" + value + "] has a decimal part");
+ }
return ((Number) value).intValue();
}
if (value instanceof BytesRef) {
@@ -581,6 +602,13 @@ public class NumberFieldMapper extends FieldMapper implements AllFieldMapper.Inc
@Override
Long parse(Object value) {
if (value instanceof Number) {
+ double doubleValue = ((Number) value).doubleValue();
+ if (doubleValue < Long.MIN_VALUE || doubleValue > Long.MAX_VALUE) {
+ throw new IllegalArgumentException("Value [" + value + "] is out of range for a long");
+ }
+ if (doubleValue % 1 != 0) {
+ throw new IllegalArgumentException("Value [" + value + "] has a decimal part");
+ }
return ((Number) value).longValue();
}
if (value instanceof BytesRef) {
@@ -944,6 +972,11 @@ public class NumberFieldMapper extends FieldMapper implements AllFieldMapper.Inc
if (includeDefaults || coerce.explicit()) {
builder.field("coerce", coerce.value());
}
+
+ if (includeDefaults || fieldType().nullValue() != null) {
+ builder.field("null_value", fieldType().nullValue());
+ }
+
if (includeInAll != null) {
builder.field("include_in_all", includeInAll);
} else if (includeDefaults) {
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java
index 9473297de6f..2bf4f75f417 100644
--- a/core/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java
+++ b/core/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java
@@ -31,7 +31,6 @@ import org.apache.lucene.search.TermQuery;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseField;
-import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.loader.SettingsLoader;
import org.elasticsearch.common.xcontent.XContentBuilder;
@@ -264,7 +263,7 @@ public class ParentFieldMapper extends MetadataFieldMapper {
}
// we did not add it in the parsing phase, add it now
fields.add(new SortedDocValuesField(fieldType.name(), new BytesRef(parentId)));
- } else if (parentId != null && !parsedParentId.equals(Uid.createUid(context.stringBuilder(), parentType, parentId))) {
+ } else if (parentId != null && !parsedParentId.equals(Uid.createUid(parentType, parentId))) {
throw new MapperParsingException("Parent id mismatch, document value is [" + Uid.createUid(parsedParentId).id() + "], while external value is [" + parentId + "]");
}
}
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/internal/UidFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/internal/UidFieldMapper.java
index e150a8cd10f..b22369ef812 100644
--- a/core/src/main/java/org/elasticsearch/index/mapper/internal/UidFieldMapper.java
+++ b/core/src/main/java/org/elasticsearch/index/mapper/internal/UidFieldMapper.java
@@ -23,7 +23,6 @@ import org.apache.lucene.document.BinaryDocValuesField;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.IndexableField;
-import org.apache.lucene.index.Term;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.lucene.Lucene;
import org.elasticsearch.common.settings.Settings;
@@ -177,7 +176,7 @@ public class UidFieldMapper extends MetadataFieldMapper {
@Override
protected void parseCreateField(ParseContext context, List fields) throws IOException {
- Field uid = new Field(NAME, Uid.createUid(context.stringBuilder(), context.type(), context.id()), Defaults.FIELD_TYPE);
+ Field uid = new Field(NAME, Uid.createUid(context.type(), context.id()), Defaults.FIELD_TYPE);
context.uid(uid);
fields.add(uid);
if (fieldType().hasDocValues()) {
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java
index 6cb3cbe46c8..5f5a3d85fe1 100644
--- a/core/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java
+++ b/core/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java
@@ -339,7 +339,7 @@ public class IpFieldMapper extends FieldMapper implements AllFieldMapper.Include
if (context.externalValueSet()) {
addressAsObject = context.externalValue();
} else {
- addressAsObject = context.parser().text();
+ addressAsObject = context.parser().textOrNull();
}
if (addressAsObject == null) {
@@ -395,6 +395,10 @@ public class IpFieldMapper extends FieldMapper implements AllFieldMapper.Include
protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException {
super.doXContentBody(builder, includeDefaults, params);
+ if (includeDefaults || fieldType().nullValue() != null) {
+ builder.field("null_value", InetAddresses.toAddrString((InetAddress) fieldType().nullValue()));
+ }
+
if (includeDefaults || ignoreMalformed.explicit()) {
builder.field("ignore_malformed", ignoreMalformed.value());
}
diff --git a/core/src/main/java/org/elasticsearch/index/percolator/PercolatorFieldMapper.java b/core/src/main/java/org/elasticsearch/index/percolator/PercolatorFieldMapper.java
index 10c7e46e353..58f9f6c695c 100644
--- a/core/src/main/java/org/elasticsearch/index/percolator/PercolatorFieldMapper.java
+++ b/core/src/main/java/org/elasticsearch/index/percolator/PercolatorFieldMapper.java
@@ -186,7 +186,7 @@ public class PercolatorFieldMapper extends FieldMapper {
}
XContentParser parser = context.parser();
- QueryBuilder> queryBuilder = parseQueryBuilder(queryShardContext.newParseContext(parser), parser.getTokenLocation());
+ QueryBuilder queryBuilder = parseQueryBuilder(queryShardContext.newParseContext(parser), parser.getTokenLocation());
// Fetching of terms, shapes and indexed scripts happen during this rewrite:
queryBuilder = queryBuilder.rewrite(queryShardContext);
@@ -206,7 +206,7 @@ public class PercolatorFieldMapper extends FieldMapper {
return toQuery(context, mapUnmappedFieldsAsString, parseQueryBuilder(context.newParseContext(parser), parser.getTokenLocation()));
}
- static Query toQuery(QueryShardContext context, boolean mapUnmappedFieldsAsString, QueryBuilder> queryBuilder) throws IOException {
+ static Query toQuery(QueryShardContext context, boolean mapUnmappedFieldsAsString, QueryBuilder queryBuilder) throws IOException {
// This means that fields in the query need to exist in the mapping prior to registering this query
// The reason that this is required, is that if a field doesn't exist then the query assumes defaults, which may be undesired.
//
diff --git a/core/src/main/java/org/elasticsearch/index/query/AbstractQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/AbstractQueryBuilder.java
index 6e82e7059d8..e883166f900 100644
--- a/core/src/main/java/org/elasticsearch/index/query/AbstractQueryBuilder.java
+++ b/core/src/main/java/org/elasticsearch/index/query/AbstractQueryBuilder.java
@@ -43,7 +43,7 @@ import java.util.Objects;
* Base class for all classes producing lucene queries.
* Supports conversion to BytesReference and creation of lucene Query objects.
*/
-public abstract class AbstractQueryBuilder> extends ToXContentToBytes implements QueryBuilder {
+public abstract class AbstractQueryBuilder> extends ToXContentToBytes implements QueryBuilder {
/** Default for boost to apply to resulting Lucene query. Defaults to 1.0*/
public static final float DEFAULT_BOOST = 1.0f;
@@ -221,10 +221,10 @@ public abstract class AbstractQueryBuilder>
* their {@link QueryBuilder#toQuery(QueryShardContext)} method are not added to the
* resulting collection.
*/
- protected static Collection toQueries(Collection> queryBuilders, QueryShardContext context) throws QueryShardException,
+ protected static Collection toQueries(Collection queryBuilders, QueryShardContext context) throws QueryShardException,
IOException {
List queries = new ArrayList<>(queryBuilders.size());
- for (QueryBuilder> queryBuilder : queryBuilders) {
+ for (QueryBuilder queryBuilder : queryBuilders) {
Query query = queryBuilder.toQuery(context);
if (query != null) {
queries.add(query);
@@ -241,13 +241,13 @@ public abstract class AbstractQueryBuilder>
protected final static void writeQueries(StreamOutput out, List extends QueryBuilder> queries) throws IOException {
out.writeVInt(queries.size());
- for (QueryBuilder> query : queries) {
+ for (QueryBuilder query : queries) {
out.writeNamedWriteable(query);
}
}
- protected final static List> readQueries(StreamInput in) throws IOException {
- List> queries = new ArrayList<>();
+ protected final static List readQueries(StreamInput in) throws IOException {
+ List queries = new ArrayList<>();
int size = in.readVInt();
for (int i = 0; i < size; i++) {
queries.add(in.readNamedWriteable(QueryBuilder.class));
@@ -256,8 +256,8 @@ public abstract class AbstractQueryBuilder>
}
@Override
- public final QueryBuilder> rewrite(QueryRewriteContext queryShardContext) throws IOException {
- QueryBuilder> rewritten = doRewrite(queryShardContext);
+ public final QueryBuilder rewrite(QueryRewriteContext queryShardContext) throws IOException {
+ QueryBuilder rewritten = doRewrite(queryShardContext);
if (rewritten == this) {
return rewritten;
}
@@ -270,7 +270,7 @@ public abstract class AbstractQueryBuilder>
return rewritten;
}
- protected QueryBuilder> doRewrite(QueryRewriteContext queryShardContext) throws IOException {
+ protected QueryBuilder doRewrite(QueryRewriteContext queryShardContext) throws IOException {
return this;
}
diff --git a/core/src/main/java/org/elasticsearch/index/query/BoolQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/BoolQueryBuilder.java
index c6de1213a8d..e5aa774addc 100644
--- a/core/src/main/java/org/elasticsearch/index/query/BoolQueryBuilder.java
+++ b/core/src/main/java/org/elasticsearch/index/query/BoolQueryBuilder.java
@@ -62,13 +62,13 @@ public class BoolQueryBuilder extends AbstractQueryBuilder {
private static final ParseField MINIMUM_NUMBER_SHOULD_MATCH = new ParseField("minimum_number_should_match");
private static final ParseField ADJUST_PURE_NEGATIVE = new ParseField("adjust_pure_negative");
- private final List> mustClauses = new ArrayList<>();
+ private final List mustClauses = new ArrayList<>();
- private final List> mustNotClauses = new ArrayList<>();
+ private final List mustNotClauses = new ArrayList<>();
- private final List> filterClauses = new ArrayList<>();
+ private final List filterClauses = new ArrayList<>();
- private final List> shouldClauses = new ArrayList<>();
+ private final List shouldClauses = new ArrayList<>();
private boolean disableCoord = DISABLE_COORD_DEFAULT;
@@ -111,7 +111,7 @@ public class BoolQueryBuilder extends AbstractQueryBuilder {
* Adds a query that must appear in the matching documents and will
* contribute to scoring. No null value allowed.
*/
- public BoolQueryBuilder must(QueryBuilder> queryBuilder) {
+ public BoolQueryBuilder must(QueryBuilder queryBuilder) {
if (queryBuilder == null) {
throw new IllegalArgumentException("inner bool query clause cannot be null");
}
@@ -122,7 +122,7 @@ public class BoolQueryBuilder extends AbstractQueryBuilder {
/**
* Gets the queries that must appear in the matching documents.
*/
- public List> must() {
+ public List must() {
return this.mustClauses;
}
@@ -130,7 +130,7 @@ public class BoolQueryBuilder extends AbstractQueryBuilder {
* Adds a query that must appear in the matching documents but will
* not contribute to scoring. No null value allowed.
*/
- public BoolQueryBuilder filter(QueryBuilder> queryBuilder) {
+ public BoolQueryBuilder filter(QueryBuilder queryBuilder) {
if (queryBuilder == null) {
throw new IllegalArgumentException("inner bool query clause cannot be null");
}
@@ -141,7 +141,7 @@ public class BoolQueryBuilder extends AbstractQueryBuilder {
/**
* Gets the queries that must appear in the matching documents but don't contribute to scoring
*/
- public List> filter() {
+ public List filter() {
return this.filterClauses;
}
@@ -149,7 +149,7 @@ public class BoolQueryBuilder extends AbstractQueryBuilder {
* Adds a query that must not appear in the matching documents.
* No null value allowed.
*/
- public BoolQueryBuilder mustNot(QueryBuilder> queryBuilder) {
+ public BoolQueryBuilder mustNot(QueryBuilder queryBuilder) {
if (queryBuilder == null) {
throw new IllegalArgumentException("inner bool query clause cannot be null");
}
@@ -160,7 +160,7 @@ public class BoolQueryBuilder extends AbstractQueryBuilder {
/**
* Gets the queries that must not appear in the matching documents.
*/
- public List> mustNot() {
+ public List mustNot() {
return this.mustNotClauses;
}
@@ -171,7 +171,7 @@ public class BoolQueryBuilder extends AbstractQueryBuilder {
*
* @see #minimumNumberShouldMatch(int)
*/
- public BoolQueryBuilder should(QueryBuilder> queryBuilder) {
+ public BoolQueryBuilder should(QueryBuilder queryBuilder) {
if (queryBuilder == null) {
throw new IllegalArgumentException("inner bool query clause cannot be null");
}
@@ -185,7 +185,7 @@ public class BoolQueryBuilder extends AbstractQueryBuilder {
* @see #should(QueryBuilder)
* @see #minimumNumberShouldMatch(int)
*/
- public List> should() {
+ public List should() {
return this.shouldClauses;
}
@@ -288,13 +288,13 @@ public class BoolQueryBuilder extends AbstractQueryBuilder {
builder.endObject();
}
- private static void doXArrayContent(String field, List> clauses, XContentBuilder builder, Params params)
+ private static void doXArrayContent(String field, List clauses, XContentBuilder builder, Params params)
throws IOException {
if (clauses.isEmpty()) {
return;
}
builder.startArray(field);
- for (QueryBuilder> clause : clauses) {
+ for (QueryBuilder clause : clauses) {
clause.toXContent(builder, params);
}
builder.endArray();
@@ -308,15 +308,15 @@ public class BoolQueryBuilder extends AbstractQueryBuilder {
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
String minimumShouldMatch = null;
- final List> mustClauses = new ArrayList<>();
- final List> mustNotClauses = new ArrayList<>();
- final List> shouldClauses = new ArrayList<>();
- final List> filterClauses = new ArrayList<>();
+ final List mustClauses = new ArrayList<>();
+ final List mustNotClauses = new ArrayList<>();
+ final List shouldClauses = new ArrayList<>();
+ final List filterClauses = new ArrayList<>();
String queryName = null;
String currentFieldName = null;
XContentParser.Token token;
- QueryBuilder> query;
+ QueryBuilder query;
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
@@ -387,16 +387,16 @@ public class BoolQueryBuilder extends AbstractQueryBuilder {
}
}
BoolQueryBuilder boolQuery = new BoolQueryBuilder();
- for (QueryBuilder> queryBuilder : mustClauses) {
+ for (QueryBuilder queryBuilder : mustClauses) {
boolQuery.must(queryBuilder);
}
- for (QueryBuilder> queryBuilder : mustNotClauses) {
+ for (QueryBuilder queryBuilder : mustNotClauses) {
boolQuery.mustNot(queryBuilder);
}
- for (QueryBuilder> queryBuilder : shouldClauses) {
+ for (QueryBuilder queryBuilder : shouldClauses) {
boolQuery.should(queryBuilder);
}
- for (QueryBuilder> queryBuilder : filterClauses) {
+ for (QueryBuilder queryBuilder : filterClauses) {
boolQuery.filter(queryBuilder);
}
boolQuery.boost(boost);
@@ -436,8 +436,8 @@ public class BoolQueryBuilder extends AbstractQueryBuilder {
}
private static void addBooleanClauses(QueryShardContext context, BooleanQuery.Builder booleanQueryBuilder,
- List> clauses, Occur occurs) throws IOException {
- for (QueryBuilder> query : clauses) {
+ List clauses, Occur occurs) throws IOException {
+ for (QueryBuilder query : clauses) {
Query luceneQuery = null;
switch (occurs) {
case MUST:
@@ -473,7 +473,7 @@ public class BoolQueryBuilder extends AbstractQueryBuilder {
}
@Override
- protected QueryBuilder> doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
+ protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
BoolQueryBuilder newBuilder = new BoolQueryBuilder();
boolean changed = false;
final int clauses = mustClauses.size() + mustNotClauses.size() + filterClauses.size() + shouldClauses.size();
@@ -498,20 +498,20 @@ public class BoolQueryBuilder extends AbstractQueryBuilder {
@Override
protected void extractInnerHitBuilders(Map innerHits) {
- List> clauses = new ArrayList<>(filter());
+ List clauses = new ArrayList<>(filter());
clauses.addAll(must());
clauses.addAll(should());
// no need to include must_not (since there will be no hits for it)
- for (QueryBuilder> clause : clauses) {
+ for (QueryBuilder clause : clauses) {
InnerHitBuilder.extractInnerHits(clause, innerHits);
}
}
- private static boolean rewriteClauses(QueryRewriteContext queryRewriteContext, List> builders,
- Consumer> consumer) throws IOException {
+ private static boolean rewriteClauses(QueryRewriteContext queryRewriteContext, List builders,
+ Consumer consumer) throws IOException {
boolean changed = false;
- for (QueryBuilder> builder : builders) {
- QueryBuilder> result = builder.rewrite(queryRewriteContext);
+ for (QueryBuilder builder : builders) {
+ QueryBuilder result = builder.rewrite(queryRewriteContext);
if (result != builder) {
changed = true;
}
diff --git a/core/src/main/java/org/elasticsearch/index/query/BoostingQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/BoostingQueryBuilder.java
index fa439bc71d8..496cb7ec8a7 100644
--- a/core/src/main/java/org/elasticsearch/index/query/BoostingQueryBuilder.java
+++ b/core/src/main/java/org/elasticsearch/index/query/BoostingQueryBuilder.java
@@ -53,9 +53,9 @@ public class BoostingQueryBuilder extends AbstractQueryBuilder positiveQuery;
+ private final QueryBuilder positiveQuery;
- private final QueryBuilder> negativeQuery;
+ private final QueryBuilder negativeQuery;
private float negativeBoost = -1;
@@ -66,7 +66,7 @@ public class BoostingQueryBuilder extends AbstractQueryBuilder positiveQuery, QueryBuilder> negativeQuery) {
+ public BoostingQueryBuilder(QueryBuilder positiveQuery, QueryBuilder negativeQuery) {
if (positiveQuery == null) {
throw new IllegalArgumentException("inner clause [positive] cannot be null.");
}
@@ -226,7 +226,7 @@ public class BoostingQueryBuilder extends AbstractQueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
+ protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {
QueryBuilder positiveQuery = this.positiveQuery.rewrite(queryRewriteContext);
QueryBuilder negativeQuery = this.negativeQuery.rewrite(queryRewriteContext);
if (positiveQuery != this.positiveQuery || negativeQuery != this.negativeQuery) {
diff --git a/core/src/main/java/org/elasticsearch/index/query/ConstantScoreQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/ConstantScoreQueryBuilder.java
index 8ae2a088f2f..306a4568576 100644
--- a/core/src/main/java/org/elasticsearch/index/query/ConstantScoreQueryBuilder.java
+++ b/core/src/main/java/org/elasticsearch/index/query/ConstantScoreQueryBuilder.java
@@ -43,7 +43,7 @@ public class ConstantScoreQueryBuilder extends AbstractQueryBuilder filterBuilder;
+ private final QueryBuilder filterBuilder;
/**
* A query that wraps another query and simply returns a constant score equal to the
@@ -51,7 +51,7 @@ public class ConstantScoreQueryBuilder extends AbstractQueryBuilder filterBuilder) {
+ public ConstantScoreQueryBuilder(QueryBuilder filterBuilder) {
if (filterBuilder == null) {
throw new IllegalArgumentException("inner clause [filter] cannot be null.");
}
@@ -74,7 +74,7 @@ public class ConstantScoreQueryBuilder extends AbstractQueryBuilder innerQuery() {
+ public QueryBuilder innerQuery() {
return this.filterBuilder;
}
@@ -90,7 +90,7 @@ public class ConstantScoreQueryBuilder extends AbstractQueryBuilder