Migrate more functions to (read|write)NamedWriteable
ScoreFunction and Suggestion. Relates #17682.
This commit is contained in:
parent
ba08313417
commit
339d927ee4
|
@ -35,9 +35,6 @@ 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.elasticsearch.index.query.functionscore.ScoreFunctionBuilder;
|
||||
import org.elasticsearch.search.suggest.SuggestionBuilder;
|
||||
import org.elasticsearch.search.suggest.phrase.SmoothingModel;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
|
||||
|
@ -741,24 +738,6 @@ public abstract class StreamInput extends InputStream {
|
|||
return readNamedWriteable(QueryBuilder.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a {@link SuggestionBuilder} from the current stream
|
||||
* @deprecated prefer {@link #readNamedWriteable(Class)} passing {@link SuggestionBuilder}.
|
||||
*/
|
||||
@Deprecated
|
||||
public SuggestionBuilder<?> readSuggestion() throws IOException {
|
||||
return readNamedWriteable(SuggestionBuilder.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a {@link org.elasticsearch.index.query.functionscore.ScoreFunctionBuilder} from the current stream
|
||||
* @deprecated prefer {@link #readNamedWriteable(Class)} passing {@link ScoreFunctionBuilder}.
|
||||
*/
|
||||
@Deprecated
|
||||
public ScoreFunctionBuilder<?> readScoreFunction() throws IOException {
|
||||
return readNamedWriteable(ScoreFunctionBuilder.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a list of objects
|
||||
*/
|
||||
|
|
|
@ -34,9 +34,6 @@ 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.elasticsearch.index.query.functionscore.ScoreFunctionBuilder;
|
||||
import org.elasticsearch.search.suggest.SuggestionBuilder;
|
||||
import org.elasticsearch.search.suggest.phrase.SmoothingModel;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.joda.time.ReadableInstant;
|
||||
|
||||
|
@ -705,15 +702,6 @@ public abstract class StreamOutput extends OutputStream {
|
|||
writeNamedWriteable(queryBuilder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a {@link ScoreFunctionBuilder} to the current stream
|
||||
* @deprecated prefer {@link #writeNamedWriteable(NamedWriteable)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void writeScoreFunction(ScoreFunctionBuilder<?> scoreFunctionBuilder) throws IOException {
|
||||
writeNamedWriteable(scoreFunctionBuilder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the given {@link GeoPoint} to the stream
|
||||
*/
|
||||
|
@ -749,14 +737,5 @@ public abstract class StreamOutput extends OutputStream {
|
|||
for (T obj: list) {
|
||||
obj.writeTo(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a {@link SuggestionBuilder} to the current stream
|
||||
* @deprecated prefer {@link #writeNamedWriteable(NamedWriteable)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void writeSuggestion(SuggestionBuilder<?> suggestion) throws IOException {
|
||||
writeNamedWriteable(suggestion);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -354,14 +354,14 @@ public class FunctionScoreQueryBuilder extends AbstractQueryBuilder<FunctionScor
|
|||
* Read from a stream.
|
||||
*/
|
||||
public FilterFunctionBuilder(StreamInput in) throws IOException {
|
||||
filter = in.readQuery();
|
||||
scoreFunction = in.readScoreFunction();
|
||||
filter = in.readNamedWriteable(QueryBuilder.class);
|
||||
scoreFunction = in.readNamedWriteable(ScoreFunctionBuilder.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeQuery(filter);
|
||||
out.writeScoreFunction(scoreFunction);
|
||||
out.writeNamedWriteable(filter);
|
||||
out.writeNamedWriteable(scoreFunction);
|
||||
}
|
||||
|
||||
public QueryBuilder<?> getFilter() {
|
||||
|
|
|
@ -65,7 +65,7 @@ public class SuggestBuilder extends ToXContentToBytes implements Writeable<Sugge
|
|||
globalText = in.readOptionalString();
|
||||
final int size = in.readVInt();
|
||||
for (int i = 0; i < size; i++) {
|
||||
suggestions.put(in.readString(), in.readSuggestion());
|
||||
suggestions.put(in.readString(), in.readNamedWriteable(SuggestionBuilder.class));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ public class SuggestBuilder extends ToXContentToBytes implements Writeable<Sugge
|
|||
out.writeVInt(size);
|
||||
for (Entry<String, SuggestionBuilder<?>> suggestion : suggestions.entrySet()) {
|
||||
out.writeString(suggestion.getKey());
|
||||
out.writeSuggestion(suggestion.getValue());
|
||||
out.writeNamedWriteable(suggestion.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -217,9 +217,9 @@ public abstract class AbstractSuggestionBuilderTestCase<SB extends SuggestionBui
|
|||
@SuppressWarnings("unchecked")
|
||||
protected SB serializedCopy(SB original) throws IOException {
|
||||
try (BytesStreamOutput output = new BytesStreamOutput()) {
|
||||
output.writeSuggestion(original);
|
||||
output.writeNamedWriteable(original);
|
||||
try (StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(output.bytes()), namedWriteableRegistry)) {
|
||||
return (SB) in.readSuggestion();
|
||||
return (SB) in.readNamedWriteable(SuggestionBuilder.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue