Skip to content

Commit e85e3a8

Browse files
authored
Remove type parameter from Client.prepareIndex/Delete/Update(index, type) (#48185)
Types are no longer used in IndexRequest, DeleteRequest or UpdateRequest; this commit removes them from the prepareX(index, type) methods on Client, as well as removing setType() and deprecated constructors on XRequestBuilder objects. Note that Client.prepareIndex(index, type, id) is not affected by this PR and will be removed in a followup. Relates to #41059
1 parent 25d3add commit e85e3a8

File tree

169 files changed

+660
-692
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+660
-692
lines changed

modules/lang-expression/src/test/java/org/elasticsearch/script/expression/MoreExpressionTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,6 @@ public void testInvalidUpdateScript() throws Exception {
521521
ensureGreen("test_index");
522522
indexRandom(true, client().prepareIndex("test_index", "doc", "1").setSource("text_field", "text"));
523523
UpdateRequestBuilder urb = client().prepareUpdate().setIndex("test_index");
524-
urb.setType("doc");
525524
urb.setId("1");
526525
urb.setScript(new Script(ScriptType.INLINE, ExpressionScriptEngine.NAME, "0", Collections.emptyMap()));
527526
urb.get();

modules/lang-expression/src/test/java/org/elasticsearch/script/expression/StoredExpressionTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void testAllOpsDisabledIndexedScripts() throws IOException {
5656
.get();
5757
client().prepareIndex("test", "scriptTest", "1").setSource("{\"theField\":\"foo\"}", XContentType.JSON).get();
5858
try {
59-
client().prepareUpdate("test", "scriptTest", "1")
59+
client().prepareUpdate("test", "1")
6060
.setScript(new Script(ScriptType.STORED, null, "script1", Collections.emptyMap())).get();
6161
fail("update script should have been rejected");
6262
} catch(Exception e) {

modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ChildrenIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public void testWithDeletes() throws Exception {
192192
* the updates cause that.
193193
*/
194194
UpdateResponse updateResponse;
195-
updateResponse = client().prepareUpdate(indexName, "doc", idToUpdate)
195+
updateResponse = client().prepareUpdate(indexName, idToUpdate)
196196
.setRouting("1")
197197
.setDoc(Requests.INDEX_CONTENT_TYPE, "count", 1)
198198
.setDetectNoop(false)

modules/parent-join/src/test/java/org/elasticsearch/join/query/ChildQuerySearchIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ public void testParentChildQueriesCanHandleNoRelevantTypesInIndex() throws Excep
707707
assertNoFailures(response);
708708
assertThat(response.getHits().getTotalHits().value, equalTo(0L));
709709

710-
client().prepareIndex("test", "doc").setSource(jsonBuilder().startObject().field("text", "value").endObject())
710+
client().prepareIndex("test").setSource(jsonBuilder().startObject().field("text", "value").endObject())
711711
.setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
712712

713713
response = client().prepareSearch("test")

modules/rank-eval/src/test/java/org/elasticsearch/index/rankeval/RankEvalRequestIT.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.elasticsearch.action.search.SearchRequest;
2525
import org.elasticsearch.action.support.IndicesOptions;
2626
import org.elasticsearch.index.IndexNotFoundException;
27-
import org.elasticsearch.index.mapper.MapperService;
2827
import org.elasticsearch.index.query.MatchAllQueryBuilder;
2928
import org.elasticsearch.index.query.QueryBuilders;
3029
import org.elasticsearch.index.rankeval.PrecisionAtK.Detail;
@@ -61,21 +60,21 @@ public void setup() {
6160
createIndex(TEST_INDEX);
6261
ensureGreen();
6362

64-
client().prepareIndex(TEST_INDEX, MapperService.SINGLE_MAPPING_NAME).setId("1")
63+
client().prepareIndex(TEST_INDEX).setId("1")
6564
.setSource("text", "berlin", "title", "Berlin, Germany", "population", 3670622).get();
66-
client().prepareIndex(TEST_INDEX, MapperService.SINGLE_MAPPING_NAME).setId("2").setSource("text", "amsterdam", "population", 851573)
65+
client().prepareIndex(TEST_INDEX).setId("2").setSource("text", "amsterdam", "population", 851573)
6766
.get();
68-
client().prepareIndex(TEST_INDEX, MapperService.SINGLE_MAPPING_NAME).setId("3").setSource("text", "amsterdam", "population", 851573)
67+
client().prepareIndex(TEST_INDEX).setId("3").setSource("text", "amsterdam", "population", 851573)
6968
.get();
70-
client().prepareIndex(TEST_INDEX, MapperService.SINGLE_MAPPING_NAME).setId("4").setSource("text", "amsterdam", "population", 851573)
69+
client().prepareIndex(TEST_INDEX).setId("4").setSource("text", "amsterdam", "population", 851573)
7170
.get();
72-
client().prepareIndex(TEST_INDEX, MapperService.SINGLE_MAPPING_NAME).setId("5").setSource("text", "amsterdam", "population", 851573)
71+
client().prepareIndex(TEST_INDEX).setId("5").setSource("text", "amsterdam", "population", 851573)
7372
.get();
74-
client().prepareIndex(TEST_INDEX, MapperService.SINGLE_MAPPING_NAME).setId("6").setSource("text", "amsterdam", "population", 851573)
73+
client().prepareIndex(TEST_INDEX).setId("6").setSource("text", "amsterdam", "population", 851573)
7574
.get();
7675

7776
// add another index for testing closed indices etc...
78-
client().prepareIndex("test2", MapperService.SINGLE_MAPPING_NAME).setId("7").setSource("text", "amsterdam", "population", 851573)
77+
client().prepareIndex("test2").setId("7").setSource("text", "amsterdam", "population", 851573)
7978
.get();
8079
refresh();
8180

modules/reindex/src/test/java/org/elasticsearch/index/reindex/DeleteByQueryConcurrentTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void testConcurrentDeleteByQueriesOnDifferentDocs() throws Throwable {
4242
List<IndexRequestBuilder> builders = new ArrayList<>();
4343
for (int i = 0; i < docs; i++) {
4444
for (int t = 0; t < threads.length; t++) {
45-
builders.add(client().prepareIndex("test", "doc").setSource("field", t));
45+
builders.add(client().prepareIndex("test").setSource("field", t));
4646
}
4747
}
4848
indexRandom(true, true, true, builders);

modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexFromRemoteWithAuthTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected Settings nodeSettings() {
9191

9292
@Before
9393
public void setupSourceIndex() {
94-
client().prepareIndex("source", "test").setSource("test", "test").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
94+
client().prepareIndex("source").setSource("test", "test").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
9595
}
9696

9797
@Before

modules/reindex/src/test/java/org/elasticsearch/index/reindex/RetryTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ private void testCase(
177177
// Build the test data. Don't use indexRandom because that won't work consistently with such small thread pools.
178178
BulkRequestBuilder bulk = client().prepareBulk();
179179
for (int i = 0; i < DOC_COUNT; i++) {
180-
bulk.add(client().prepareIndex("source", "test").setSource("foo", "bar " + i));
180+
bulk.add(client().prepareIndex("source").setSource("foo", "bar " + i));
181181
}
182182

183183
Retry retry = new Retry(BackoffPolicy.exponentialBackoff(), client().threadPool());

plugins/repository-hdfs/src/test/java/org/elasticsearch/repositories/hdfs/HdfsTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ public void testSimpleWorkflow() {
102102

103103
logger.info("--> delete some data");
104104
for (int i = 0; i < 50; i++) {
105-
client.prepareDelete("test-idx-1", "doc", Integer.toString(i)).get();
105+
client.prepareDelete("test-idx-1", Integer.toString(i)).get();
106106
}
107107
for (int i = 50; i < 100; i++) {
108-
client.prepareDelete("test-idx-2", "doc", Integer.toString(i)).get();
108+
client.prepareDelete("test-idx-2", Integer.toString(i)).get();
109109
}
110110
for (int i = 0; i < 100; i += 2) {
111-
client.prepareDelete("test-idx-3", "doc", Integer.toString(i)).get();
111+
client.prepareDelete("test-idx-3", Integer.toString(i)).get();
112112
}
113113
client().admin().indices().prepareRefresh().get();
114114
assertThat(count(client, "test-idx-1"), equalTo(50L));

server/src/main/java/org/elasticsearch/action/delete/DeleteRequestBuilder.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,6 @@ public DeleteRequestBuilder(ElasticsearchClient client, DeleteAction action, @Nu
3939
super(client, action, new DeleteRequest(index));
4040
}
4141

42-
/**
43-
* Sets the type of the document to delete.
44-
* @deprecated types are being removed
45-
*/
46-
@Deprecated
47-
public DeleteRequestBuilder setType(String type) {
48-
return this;
49-
}
50-
5142
/**
5243
* Sets the id of the document to delete.
5344
*/

0 commit comments

Comments
 (0)