From 339d927ee4939ada0c65674f6342b43394269eb5 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Mon, 18 Apr 2016 21:07:46 -0400 Subject: [PATCH] Migrate more functions to (read|write)NamedWriteable ScoreFunction and Suggestion. Relates #17682. --- .../common/io/stream/StreamInput.java | 21 ------------------- .../common/io/stream/StreamOutput.java | 21 ------------------- .../FunctionScoreQueryBuilder.java | 8 +++---- .../search/suggest/SuggestBuilder.java | 4 ++-- .../AbstractSuggestionBuilderTestCase.java | 4 ++-- 5 files changed, 8 insertions(+), 50 deletions(-) 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 f60f87f7c90..37efb3f514b 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 @@ -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 */ 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 468a47b83ab..5655981d328 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 @@ -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); } } diff --git a/core/src/main/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilder.java index 3fcfa257c86..d95272626ed 100644 --- a/core/src/main/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilder.java @@ -354,14 +354,14 @@ public class FunctionScoreQueryBuilder extends AbstractQueryBuilder getFilter() { diff --git a/core/src/main/java/org/elasticsearch/search/suggest/SuggestBuilder.java b/core/src/main/java/org/elasticsearch/search/suggest/SuggestBuilder.java index b3493a9a66c..6095a4de70f 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/SuggestBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/SuggestBuilder.java @@ -65,7 +65,7 @@ public class SuggestBuilder extends ToXContentToBytes implements Writeable> suggestion : suggestions.entrySet()) { out.writeString(suggestion.getKey()); - out.writeSuggestion(suggestion.getValue()); + out.writeNamedWriteable(suggestion.getValue()); } } diff --git a/core/src/test/java/org/elasticsearch/search/suggest/AbstractSuggestionBuilderTestCase.java b/core/src/test/java/org/elasticsearch/search/suggest/AbstractSuggestionBuilderTestCase.java index 710f001a276..ed1bc323557 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/AbstractSuggestionBuilderTestCase.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/AbstractSuggestionBuilderTestCase.java @@ -217,9 +217,9 @@ public abstract class AbstractSuggestionBuilderTestCase