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 4b30da0b9f5..0b819daf82c 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 @@ -730,7 +730,7 @@ public abstract class StreamInput extends InputStream { } /** - * Reads an optional {@link QueryBuilder}. + * Reads an optional {@link NamedWriteable}. */ public > C readOptionalNamedWriteable(Class categoryClass) throws IOException { if (readBoolean()) { diff --git a/core/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java b/core/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java index 716d6b861a2..81cbad760d9 100644 --- a/core/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java +++ b/core/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java @@ -692,6 +692,18 @@ public abstract class StreamOutput extends OutputStream { namedWriteable.writeTo(this); } + /** + * Write an optional {@link QueryBuilder} to the stream. + */ + public void writeOptionalNamedWriteable(@Nullable NamedWriteable namedWriteable) throws IOException { + if (namedWriteable == null) { + writeBoolean(false); + } else { + writeBoolean(true); + writeNamedWriteable(namedWriteable); + } + } + /** * Writes a {@link AggregatorBuilder} to the current stream */ @@ -713,18 +725,6 @@ public abstract class StreamOutput extends OutputStream { writeNamedWriteable(queryBuilder); } - /** - * Write an optional {@link QueryBuilder} to the stream. - */ - public void writeOptionalQuery(@Nullable QueryBuilder queryBuilder) throws IOException { - if (queryBuilder == null) { - writeBoolean(false); - } else { - writeBoolean(true); - writeQuery(queryBuilder); - } - } - /** * Writes a {@link ShapeBuilder} to the current stream */ diff --git a/core/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java b/core/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java index 72a248db393..8d89322e5cd 100644 --- a/core/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java @@ -112,7 +112,7 @@ public class FieldSortBuilder extends SortBuilder { @Override public void writeTo(StreamOutput out) throws IOException { out.writeString(fieldName); - out.writeOptionalQuery(nestedFilter); + out.writeOptionalNamedWriteable(nestedFilter); out.writeOptionalString(nestedPath); out.writeGenericValue(missing); out.writeOptionalWriteable(order); diff --git a/core/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java b/core/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java index dbefbb460ba..e6570543c83 100644 --- a/core/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java @@ -173,7 +173,7 @@ public class GeoDistanceSortBuilder extends SortBuilder unit.writeTo(out); order.writeTo(out); out.writeOptionalWriteable(sortMode); - out.writeOptionalQuery(nestedFilter); + out.writeOptionalNamedWriteable(nestedFilter); out.writeOptionalString(nestedPath); out.writeBoolean(coerce); out.writeBoolean(ignoreMalformed); diff --git a/core/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java b/core/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java index 93b7de74b61..5c58d10b67f 100644 --- a/core/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java @@ -128,7 +128,7 @@ public class ScriptSortBuilder extends SortBuilder { order.writeTo(out); out.writeOptionalWriteable(sortMode); out.writeOptionalString(nestedPath); - out.writeOptionalQuery(nestedFilter); + out.writeOptionalNamedWriteable(nestedFilter); } /**