Replace (read|write)Rescorer with (read|write)NamedWriteable
This commit is contained in:
parent
d1722c9908
commit
98fa71868c
|
@ -34,14 +34,10 @@ import org.elasticsearch.common.Strings;
|
|||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.geo.builders.ShapeBuilder;
|
||||
import org.elasticsearch.common.text.Text;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilder;
|
||||
import org.elasticsearch.search.DocValueFormat;
|
||||
import org.elasticsearch.search.aggregations.AggregatorBuilder;
|
||||
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
|
||||
import org.elasticsearch.search.rescore.RescoreBuilder;
|
||||
import org.elasticsearch.search.sort.SortBuilder;
|
||||
import org.elasticsearch.search.suggest.SuggestionBuilder;
|
||||
import org.elasticsearch.search.suggest.phrase.SmoothingModel;
|
||||
|
@ -746,13 +742,6 @@ public abstract class StreamInput extends InputStream {
|
|||
return readNamedWriteable(QueryBuilder.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a {@link RescoreBuilder} from the current stream
|
||||
*/
|
||||
public RescoreBuilder<?> readRescorer() throws IOException {
|
||||
return readNamedWriteable(RescoreBuilder.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a {@link SuggestionBuilder} from the current stream
|
||||
*/
|
||||
|
|
|
@ -33,14 +33,10 @@ import org.elasticsearch.cluster.routing.allocation.command.AllocationCommand;
|
|||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.geo.builders.ShapeBuilder;
|
||||
import org.elasticsearch.common.text.Text;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilder;
|
||||
import org.elasticsearch.search.DocValueFormat;
|
||||
import org.elasticsearch.search.aggregations.AggregatorBuilder;
|
||||
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
|
||||
import org.elasticsearch.search.rescore.RescoreBuilder;
|
||||
import org.elasticsearch.search.sort.SortBuilder;
|
||||
import org.elasticsearch.search.suggest.SuggestionBuilder;
|
||||
import org.elasticsearch.search.suggest.phrase.SmoothingModel;
|
||||
|
@ -769,13 +765,6 @@ public abstract class StreamOutput extends OutputStream {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a {@link RescoreBuilder} to the current stream
|
||||
*/
|
||||
public void writeRescorer(RescoreBuilder<?> rescorer) throws IOException {
|
||||
writeNamedWriteable(rescorer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a {@link SuggestionBuilder} to the current stream
|
||||
*/
|
||||
|
|
|
@ -226,7 +226,7 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
|
|||
int size = in.readVInt();
|
||||
rescoreBuilders = new ArrayList<>();
|
||||
for (int i = 0; i < size; i++) {
|
||||
rescoreBuilders.add(in.readRescorer());
|
||||
rescoreBuilders.add(in.readNamedWriteable(RescoreBuilder.class));
|
||||
}
|
||||
}
|
||||
if (in.readBoolean()) {
|
||||
|
@ -328,7 +328,7 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
|
|||
if (hasRescoreBuilders) {
|
||||
out.writeVInt(rescoreBuilders.size());
|
||||
for (RescoreBuilder<?> rescoreBuilder : rescoreBuilders) {
|
||||
out.writeRescorer(rescoreBuilder);
|
||||
out.writeNamedWriteable(rescoreBuilder);
|
||||
}
|
||||
}
|
||||
boolean hasScriptFields = scriptFields != null;
|
||||
|
|
|
@ -335,9 +335,9 @@ public class QueryRescoreBuilderTests extends ESTestCase {
|
|||
|
||||
private static RescoreBuilder<?> serializedCopy(RescoreBuilder<?> original) throws IOException {
|
||||
try (BytesStreamOutput output = new BytesStreamOutput()) {
|
||||
output.writeRescorer(original);
|
||||
output.writeNamedWriteable(original);
|
||||
try (StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(output.bytes()), namedWriteableRegistry)) {
|
||||
return in.readRescorer();
|
||||
return in.readNamedWriteable(RescoreBuilder.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue