Remove deprecated methods in MoreLikeThisQueryBuilder (#36340)

The ids method is deprecated since 6.0 (at least) and only used in a few tests
internally, so we can safely remove it.
This commit is contained in:
Christoph Büscher 2018-12-07 11:14:41 +01:00 committed by GitHub
parent 60289e7331
commit 562479b5a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 28 deletions

View File

@ -305,15 +305,6 @@ public class MatchQueryBuilder extends AbstractQueryBuilder<MatchQueryBuilder> {
return this.fuzzyTranspositions; return this.fuzzyTranspositions;
} }
/**
* Sets whether format based failures will be ignored.
* @deprecated use #lenient() instead
*/
@Deprecated
public MatchQueryBuilder setLenient(boolean lenient) {
return lenient(lenient);
}
/** /**
* Sets whether format based failures will be ignored. * Sets whether format based failures will be ignored.
*/ */

View File

@ -752,21 +752,6 @@ public class MoreLikeThisQueryBuilder extends AbstractQueryBuilder<MoreLikeThisQ
return failOnUnsupportedField; return failOnUnsupportedField;
} }
/**
* Converts an array of String ids to and Item[].
* @param ids the ids to convert
* @return the new items array
* @deprecated construct the items array externally and use it in the constructor / setter
*/
@Deprecated
public static Item[] ids(String... ids) {
Item[] items = new Item[ids.length];
for (int i = 0; i < items.length; i++) {
items[i] = new Item(null, null, ids[i]);
}
return items;
}
@Override @Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException { protected void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(NAME); builder.startObject(NAME);

View File

@ -50,7 +50,6 @@ import static org.elasticsearch.client.Requests.refreshRequest;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.MoreLikeThisQueryBuilder.ids;
import static org.elasticsearch.index.query.QueryBuilders.moreLikeThisQuery; import static org.elasticsearch.index.query.QueryBuilders.moreLikeThisQuery;
import static org.elasticsearch.index.query.QueryBuilders.termQuery; import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
@ -452,7 +451,8 @@ public class MoreLikeThisIT extends ESIntegTestCase {
indexRandom(true, builders); indexRandom(true, builders);
logger.info("Running MoreLikeThis"); logger.info("Running MoreLikeThis");
MoreLikeThisQueryBuilder queryBuilder = QueryBuilders.moreLikeThisQuery(new String[] {"text"}, null, ids("1")).include(true) Item[] items = new Item[] { new Item(null, null, "1")};
MoreLikeThisQueryBuilder queryBuilder = QueryBuilders.moreLikeThisQuery(new String[] {"text"}, null, items).include(true)
.minTermFreq(1).minDocFreq(1); .minTermFreq(1).minDocFreq(1);
SearchResponse mltResponse = client().prepareSearch().setTypes("type1").setQuery(queryBuilder).get(); SearchResponse mltResponse = client().prepareSearch().setTypes("type1").setQuery(queryBuilder).get();
assertHitCount(mltResponse, 3L); assertHitCount(mltResponse, 3L);

View File

@ -26,7 +26,7 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.Fuzziness; import org.elasticsearch.common.unit.Fuzziness;
import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.query.MoreLikeThisQueryBuilder; import org.elasticsearch.index.query.MoreLikeThisQueryBuilder.Item;
import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.TermsQueryBuilder; import org.elasticsearch.index.query.TermsQueryBuilder;
@ -224,7 +224,8 @@ public class SimpleValidateQueryIT extends ESIntegTestCase {
containsString("(field:jumps)^0.75"), true); containsString("(field:jumps)^0.75"), true);
// more like this queries // more like this queries
assertExplanation(QueryBuilders.moreLikeThisQuery(new String[] { "field" }, null, MoreLikeThisQueryBuilder.ids("1")) Item[] items = new Item[] { new Item(null, null, "1")};
assertExplanation(QueryBuilders.moreLikeThisQuery(new String[] { "field" }, null, items)
.include(true).minTermFreq(1).minDocFreq(1).maxQueryTerms(2), .include(true).minTermFreq(1).minDocFreq(1).maxQueryTerms(2),
containsString("field:huge field:pidgin"), true); containsString("field:huge field:pidgin"), true);
assertExplanation(QueryBuilders.moreLikeThisQuery(new String[] { "field" }, new String[] {"the huge pidgin"}, null) assertExplanation(QueryBuilders.moreLikeThisQuery(new String[] { "field" }, new String[] {"the huge pidgin"}, null)