Migrate (read|write)Query to (read|write)NamedWriteable
Now there aren't any more specialized methods to read or write NamedWriteables! Now StreamInput and StreamOutput don't need to know about large chunks of the application!
This commit is contained in:
parent
339d927ee4
commit
133cec602c
|
@ -84,7 +84,7 @@ public class ShardValidateQueryRequest extends BroadcastShardRequest {
|
|||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
query = in.readQuery();
|
||||
query = in.readNamedWriteable(QueryBuilder.class);
|
||||
|
||||
int typesSize = in.readVInt();
|
||||
if (typesSize > 0) {
|
||||
|
@ -109,7 +109,7 @@ public class ShardValidateQueryRequest extends BroadcastShardRequest {
|
|||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeQuery(query);
|
||||
out.writeNamedWriteable(query);
|
||||
|
||||
out.writeVInt(types.length);
|
||||
for (String type : types) {
|
||||
|
|
|
@ -128,7 +128,7 @@ public class ValidateQueryRequest extends BroadcastRequest<ValidateQueryRequest>
|
|||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
query = in.readQuery();
|
||||
query = in.readNamedWriteable(QueryBuilder.class);
|
||||
int typesSize = in.readVInt();
|
||||
if (typesSize > 0) {
|
||||
types = new String[typesSize];
|
||||
|
@ -143,7 +143,7 @@ public class ValidateQueryRequest extends BroadcastRequest<ValidateQueryRequest>
|
|||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeQuery(query);
|
||||
out.writeNamedWriteable(query);
|
||||
out.writeVInt(types.length);
|
||||
for (String type : types) {
|
||||
out.writeString(type);
|
||||
|
|
|
@ -165,7 +165,7 @@ public class ExplainRequest extends SingleShardRequest<ExplainRequest> {
|
|||
id = in.readString();
|
||||
routing = in.readOptionalString();
|
||||
preference = in.readOptionalString();
|
||||
query = in.readQuery();
|
||||
query = in.readNamedWriteable(QueryBuilder.class);
|
||||
filteringAlias = in.readStringArray();
|
||||
fields = in.readOptionalStringArray();
|
||||
fetchSourceContext = in.readOptionalStreamable(FetchSourceContext::new);
|
||||
|
@ -179,7 +179,7 @@ public class ExplainRequest extends SingleShardRequest<ExplainRequest> {
|
|||
out.writeString(id);
|
||||
out.writeOptionalString(routing);
|
||||
out.writeOptionalString(preference);
|
||||
out.writeQuery(query);
|
||||
out.writeNamedWriteable(query);
|
||||
out.writeStringArray(filteringAlias);
|
||||
out.writeOptionalStringArray(fields);
|
||||
out.writeOptionalStreamable(fetchSourceContext);
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.elasticsearch.common.bytes.BytesArray;
|
|||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.text.Text;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
|
||||
|
@ -729,15 +728,6 @@ public abstract class StreamInput extends InputStream {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a {@link QueryBuilder} from the current stream
|
||||
* @deprecated prefer {@link #readNamedWriteable(Class)} passing {@link QueryBuilder}.
|
||||
*/
|
||||
@Deprecated
|
||||
public QueryBuilder<?> readQuery() throws IOException {
|
||||
return readNamedWriteable(QueryBuilder.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a list of objects
|
||||
*/
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.elasticsearch.common.Nullable;
|
|||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.text.Text;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.joda.time.ReadableInstant;
|
||||
|
||||
|
@ -693,15 +692,6 @@ public abstract class StreamOutput extends OutputStream {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a {@link QueryBuilder} to the current stream
|
||||
* @deprecated prefer {@link #writeNamedWriteable(NamedWriteable)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void writeQuery(QueryBuilder<?> queryBuilder) throws IOException {
|
||||
writeNamedWriteable(queryBuilder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the given {@link GeoPoint} to the stream
|
||||
*/
|
||||
|
|
|
@ -241,7 +241,7 @@ public abstract class AbstractQueryBuilder<QB extends AbstractQueryBuilder<QB>>
|
|||
protected final void writeQueries(StreamOutput out, List<? extends QueryBuilder<?>> queries) throws IOException {
|
||||
out.writeVInt(queries.size());
|
||||
for (QueryBuilder<?> query : queries) {
|
||||
out.writeQuery(query);
|
||||
out.writeNamedWriteable(query);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ public abstract class AbstractQueryBuilder<QB extends AbstractQueryBuilder<QB>>
|
|||
List<QueryBuilder<?>> queries = new ArrayList<>();
|
||||
int size = in.readVInt();
|
||||
for (int i = 0; i < size; i++) {
|
||||
queries.add(in.readQuery());
|
||||
queries.add(in.readNamedWriteable(QueryBuilder.class));
|
||||
}
|
||||
return queries;
|
||||
}
|
||||
|
|
|
@ -81,15 +81,15 @@ public class BoostingQueryBuilder extends AbstractQueryBuilder<BoostingQueryBuil
|
|||
*/
|
||||
public BoostingQueryBuilder(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
positiveQuery = in.readQuery();
|
||||
negativeQuery = in.readQuery();
|
||||
positiveQuery = in.readNamedWriteable(QueryBuilder.class);
|
||||
negativeQuery = in.readNamedWriteable(QueryBuilder.class);
|
||||
negativeBoost = in.readFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doWriteTo(StreamOutput out) throws IOException {
|
||||
out.writeQuery(positiveQuery);
|
||||
out.writeQuery(negativeQuery);
|
||||
out.writeNamedWriteable(positiveQuery);
|
||||
out.writeNamedWriteable(negativeQuery);
|
||||
out.writeFloat(negativeBoost);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,12 +62,12 @@ public class ConstantScoreQueryBuilder extends AbstractQueryBuilder<ConstantScor
|
|||
*/
|
||||
public ConstantScoreQueryBuilder(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
filterBuilder = in.readQuery();
|
||||
filterBuilder = in.readNamedWriteable(QueryBuilder.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doWriteTo(StreamOutput out) throws IOException {
|
||||
out.writeQuery(filterBuilder);
|
||||
out.writeNamedWriteable(filterBuilder);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -69,13 +69,13 @@ public class FieldMaskingSpanQueryBuilder extends AbstractQueryBuilder<FieldMask
|
|||
*/
|
||||
public FieldMaskingSpanQueryBuilder(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
queryBuilder = (SpanQueryBuilder<?>) in.readQuery();
|
||||
queryBuilder = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
|
||||
fieldName = in.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doWriteTo(StreamOutput out) throws IOException {
|
||||
out.writeQuery(queryBuilder);
|
||||
out.writeNamedWriteable(queryBuilder);
|
||||
out.writeString(fieldName);
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ public class HasChildQueryBuilder extends AbstractQueryBuilder<HasChildQueryBuil
|
|||
minChildren = in.readInt();
|
||||
maxChildren = in.readInt();
|
||||
scoreMode = ScoreMode.values()[in.readVInt()];
|
||||
query = in.readQuery();
|
||||
query = in.readNamedWriteable(QueryBuilder.class);
|
||||
innerHitBuilder = in.readOptionalWriteable(InnerHitBuilder::new);
|
||||
ignoreUnmapped = in.readBoolean();
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ public class HasChildQueryBuilder extends AbstractQueryBuilder<HasChildQueryBuil
|
|||
out.writeInt(minChildren);
|
||||
out.writeInt(maxChildren);
|
||||
out.writeVInt(scoreMode.ordinal());
|
||||
out.writeQuery(query);
|
||||
out.writeNamedWriteable(query);
|
||||
out.writeOptionalWriteable(innerHitBuilder);
|
||||
out.writeBoolean(ignoreUnmapped);
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public class HasParentQueryBuilder extends AbstractQueryBuilder<HasParentQueryBu
|
|||
super(in);
|
||||
type = in.readString();
|
||||
score = in.readBoolean();
|
||||
query = in.readQuery();
|
||||
query = in.readNamedWriteable(QueryBuilder.class);
|
||||
innerHit = in.readOptionalWriteable(InnerHitBuilder::new);
|
||||
ignoreUnmapped = in.readBoolean();
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public class HasParentQueryBuilder extends AbstractQueryBuilder<HasParentQueryBu
|
|||
protected void doWriteTo(StreamOutput out) throws IOException {
|
||||
out.writeString(type);
|
||||
out.writeBoolean(score);
|
||||
out.writeQuery(query);
|
||||
out.writeNamedWriteable(query);
|
||||
out.writeOptionalWriteable(innerHit);
|
||||
out.writeBoolean(ignoreUnmapped);
|
||||
}
|
||||
|
|
|
@ -82,16 +82,16 @@ public class IndicesQueryBuilder extends AbstractQueryBuilder<IndicesQueryBuilde
|
|||
*/
|
||||
public IndicesQueryBuilder(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
innerQuery = in.readQuery();
|
||||
innerQuery = in.readNamedWriteable(QueryBuilder.class);
|
||||
indices = in.readStringArray();
|
||||
noMatchQuery = in.readQuery();
|
||||
noMatchQuery = in.readNamedWriteable(QueryBuilder.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doWriteTo(StreamOutput out) throws IOException {
|
||||
out.writeQuery(innerQuery);
|
||||
out.writeNamedWriteable(innerQuery);
|
||||
out.writeStringArray(indices);
|
||||
out.writeQuery(noMatchQuery);
|
||||
out.writeNamedWriteable(noMatchQuery);
|
||||
}
|
||||
|
||||
public QueryBuilder<?> innerQuery() {
|
||||
|
|
|
@ -79,7 +79,7 @@ public class NestedQueryBuilder extends AbstractQueryBuilder<NestedQueryBuilder>
|
|||
super(in);
|
||||
path = in.readString();
|
||||
scoreMode = ScoreMode.values()[in.readVInt()];
|
||||
query = in.readQuery();
|
||||
query = in.readNamedWriteable(QueryBuilder.class);
|
||||
innerHitBuilder = in.readOptionalWriteable(InnerHitBuilder::new);
|
||||
ignoreUnmapped = in.readBoolean();
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class NestedQueryBuilder extends AbstractQueryBuilder<NestedQueryBuilder>
|
|||
protected void doWriteTo(StreamOutput out) throws IOException {
|
||||
out.writeString(path);
|
||||
out.writeVInt(scoreMode.ordinal());
|
||||
out.writeQuery(query);
|
||||
out.writeNamedWriteable(query);
|
||||
out.writeOptionalWriteable(innerHitBuilder);
|
||||
out.writeBoolean(ignoreUnmapped);
|
||||
}
|
||||
|
|
|
@ -67,14 +67,14 @@ public class SpanContainingQueryBuilder extends AbstractQueryBuilder<SpanContain
|
|||
*/
|
||||
public SpanContainingQueryBuilder(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
big = (SpanQueryBuilder<?>) in.readQuery();
|
||||
little = (SpanQueryBuilder<?>) in.readQuery();
|
||||
big = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
|
||||
little = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doWriteTo(StreamOutput out) throws IOException {
|
||||
out.writeQuery(big);
|
||||
out.writeQuery(little);
|
||||
out.writeNamedWriteable(big);
|
||||
out.writeNamedWriteable(little);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -67,13 +67,13 @@ public class SpanFirstQueryBuilder extends AbstractQueryBuilder<SpanFirstQueryBu
|
|||
*/
|
||||
public SpanFirstQueryBuilder(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
matchBuilder = (SpanQueryBuilder<?>)in.readQuery();
|
||||
matchBuilder = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
|
||||
end = in.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doWriteTo(StreamOutput out) throws IOException {
|
||||
out.writeQuery(matchBuilder);
|
||||
out.writeNamedWriteable(matchBuilder);
|
||||
out.writeInt(end);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,12 +60,12 @@ public class SpanMultiTermQueryBuilder extends AbstractQueryBuilder<SpanMultiTer
|
|||
*/
|
||||
public SpanMultiTermQueryBuilder(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
multiTermQueryBuilder = (MultiTermQueryBuilder<?>) in.readQuery();
|
||||
multiTermQueryBuilder = (MultiTermQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doWriteTo(StreamOutput out) throws IOException {
|
||||
out.writeQuery(multiTermQueryBuilder);
|
||||
out.writeNamedWriteable(multiTermQueryBuilder);
|
||||
}
|
||||
|
||||
public MultiTermQueryBuilder<?> innerQuery() {
|
||||
|
|
|
@ -78,16 +78,16 @@ public class SpanNotQueryBuilder extends AbstractQueryBuilder<SpanNotQueryBuilde
|
|||
*/
|
||||
public SpanNotQueryBuilder(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
include = (SpanQueryBuilder<?>) in.readQuery();
|
||||
exclude = (SpanQueryBuilder<?>) in.readQuery();
|
||||
include = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
|
||||
exclude = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
|
||||
pre = in.readVInt();
|
||||
post = in.readVInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doWriteTo(StreamOutput out) throws IOException {
|
||||
out.writeQuery(include);
|
||||
out.writeQuery(exclude);
|
||||
out.writeNamedWriteable(include);
|
||||
out.writeNamedWriteable(exclude);
|
||||
out.writeVInt(pre);
|
||||
out.writeVInt(post);
|
||||
}
|
||||
|
|
|
@ -68,14 +68,14 @@ public class SpanWithinQueryBuilder extends AbstractQueryBuilder<SpanWithinQuery
|
|||
*/
|
||||
public SpanWithinQueryBuilder(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
big = (SpanQueryBuilder<?>) in.readQuery();
|
||||
little = (SpanQueryBuilder<?>) in.readQuery();
|
||||
big = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
|
||||
little = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doWriteTo(StreamOutput out) throws IOException {
|
||||
out.writeQuery(big);
|
||||
out.writeQuery(little);
|
||||
out.writeNamedWriteable(big);
|
||||
out.writeNamedWriteable(little);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -149,7 +149,7 @@ public class FunctionScoreQueryBuilder extends AbstractQueryBuilder<FunctionScor
|
|||
*/
|
||||
public FunctionScoreQueryBuilder(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
query = in.readQuery();
|
||||
query = in.readNamedWriteable(QueryBuilder.class);
|
||||
filterFunctionBuilders = in.readList(FilterFunctionBuilder::new).toArray(new FilterFunctionBuilder[0]);
|
||||
maxBoost = in.readFloat();
|
||||
minScore = in.readOptionalFloat();
|
||||
|
@ -159,7 +159,7 @@ public class FunctionScoreQueryBuilder extends AbstractQueryBuilder<FunctionScor
|
|||
|
||||
@Override
|
||||
protected void doWriteTo(StreamOutput out) throws IOException {
|
||||
out.writeQuery(query);
|
||||
out.writeNamedWriteable(query);
|
||||
out.writeList(Arrays.asList(filterFunctionBuilders));
|
||||
out.writeFloat(maxBoost);
|
||||
out.writeOptionalFloat(minScore);
|
||||
|
|
|
@ -164,7 +164,7 @@ public final class InnerHitBuilder extends ToXContentToBytes implements Writeabl
|
|||
}
|
||||
}
|
||||
highlightBuilder = in.readOptionalWriteable(HighlightBuilder::new);
|
||||
query = in.readQuery();
|
||||
query = in.readNamedWriteable(QueryBuilder.class);
|
||||
innerHitsBuilder = in.readOptionalWriteable(InnerHitsBuilder::new);
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ public final class InnerHitBuilder extends ToXContentToBytes implements Writeabl
|
|||
}
|
||||
}
|
||||
out.writeOptionalWriteable(highlightBuilder);
|
||||
out.writeQuery(query);
|
||||
out.writeNamedWriteable(query);
|
||||
out.writeOptionalWriteable(innerHitsBuilder);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,12 +68,12 @@ public class FilterAggregatorBuilder extends AggregatorBuilder<FilterAggregatorB
|
|||
*/
|
||||
public FilterAggregatorBuilder(StreamInput in) throws IOException {
|
||||
super(in, InternalFilter.TYPE);
|
||||
filter = in.readQuery();
|
||||
filter = in.readNamedWriteable(QueryBuilder.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doWriteTo(StreamOutput out) throws IOException {
|
||||
out.writeQuery(filter);
|
||||
out.writeNamedWriteable(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -81,13 +81,13 @@ public class FiltersAggregator extends BucketsAggregator {
|
|||
*/
|
||||
public KeyedFilter(StreamInput in) throws IOException {
|
||||
key = in.readString();
|
||||
filter = in.readQuery();
|
||||
filter = in.readNamedWriteable(QueryBuilder.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeString(key);
|
||||
out.writeQuery(filter);
|
||||
out.writeNamedWriteable(filter);
|
||||
}
|
||||
|
||||
public String key() {
|
||||
|
|
|
@ -104,7 +104,7 @@ public class FiltersAggregatorBuilder extends AggregatorBuilder<FiltersAggregato
|
|||
}
|
||||
} else {
|
||||
for (int i = 0; i < filtersSize; i++) {
|
||||
filters.add(new KeyedFilter(String.valueOf(i), in.readQuery()));
|
||||
filters.add(new KeyedFilter(String.valueOf(i), in.readNamedWriteable(QueryBuilder.class)));
|
||||
}
|
||||
}
|
||||
otherBucket = in.readBoolean();
|
||||
|
@ -121,7 +121,7 @@ public class FiltersAggregatorBuilder extends AggregatorBuilder<FiltersAggregato
|
|||
}
|
||||
} else {
|
||||
for (KeyedFilter keyedFilter : filters) {
|
||||
out.writeQuery(keyedFilter.filter());
|
||||
out.writeNamedWriteable(keyedFilter.filter());
|
||||
}
|
||||
}
|
||||
out.writeBoolean(otherBucket);
|
||||
|
|
|
@ -74,7 +74,7 @@ public class SignificantTermsAggregatorBuilder extends ValuesSourceAggregatorBui
|
|||
bucketCountThresholds = BucketCountThresholds.readFromStream(in);
|
||||
executionHint = in.readOptionalString();
|
||||
if (in.readBoolean()) {
|
||||
filterBuilder = in.readQuery();
|
||||
filterBuilder = in.readNamedWriteable(QueryBuilder.class);
|
||||
}
|
||||
if (in.readBoolean()) {
|
||||
includeExclude = IncludeExclude.readFromStream(in);
|
||||
|
@ -89,7 +89,7 @@ public class SignificantTermsAggregatorBuilder extends ValuesSourceAggregatorBui
|
|||
boolean hasfilterBuilder = filterBuilder != null;
|
||||
out.writeBoolean(hasfilterBuilder);
|
||||
if (hasfilterBuilder) {
|
||||
out.writeQuery(filterBuilder);
|
||||
out.writeNamedWriteable(filterBuilder);
|
||||
}
|
||||
boolean hasIncExc = includeExclude != null;
|
||||
out.writeBoolean(hasIncExc);
|
||||
|
|
|
@ -217,10 +217,10 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
|
|||
minScore = in.readFloat();
|
||||
}
|
||||
if (in.readBoolean()) {
|
||||
postQueryBuilder = in.readQuery();
|
||||
postQueryBuilder = in.readNamedWriteable(QueryBuilder.class);
|
||||
}
|
||||
if (in.readBoolean()) {
|
||||
queryBuilder = in.readQuery();
|
||||
queryBuilder = in.readNamedWriteable(QueryBuilder.class);
|
||||
}
|
||||
if (in.readBoolean()) {
|
||||
int size = in.readVInt();
|
||||
|
@ -316,12 +316,12 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
|
|||
boolean hasPostQuery = postQueryBuilder != null;
|
||||
out.writeBoolean(hasPostQuery);
|
||||
if (hasPostQuery) {
|
||||
out.writeQuery(postQueryBuilder);
|
||||
out.writeNamedWriteable(postQueryBuilder);
|
||||
}
|
||||
boolean hasQuery = queryBuilder != null;
|
||||
out.writeBoolean(hasQuery);
|
||||
if (hasQuery) {
|
||||
out.writeQuery(queryBuilder);
|
||||
out.writeNamedWriteable(queryBuilder);
|
||||
}
|
||||
boolean hasRescoreBuilders = rescoreBuilders != null;
|
||||
out.writeBoolean(hasRescoreBuilders);
|
||||
|
|
|
@ -115,7 +115,7 @@ public abstract class AbstractHighlighterBuilder<HB extends AbstractHighlighterB
|
|||
highlighterType(in.readOptionalString());
|
||||
fragmenter(in.readOptionalString());
|
||||
if (in.readBoolean()) {
|
||||
highlightQuery(in.readQuery());
|
||||
highlightQuery(in.readNamedWriteable(QueryBuilder.class));
|
||||
}
|
||||
order(in.readOptionalWriteable(Order::readFromStream));
|
||||
highlightFilter(in.readOptionalBoolean());
|
||||
|
@ -146,7 +146,7 @@ public abstract class AbstractHighlighterBuilder<HB extends AbstractHighlighterB
|
|||
boolean hasQuery = highlightQuery != null;
|
||||
out.writeBoolean(hasQuery);
|
||||
if (hasQuery) {
|
||||
out.writeQuery(highlightQuery);
|
||||
out.writeNamedWriteable(highlightQuery);
|
||||
}
|
||||
out.writeOptionalWriteable(order);
|
||||
out.writeOptionalBoolean(highlightFilter);
|
||||
|
|
|
@ -79,7 +79,7 @@ public class QueryRescorerBuilder extends RescoreBuilder<QueryRescorerBuilder> {
|
|||
*/
|
||||
public QueryRescorerBuilder(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
queryBuilder = in.readQuery();
|
||||
queryBuilder = in.readNamedWriteable(QueryBuilder.class);
|
||||
scoreMode = QueryRescoreMode.readFromStream(in);
|
||||
rescoreQueryWeight = in.readFloat();
|
||||
queryWeight = in.readFloat();
|
||||
|
@ -87,7 +87,7 @@ public class QueryRescorerBuilder extends RescoreBuilder<QueryRescorerBuilder> {
|
|||
|
||||
@Override
|
||||
public void doWriteTo(StreamOutput out) throws IOException {
|
||||
out.writeQuery(queryBuilder);
|
||||
out.writeNamedWriteable(queryBuilder);
|
||||
scoreMode.writeTo(out);
|
||||
out.writeFloat(rescoreQueryWeight);
|
||||
out.writeFloat(queryWeight);
|
||||
|
|
|
@ -678,9 +678,9 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
|
|||
@SuppressWarnings("unchecked")
|
||||
protected <QB extends QueryBuilder> QB assertSerialization(QB testQuery) throws IOException {
|
||||
try (BytesStreamOutput output = new BytesStreamOutput()) {
|
||||
output.writeQuery(testQuery);
|
||||
output.writeNamedWriteable(testQuery);
|
||||
try (StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(output.bytes()), namedWriteableRegistry)) {
|
||||
QueryBuilder<?> deserializedQuery = in.readQuery();
|
||||
QueryBuilder<?> deserializedQuery = in.readNamedWriteable(QueryBuilder.class);
|
||||
assertEquals(testQuery, deserializedQuery);
|
||||
assertEquals(testQuery.hashCode(), deserializedQuery.hashCode());
|
||||
assertNotSame(testQuery, deserializedQuery);
|
||||
|
@ -727,9 +727,9 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
|
|||
@SuppressWarnings("unchecked")
|
||||
protected QB copyQuery(QB query) throws IOException {
|
||||
try (BytesStreamOutput output = new BytesStreamOutput()) {
|
||||
output.writeQuery(query);
|
||||
output.writeNamedWriteable(query);
|
||||
try (StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(output.bytes()), namedWriteableRegistry)) {
|
||||
return (QB) in.readQuery();
|
||||
return (QB) in.readNamedWriteable(QueryBuilder.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue