[Remove] Type from Client.prepare(Index,Delete,Update) (#2253)

Removes the type parameter from Client.prepare(Index,Delete,Update) and
everywhere it's used throughout the codebase except for prepareIndex(index,
type, id) which is removed in a follow up.

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
This commit is contained in:
Nick Knize 2022-02-24 21:20:03 -06:00 committed by GitHub
parent 9f6e2e56e0
commit 8b48207540
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
157 changed files with 795 additions and 951 deletions

View File

@ -114,7 +114,7 @@ public class IngestRestartIT extends OpenSearchIntegTestCase {
Exception e = expectThrows(
Exception.class,
() -> client().prepareIndex("index", "doc")
() -> client().prepareIndex("index")
.setId("1")
.setSource("x", 0)
.setPipeline(pipelineId)

View File

@ -566,7 +566,6 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
ensureGreen("test_index");
indexRandom(true, client().prepareIndex("test_index", "doc", "1").setSource("text_field", "text"));
UpdateRequestBuilder urb = client().prepareUpdate().setIndex("test_index");
urb.setType("doc");
urb.setId("1");
urb.setScript(new Script(ScriptType.INLINE, ExpressionScriptEngine.NAME, "0", Collections.emptyMap()));
urb.get();

View File

@ -71,9 +71,7 @@ public class StoredExpressionIT extends OpenSearchIntegTestCase {
.get();
client().prepareIndex("test", "scriptTest", "1").setSource("{\"theField\":\"foo\"}", XContentType.JSON).get();
try {
client().prepareUpdate("test", "scriptTest", "1")
.setScript(new Script(ScriptType.STORED, null, "script1", Collections.emptyMap()))
.get();
client().prepareUpdate("test", "1").setScript(new Script(ScriptType.STORED, null, "script1", Collections.emptyMap())).get();
fail("update script should have been rejected");
} catch (Exception e) {
assertThat(e.getMessage(), containsString("failed to execute script"));

View File

@ -207,7 +207,7 @@ public class ChildrenIT extends AbstractParentChildTestCase {
* the updates cause that.
*/
UpdateResponse updateResponse;
updateResponse = client().prepareUpdate(indexName, "doc", idToUpdate)
updateResponse = client().prepareUpdate(indexName, idToUpdate)
.setRouting("1")
.setDoc(Requests.INDEX_CONTENT_TYPE, "count", 1)
.setDetectNoop(false)

View File

@ -769,7 +769,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
assertNoFailures(response);
assertThat(response.getHits().getTotalHits().value, equalTo(0L));
client().prepareIndex("test", "doc")
client().prepareIndex("test")
.setSource(jsonBuilder().startObject().field("text", "value").endObject())
.setRefreshPolicy(RefreshPolicy.IMMEDIATE)
.get();

View File

@ -1215,7 +1215,7 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
.addMapping("_doc", "id", "type=keyword", "field1", "type=keyword", "query", "type=percolator")
);
client().prepareIndex("test", "_doc")
client().prepareIndex("test")
.setId("1")
.setSource(jsonBuilder().startObject().field("id", "1").field("query", matchQuery("field1", "value")).endObject())
.get();
@ -1264,13 +1264,13 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
assertAcked(client().admin().indices().prepareCreate("test").addMapping("_doc", "d", "type=date", "q", "type=percolator"));
client().prepareIndex("test", "_doc")
client().prepareIndex("test")
.setId("1")
.setSource(jsonBuilder().startObject().field("q", boolQuery().must(rangeQuery("d").gt("now"))).endObject())
.execute()
.actionGet();
client().prepareIndex("test", "_doc")
client().prepareIndex("test")
.setId("2")
.setSource(jsonBuilder().startObject().field("q", boolQuery().must(rangeQuery("d").lt("now"))).endObject())
.execute()

View File

@ -37,7 +37,6 @@ import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActi
import org.opensearch.action.search.SearchRequest;
import org.opensearch.action.support.IndicesOptions;
import org.opensearch.index.IndexNotFoundException;
import org.opensearch.index.mapper.MapperService;
import org.opensearch.index.query.MatchAllQueryBuilder;
import org.opensearch.index.query.QueryBuilders;
import org.opensearch.index.rankeval.PrecisionAtK.Detail;
@ -74,29 +73,18 @@ public class RankEvalRequestIT extends OpenSearchIntegTestCase {
createIndex(TEST_INDEX);
ensureGreen();
client().prepareIndex(TEST_INDEX, MapperService.SINGLE_MAPPING_NAME, "1")
client().prepareIndex(TEST_INDEX)
.setId("1")
.setSource("id", 1, "text", "berlin", "title", "Berlin, Germany", "population", 3670622)
.get();
client().prepareIndex(TEST_INDEX, MapperService.SINGLE_MAPPING_NAME, "2")
.setSource("id", 2, "text", "amsterdam", "population", 851573)
.get();
client().prepareIndex(TEST_INDEX, MapperService.SINGLE_MAPPING_NAME, "3")
.setSource("id", 3, "text", "amsterdam", "population", 851573)
.get();
client().prepareIndex(TEST_INDEX, MapperService.SINGLE_MAPPING_NAME, "4")
.setSource("id", 4, "text", "amsterdam", "population", 851573)
.get();
client().prepareIndex(TEST_INDEX, MapperService.SINGLE_MAPPING_NAME, "5")
.setSource("id", 5, "text", "amsterdam", "population", 851573)
.get();
client().prepareIndex(TEST_INDEX, MapperService.SINGLE_MAPPING_NAME, "6")
.setSource("id", 6, "text", "amsterdam", "population", 851573)
.get();
client().prepareIndex(TEST_INDEX).setId("2").setSource("id", 2, "text", "amsterdam", "population", 851573).get();
client().prepareIndex(TEST_INDEX).setId("3").setSource("id", 3, "text", "amsterdam", "population", 851573).get();
client().prepareIndex(TEST_INDEX).setId("4").setSource("id", 4, "text", "amsterdam", "population", 851573).get();
client().prepareIndex(TEST_INDEX).setId("5").setSource("id", 5, "text", "amsterdam", "population", 851573).get();
client().prepareIndex(TEST_INDEX).setId("6").setSource("id", 6, "text", "amsterdam", "population", 851573).get();
// add another index for testing closed indices etc...
client().prepareIndex("test2", MapperService.SINGLE_MAPPING_NAME, "7")
.setSource("id", 7, "text", "amsterdam", "population", 851573)
.get();
client().prepareIndex("test2").setId("7").setSource("id", 7, "text", "amsterdam", "population", 851573).get();
refresh();
// set up an alias that can also be used in tests

View File

@ -254,7 +254,7 @@ public class DeleteByQueryBasicTests extends ReindexTestCase {
final int docs = randomIntBetween(1, 50);
List<IndexRequestBuilder> builders = new ArrayList<>();
for (int i = 0; i < docs; i++) {
builders.add(client().prepareIndex("test", "test").setId(Integer.toString(i)).setSource("field", 1));
builders.add(client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", 1));
}
indexRandom(true, true, true, builders);

View File

@ -55,7 +55,7 @@ public class DeleteByQueryConcurrentTests extends ReindexTestCase {
List<IndexRequestBuilder> builders = new ArrayList<>();
for (int i = 0; i < docs; i++) {
for (int t = 0; t < threads.length; t++) {
builders.add(client().prepareIndex("test", "doc").setSource("field", t));
builders.add(client().prepareIndex("test").setSource("field", t));
}
}
indexRandom(true, true, true, builders);

View File

@ -106,7 +106,7 @@ public class ReindexFromRemoteWithAuthTests extends OpenSearchSingleNodeTestCase
@Before
public void setupSourceIndex() {
client().prepareIndex("source", "test").setSource("test", "test").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareIndex("source").setSource("test", "test").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
}
@Before

View File

@ -52,7 +52,7 @@ public class ReindexSingleNodeTests extends OpenSearchSingleNodeTestCase {
public void testDeprecatedSort() {
int max = between(2, 20);
for (int i = 0; i < max; i++) {
client().prepareIndex("source", "_doc").setId(Integer.toString(i)).setSource("foo", i).get();
client().prepareIndex("source").setId(Integer.toString(i)).setSource("foo", i).get();
}
client().admin().indices().prepareRefresh("source").get();

View File

@ -198,7 +198,7 @@ public class RetryTests extends OpenSearchIntegTestCase {
// Build the test data. Don't use indexRandom because that won't work consistently with such small thread pools.
BulkRequestBuilder bulk = client().prepareBulk();
for (int i = 0; i < DOC_COUNT; i++) {
bulk.add(client().prepareIndex("source", "test").setSource("foo", "bar " + i));
bulk.add(client().prepareIndex("source").setSource("foo", "bar " + i));
}
Retry retry = new Retry(BackoffPolicy.exponentialBackoff(), client().threadPool());

View File

@ -117,13 +117,13 @@ public class HdfsTests extends OpenSearchSingleNodeTestCase {
logger.info("--> delete some data");
for (int i = 0; i < 50; i++) {
client.prepareDelete("test-idx-1", "doc", Integer.toString(i)).get();
client.prepareDelete("test-idx-1", Integer.toString(i)).get();
}
for (int i = 50; i < 100; i++) {
client.prepareDelete("test-idx-2", "doc", Integer.toString(i)).get();
client.prepareDelete("test-idx-2", Integer.toString(i)).get();
}
for (int i = 0; i < 100; i += 2) {
client.prepareDelete("test-idx-3", "doc", Integer.toString(i)).get();
client.prepareDelete("test-idx-3", Integer.toString(i)).get();
}
client().admin().indices().prepareRefresh().get();
assertThat(count(client, "test-idx-1"), equalTo(50L));

View File

@ -475,7 +475,7 @@ public class TasksIT extends OpenSearchIntegTestCase {
}
// Need to run the task in a separate thread because node client's .execute() is blocked by our task listener
index = new Thread(() -> {
IndexResponse indexResponse = client().prepareIndex("test", "test").setSource("test", "test").get();
IndexResponse indexResponse = client().prepareIndex("test").setSource("test", "test").get();
assertArrayEquals(ReplicationResponse.EMPTY, indexResponse.getShardInfo().getFailures());
});
index.start();

View File

@ -73,11 +73,11 @@ public class SnapshotBlocksIT extends OpenSearchIntegTestCase {
int docs = between(10, 100);
for (int i = 0; i < docs; i++) {
client().prepareIndex(INDEX_NAME, "type").setSource("test", "init").execute().actionGet();
client().prepareIndex(INDEX_NAME).setSource("test", "init").execute().actionGet();
}
docs = between(10, 100);
for (int i = 0; i < docs; i++) {
client().prepareIndex(OTHER_INDEX_NAME, "type").setSource("test", "init").execute().actionGet();
client().prepareIndex(OTHER_INDEX_NAME).setSource("test", "init").execute().actionGet();
}
logger.info("--> register a repository");

View File

@ -62,7 +62,7 @@ public class CloneIndexIT extends OpenSearchIntegTestCase {
).get();
final int docs = randomIntBetween(0, 128);
for (int i = 0; i < docs; i++) {
client().prepareIndex("source", "type").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
client().prepareIndex("source").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
}
internalCluster().ensureAtLeastNumDataNodes(2);
// ensure all shards are allocated otherwise the ensure green below might not succeed since we require the merge node
@ -122,7 +122,7 @@ public class CloneIndexIT extends OpenSearchIntegTestCase {
}
for (int i = docs; i < 2 * docs; i++) {
client().prepareIndex("target", "type").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
client().prepareIndex("target").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
}
flushAndRefresh();
assertHitCount(

View File

@ -276,7 +276,7 @@ public class CreateIndexIT extends OpenSearchIntegTestCase {
final CountDownLatch latch = new CountDownLatch(1);
int numDocs = randomIntBetween(1, 10);
for (int i = 0; i < numDocs; i++) {
client().prepareIndex("test", "test").setSource("index_version", indexVersion.get()).get();
client().prepareIndex("test").setSource("index_version", indexVersion.get()).get();
}
synchronized (indexVersionLock) { // not necessarily needed here but for completeness we lock here too
indexVersion.incrementAndGet();
@ -289,7 +289,7 @@ public class CreateIndexIT extends OpenSearchIntegTestCase {
public void run() {
try {
// recreate that index
client().prepareIndex("test", "test").setSource("index_version", indexVersion.get()).get();
client().prepareIndex("test").setSource("index_version", indexVersion.get()).get();
synchronized (indexVersionLock) {
// we sync here since we have to ensure that all indexing operations below for a given ID are done before
// we increment the index version otherwise a doc that is in-flight could make it into an index that it
@ -315,7 +315,7 @@ public class CreateIndexIT extends OpenSearchIntegTestCase {
for (int i = 0; i < numDocs; i++) {
try {
synchronized (indexVersionLock) {
client().prepareIndex("test", "test")
client().prepareIndex("test")
.setSource("index_version", indexVersion.get())
.setTimeout(TimeValue.timeValueSeconds(10))
.get();

View File

@ -292,7 +292,7 @@ public class ShrinkIndexIT extends OpenSearchIntegTestCase {
).get();
final int docs = randomIntBetween(0, 128);
for (int i = 0; i < docs; i++) {
client().prepareIndex("source", "type").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
client().prepareIndex("source").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
}
ImmutableOpenMap<String, DiscoveryNode> dataNodes = client().admin()
.cluster()
@ -393,7 +393,7 @@ public class ShrinkIndexIT extends OpenSearchIntegTestCase {
}
for (int i = docs; i < 2 * docs; i++) {
client().prepareIndex("target", "type").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
client().prepareIndex("target").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
}
flushAndRefresh();
assertHitCount(client().prepareSearch("target").setSize(2 * size).setQuery(new TermsQueryBuilder("foo", "bar")).get(), 2 * docs);
@ -420,7 +420,7 @@ public class ShrinkIndexIT extends OpenSearchIntegTestCase {
Settings.builder().put(indexSettings()).put("number_of_shards", randomIntBetween(2, 7)).put("number_of_replicas", 0)
).get();
for (int i = 0; i < 20; i++) {
client().prepareIndex("source", "type").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
client().prepareIndex("source").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
}
ImmutableOpenMap<String, DiscoveryNode> dataNodes = client().admin()
.cluster()
@ -595,7 +595,7 @@ public class ShrinkIndexIT extends OpenSearchIntegTestCase {
// ... and that the index sort is also applied to updates
for (int i = 20; i < 40; i++) {
client().prepareIndex("target", "type").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
client().prepareIndex("target").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
}
flushAndRefresh();
assertSortedSegments("target", expectedIndexSort);
@ -606,7 +606,7 @@ public class ShrinkIndexIT extends OpenSearchIntegTestCase {
Settings.builder().put(indexSettings()).put("index.number_of_replicas", 0).put("number_of_shards", 5)
).get();
for (int i = 0; i < 30; i++) {
client().prepareIndex("source", "type").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
client().prepareIndex("source").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
}
client().admin().indices().prepareFlush("source").get();
ImmutableOpenMap<String, DiscoveryNode> dataNodes = client().admin()

View File

@ -402,7 +402,7 @@ public class SplitIndexIT extends OpenSearchIntegTestCase {
).get();
final int docs = randomIntBetween(0, 128);
for (int i = 0; i < docs; i++) {
client().prepareIndex("source", "type").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
client().prepareIndex("source").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
}
// ensure all shards are allocated otherwise the ensure green below might not succeed since we require the merge node
// if we change the setting too quickly we will end up with one replica unassigned which can't be assigned anymore due
@ -486,7 +486,7 @@ public class SplitIndexIT extends OpenSearchIntegTestCase {
}
for (int i = docs; i < 2 * docs; i++) {
client().prepareIndex("target", "type").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
client().prepareIndex("target").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
}
flushAndRefresh();
assertHitCount(
@ -580,7 +580,7 @@ public class SplitIndexIT extends OpenSearchIntegTestCase {
// ... and that the index sort is also applied to updates
for (int i = 20; i < 40; i++) {
client().prepareIndex("target", "type").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
client().prepareIndex("target").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
}
flushAndRefresh();
assertSortedSegments("target", expectedIndexSort);

View File

@ -58,14 +58,14 @@ public class DeleteIndexBlocksIT extends OpenSearchIntegTestCase {
public void testDeleteIndexOnIndexReadOnlyAllowDeleteSetting() {
createIndex("test");
ensureGreen("test");
client().prepareIndex().setIndex("test").setType("doc").setId("1").setSource("foo", "bar").get();
client().prepareIndex().setIndex("test").setId("1").setSource("foo", "bar").get();
refresh();
try {
Settings settings = Settings.builder().put(IndexMetadata.SETTING_READ_ONLY_ALLOW_DELETE, true).build();
assertAcked(client().admin().indices().prepareUpdateSettings("test").setSettings(settings).get());
assertSearchHits(client().prepareSearch().get(), "1");
assertBlocked(
client().prepareIndex().setIndex("test").setType("doc").setId("2").setSource("foo", "bar"),
client().prepareIndex().setIndex("test").setId("2").setSource("foo", "bar"),
IndexMetadata.INDEX_READ_ONLY_ALLOW_DELETE_BLOCK
);
assertBlocked(
@ -95,7 +95,7 @@ public class DeleteIndexBlocksIT extends OpenSearchIntegTestCase {
client().admin().indices().prepareUpdateSettings("test").setSettings(settings).get();
ClusterBlockException e = expectThrows(
ClusterBlockException.class,
() -> client().prepareIndex().setIndex("test").setType("doc").setId("1").setSource("foo", "bar").get()
() -> client().prepareIndex().setIndex("test").setId("1").setSource("foo", "bar").get()
);
assertEquals(
"index [test] blocked by: [TOO_MANY_REQUESTS/12/disk usage exceeded flood-stage watermark, "
@ -116,14 +116,14 @@ public class DeleteIndexBlocksIT extends OpenSearchIntegTestCase {
public void testDeleteIndexOnClusterReadOnlyAllowDeleteSetting() {
createIndex("test");
ensureGreen("test");
client().prepareIndex().setIndex("test").setType("doc").setId("1").setSource("foo", "bar").get();
client().prepareIndex().setIndex("test").setId("1").setSource("foo", "bar").get();
refresh();
try {
Settings settings = Settings.builder().put(Metadata.SETTING_READ_ONLY_ALLOW_DELETE_SETTING.getKey(), true).build();
assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(settings).get());
assertSearchHits(client().prepareSearch().get(), "1");
assertBlocked(
client().prepareIndex().setIndex("test").setType("doc").setId("2").setSource("foo", "bar"),
client().prepareIndex().setIndex("test").setId("2").setSource("foo", "bar"),
Metadata.CLUSTER_READ_ONLY_ALLOW_DELETE_BLOCK
);
assertBlocked(

View File

@ -236,7 +236,7 @@ public class IndicesShardStoreRequestIT extends OpenSearchIntegTestCase {
int numDocs = scaledRandomIntBetween(10, 20);
IndexRequestBuilder[] builders = new IndexRequestBuilder[numDocs];
for (int i = 0; i < builders.length; i++) {
builders[i] = client().prepareIndex(index, "type").setSource("field", "value");
builders[i] = client().prepareIndex(index).setSource("field", "value");
}
indexRandom(true, builders);
client().admin().indices().prepareFlush().setForce(true).execute().actionGet();

View File

@ -128,10 +128,10 @@ public class BulkIntegrationIT extends OpenSearchIntegTestCase {
assertThat(bulkResponse.getItems()[0].getResponse().status(), equalTo(RestStatus.CREATED));
assertThat(client().prepareGet("index3", "id").setRouting("1").get().getSource().get("foo"), equalTo("baz"));
bulkResponse = client().prepareBulk().add(client().prepareUpdate("alias1", "type", "id").setDoc("foo", "updated")).get();
bulkResponse = client().prepareBulk().add(client().prepareUpdate("alias1", "id").setDoc("foo", "updated")).get();
assertFalse(bulkResponse.buildFailureMessage(), bulkResponse.hasFailures());
assertThat(client().prepareGet("index3", "id").setRouting("1").get().getSource().get("foo"), equalTo("updated"));
bulkResponse = client().prepareBulk().add(client().prepareDelete("alias1", "type", "id")).get();
bulkResponse = client().prepareBulk().add(client().prepareDelete("alias1", "id")).get();
assertFalse(bulkResponse.buildFailureMessage(), bulkResponse.hasFailures());
assertFalse(client().prepareGet("index3", "id").setRouting("1").get().isExists());
}
@ -200,7 +200,7 @@ public class BulkIntegrationIT extends OpenSearchIntegTestCase {
while (stopped.get() == false && docID.get() < 5000) {
String id = Integer.toString(docID.incrementAndGet());
try {
IndexResponse response = client().prepareIndex(index, "_doc")
IndexResponse response = client().prepareIndex(index)
.setId(id)
.setSource(Collections.singletonMap("f" + randomIntBetween(1, 10), randomNonNegativeLong()), XContentType.JSON)
.get();

View File

@ -57,7 +57,6 @@ import static org.hamcrest.Matchers.lessThanOrEqualTo;
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.SUITE, numDataNodes = 2)
public class BulkProcessorRetryIT extends OpenSearchIntegTestCase {
private static final String INDEX_NAME = "test";
private static final String TYPE_NAME = "type";
@Override
protected Settings nodeSettings(int nodeOrdinal) {
@ -186,7 +185,6 @@ public class BulkProcessorRetryIT extends OpenSearchIntegTestCase {
processor.add(
client().prepareIndex()
.setIndex(INDEX_NAME)
.setType(TYPE_NAME)
.setId(Integer.toString(i))
.setSource("field", randomRealisticUnicodeOfLengthBetween(1, 30))
.request()

View File

@ -137,11 +137,11 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
ensureGreen();
BulkResponse bulkResponse = client().prepareBulk()
.add(client().prepareIndex().setIndex(indexOrAlias()).setType("type1").setId("1").setSource("field", 1))
.add(client().prepareIndex().setIndex(indexOrAlias()).setType("type1").setId("2").setSource("field", 2).setCreate(true))
.add(client().prepareIndex().setIndex(indexOrAlias()).setType("type1").setId("3").setSource("field", 3))
.add(client().prepareIndex().setIndex(indexOrAlias()).setType("type1").setId("4").setSource("field", 4))
.add(client().prepareIndex().setIndex(indexOrAlias()).setType("type1").setId("5").setSource("field", 5))
.add(client().prepareIndex().setIndex(indexOrAlias()).setId("1").setSource("field", 1))
.add(client().prepareIndex().setIndex(indexOrAlias()).setId("2").setSource("field", 2).setCreate(true))
.add(client().prepareIndex().setIndex(indexOrAlias()).setId("3").setSource("field", 3))
.add(client().prepareIndex().setIndex(indexOrAlias()).setId("4").setSource("field", 4))
.add(client().prepareIndex().setIndex(indexOrAlias()).setId("5").setSource("field", 5))
.execute()
.actionGet();
@ -154,12 +154,11 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
final Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "ctx._source.field += 1", Collections.emptyMap());
bulkResponse = client().prepareBulk()
.add(client().prepareUpdate().setIndex(indexOrAlias()).setType("type1").setId("1").setScript(script))
.add(client().prepareUpdate().setIndex(indexOrAlias()).setType("type1").setId("2").setScript(script).setRetryOnConflict(3))
.add(client().prepareUpdate().setIndex(indexOrAlias()).setId("1").setScript(script))
.add(client().prepareUpdate().setIndex(indexOrAlias()).setId("2").setScript(script).setRetryOnConflict(3))
.add(
client().prepareUpdate()
.setIndex(indexOrAlias())
.setType("type1")
.setId("3")
.setDoc(jsonBuilder().startObject().field("field1", "test").endObject())
)
@ -196,13 +195,12 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
.add(
client().prepareUpdate()
.setIndex(indexOrAlias())
.setType("type1")
.setId("6")
.setScript(script)
.setUpsert(jsonBuilder().startObject().field("field", 0).endObject())
)
.add(client().prepareUpdate().setIndex(indexOrAlias()).setType("type1").setId("7").setScript(script))
.add(client().prepareUpdate().setIndex(indexOrAlias()).setType("type1").setId("2").setScript(script))
.add(client().prepareUpdate().setIndex(indexOrAlias()).setId("7").setScript(script))
.add(client().prepareUpdate().setIndex(indexOrAlias()).setId("2").setScript(script))
.get();
assertThat(bulkResponse.hasFailures(), equalTo(true));
@ -286,19 +284,9 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
assertThat(bulkResponse.getItems()[2].getResponse().getSeqNo(), equalTo(2L));
bulkResponse = client().prepareBulk()
.add(
client().prepareUpdate("test", "type", "1")
.setIfSeqNo(40L)
.setIfPrimaryTerm(20)
.setDoc(Requests.INDEX_CONTENT_TYPE, "field", "2")
)
.add(client().prepareUpdate("test", "type", "2").setDoc(Requests.INDEX_CONTENT_TYPE, "field", "2"))
.add(
client().prepareUpdate("test", "type", "1")
.setIfSeqNo(2L)
.setIfPrimaryTerm(1)
.setDoc(Requests.INDEX_CONTENT_TYPE, "field", "3")
)
.add(client().prepareUpdate("test", "1").setIfSeqNo(40L).setIfPrimaryTerm(20).setDoc(Requests.INDEX_CONTENT_TYPE, "field", "2"))
.add(client().prepareUpdate("test", "2").setDoc(Requests.INDEX_CONTENT_TYPE, "field", "2"))
.add(client().prepareUpdate("test", "1").setIfSeqNo(2L).setIfPrimaryTerm(1).setDoc(Requests.INDEX_CONTENT_TYPE, "field", "3"))
.get();
assertThat(bulkResponse.getItems()[0].getFailureMessage(), containsString("version conflict"));
@ -319,18 +307,8 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
assertThat(bulkResponse.getItems()[2].getResponse().getVersion(), equalTo(12L));
bulkResponse = client().prepareBulk()
.add(
client().prepareUpdate("test", "type", "e1")
.setDoc(Requests.INDEX_CONTENT_TYPE, "field", "2")
.setIfSeqNo(10L)
.setIfPrimaryTerm(1)
)
.add(
client().prepareUpdate("test", "type", "e1")
.setDoc(Requests.INDEX_CONTENT_TYPE, "field", "3")
.setIfSeqNo(20L)
.setIfPrimaryTerm(1)
)
.add(client().prepareUpdate("test", "e1").setDoc(Requests.INDEX_CONTENT_TYPE, "field", "2").setIfSeqNo(10L).setIfPrimaryTerm(1))
.add(client().prepareUpdate("test", "e1").setDoc(Requests.INDEX_CONTENT_TYPE, "field", "3").setIfSeqNo(20L).setIfPrimaryTerm(1))
.get();
assertThat(bulkResponse.getItems()[0].getFailureMessage(), containsString("version conflict"));
@ -342,9 +320,9 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
ensureGreen();
BulkResponse bulkResponse = client().prepareBulk()
.add(client().prepareIndex().setIndex("test").setType("type1").setId("1").setSource("field", 1))
.add(client().prepareIndex().setIndex("test").setType("type1").setId("2").setSource("field", 1))
.add(client().prepareIndex().setIndex("test").setType("type1").setId("3").setSource("field", 1))
.add(client().prepareIndex().setIndex("test").setId("1").setSource("field", 1))
.add(client().prepareIndex().setIndex("test").setId("2").setSource("field", 1))
.add(client().prepareIndex().setIndex("test").setId("3").setSource("field", 1))
.execute()
.actionGet();
@ -355,7 +333,6 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
.add(
client().prepareUpdate()
.setIndex("test")
.setType("type1")
.setId("1")
.setFetchSource("field", null)
.setScript(
@ -370,7 +347,6 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
.add(
client().prepareUpdate()
.setIndex("test")
.setType("type1")
.setId("2")
.setFetchSource("field", null)
.setScript(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "ctx._source.field += 1", Collections.emptyMap()))
@ -378,7 +354,6 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
.add(
client().prepareUpdate()
.setIndex("test")
.setType("type1")
.setId("3")
.setFetchSource("field", null)
.setScript(
@ -425,7 +400,6 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
builder.add(
client().prepareUpdate()
.setIndex("test")
.setType("type1")
.setId(Integer.toString(i))
.setFetchSource("counter", null)
.setScript(script)
@ -457,7 +431,6 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
for (int i = 0; i < numDocs; i++) {
UpdateRequestBuilder updateBuilder = client().prepareUpdate()
.setIndex("test")
.setType("type1")
.setId(Integer.toString(i))
.setFetchSource("counter", null);
if (i % 2 == 0) {
@ -488,7 +461,7 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
builder = client().prepareBulk();
int maxDocs = numDocs / 2 + numDocs;
for (int i = (numDocs / 2); i < maxDocs; i++) {
builder.add(client().prepareUpdate().setIndex("test").setType("type1").setId(Integer.toString(i)).setScript(script));
builder.add(client().prepareUpdate().setIndex("test").setId(Integer.toString(i)).setScript(script));
}
response = builder.execute().actionGet();
assertThat(response.hasFailures(), equalTo(true));
@ -511,7 +484,6 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
builder.add(
client().prepareUpdate()
.setIndex("test")
.setType("type1")
.setId(Integer.toString(i))
.setScript(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "ctx.op = \"none\"", Collections.emptyMap()))
);
@ -531,7 +503,6 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
builder.add(
client().prepareUpdate()
.setIndex("test")
.setType("type1")
.setId(Integer.toString(i))
.setScript(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "ctx.op = \"delete\"", Collections.emptyMap()))
);
@ -599,7 +570,7 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
}
BulkRequestBuilder requestBuilder = client().prepareBulk();
requestBuilder.add(
client().prepareUpdate("test", "type", "1")
client().prepareUpdate("test", "1")
.setIfSeqNo(0L)
.setIfPrimaryTerm(1)
.setDoc(Requests.INDEX_CONTENT_TYPE, "field", threadID)
@ -643,7 +614,7 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
} else {
name = "test";
}
builder.add(client().prepareIndex().setIndex(name).setType("type1").setId("1").setSource("field", 1));
builder.add(client().prepareIndex().setIndex(name).setId("1").setSource("field", 1));
}
BulkResponse bulkResponse = builder.get();
assertThat(bulkResponse.hasFailures(), is(expectFailure));
@ -744,21 +715,9 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
// issue 9821
public void testInvalidIndexNamesCorrectOpType() {
BulkResponse bulkResponse = client().prepareBulk()
.add(
client().prepareIndex()
.setIndex("INVALID.NAME")
.setType("type1")
.setId("1")
.setSource(Requests.INDEX_CONTENT_TYPE, "field", 1)
)
.add(
client().prepareUpdate()
.setIndex("INVALID.NAME")
.setType("type1")
.setId("1")
.setDoc(Requests.INDEX_CONTENT_TYPE, "field", randomInt())
)
.add(client().prepareDelete().setIndex("INVALID.NAME").setType("type1").setId("1"))
.add(client().prepareIndex().setIndex("INVALID.NAME").setId("1").setSource(Requests.INDEX_CONTENT_TYPE, "field", 1))
.add(client().prepareUpdate().setIndex("INVALID.NAME").setId("1").setDoc(Requests.INDEX_CONTENT_TYPE, "field", randomInt()))
.add(client().prepareDelete().setIndex("INVALID.NAME").setId("1"))
.get();
assertThat(bulkResponse.getItems().length, is(3));
assertThat(bulkResponse.getItems()[0].getOpType(), is(OpType.INDEX));

View File

@ -358,9 +358,9 @@ public class TransportSearchIT extends OpenSearchIntegTestCase {
}
}
});
client().prepareIndex("test", "_doc").setId("1").setSource("created_date", "2020-01-01").get();
client().prepareIndex("test", "_doc").setId("2").setSource("created_date", "2020-01-02").get();
client().prepareIndex("test", "_doc").setId("3").setSource("created_date", "2020-01-03").get();
client().prepareIndex("test").setId("1").setSource("created_date", "2020-01-01").get();
client().prepareIndex("test").setId("2").setSource("created_date", "2020-01-02").get();
client().prepareIndex("test").setId("3").setSource("created_date", "2020-01-03").get();
assertBusy(() -> {
SearchResponse resp = client().prepareSearch("test")
.setQuery(new RangeQueryBuilder("created_date").gte("2020-01-02").lte("2020-01-03"))
@ -491,7 +491,7 @@ public class TransportSearchIT extends OpenSearchIntegTestCase {
createIndex(indexName, Settings.builder().put("index.number_of_shards", numberOfShards).build());
for (int i = 0; i < numberOfDocs; i++) {
IndexResponse indexResponse = client().prepareIndex(indexName, "_doc").setSource("number", randomInt()).get();
IndexResponse indexResponse = client().prepareIndex(indexName).setSource("number", randomInt()).get();
assertEquals(RestStatus.CREATED, indexResponse.status());
}
client().admin().indices().prepareRefresh(indexName).get();

View File

@ -97,8 +97,8 @@ public class IndexingMasterFailoverIT extends OpenSearchIntegTestCase {
return;
}
for (int i = 0; i < 10; i++) {
// index data with mapping changes
IndexResponse response = client(dataNode).prepareIndex("myindex", "mytype").setSource("field_" + i, "val").get();
// index data
IndexResponse response = client(dataNode).prepareIndex("myindex").setSource("field_" + i, "val").get();
assertEquals(DocWriteResponse.Result.CREATED, response.getResult());
}
}

View File

@ -186,7 +186,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
List<IndexRequestBuilder> indexBuilders = new ArrayList<>();
for (int i = 0; i < 6; i++) {
indexBuilders.add(client().prepareIndex().setIndex("test").setType("type1").setId(String.valueOf(i)).setSource("field" + i, i));
indexBuilders.add(client().prepareIndex().setIndex("test").setId(String.valueOf(i)).setSource("field" + i, i));
}
indexRandom(true, indexBuilders);
@ -575,9 +575,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
List<IndexRequestBuilder> indexBuilders = new ArrayList<>();
for (String indexName : indexNames) {
for (int id = 0; id < content.length; id++) {
indexBuilders.add(
client().prepareIndex().setIndex(indexName).setType("type1").setId(String.valueOf(id)).setSource("field1", content[id])
);
indexBuilders.add(client().prepareIndex().setIndex(indexName).setId(String.valueOf(id)).setSource("field1", content[id]));
}
}
indexRandom(true, indexBuilders);
@ -680,9 +678,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
List<IndexRequestBuilder> indexBuilders = new ArrayList<>();
for (int i = 0; i < content.length; i++) {
indexBuilders.add(
client().prepareIndex().setIndex("test").setType("type1").setId(String.valueOf(i)).setSource("field1", content[i])
);
indexBuilders.add(client().prepareIndex().setIndex("test").setId(String.valueOf(i)).setSource("field1", content[i]));
}
indexRandom(true, indexBuilders);
@ -1111,7 +1107,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
indexBuilders.add(
client().prepareIndex()
.setIndex(indexName)
.setType("type1")
.setId(String.valueOf(id))
.setSource("field1", content[id], "field2", content[id])
);

View File

@ -1206,7 +1206,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
final int numDocs = scaledRandomIntBetween(5, 52);
for (int i = 1; i <= numDocs; i++) {
client().prepareIndex("my-index", "my-type").setSource("timestamp", "2016-12-12").get();
client().prepareIndex("my-index").setSource("timestamp", "2016-12-12").get();
if (i % 2 == 0) {
refresh();
SearchResponse response = client().prepareSearch("filter1").get();

View File

@ -162,7 +162,7 @@ public class SimpleBlocksIT extends OpenSearchIntegTestCase {
private void canIndexDocument(String index) {
try {
IndexRequestBuilder builder = client().prepareIndex(index, "zzz");
IndexRequestBuilder builder = client().prepareIndex(index);
builder.setSource("foo", "bar");
IndexResponse r = builder.execute().actionGet();
assertThat(r, notNullValue());
@ -173,7 +173,7 @@ public class SimpleBlocksIT extends OpenSearchIntegTestCase {
private void canNotIndexDocument(String index) {
try {
IndexRequestBuilder builder = client().prepareIndex(index, "zzz");
IndexRequestBuilder builder = client().prepareIndex(index);
builder.setSource("foo", "bar");
builder.execute().actionGet();
fail();
@ -306,7 +306,7 @@ public class SimpleBlocksIT extends OpenSearchIntegTestCase {
false,
randomBoolean(),
IntStream.range(0, nbDocs)
.mapToObj(i -> client().prepareIndex(indexName, "zzz").setId(String.valueOf(i)).setSource("num", i))
.mapToObj(i -> client().prepareIndex(indexName).setId(String.valueOf(i)).setSource("num", i))
.collect(toList())
);
@ -332,7 +332,7 @@ public class SimpleBlocksIT extends OpenSearchIntegTestCase {
false,
randomBoolean(),
IntStream.range(0, randomIntBetween(1, 10))
.mapToObj(i -> client().prepareIndex(indexName, "zzz").setId(String.valueOf(i)).setSource("num", i))
.mapToObj(i -> client().prepareIndex(indexName).setId(String.valueOf(i)).setSource("num", i))
.collect(toList())
);
}
@ -378,7 +378,7 @@ public class SimpleBlocksIT extends OpenSearchIntegTestCase {
false,
randomBoolean(),
IntStream.range(0, nbDocs)
.mapToObj(i -> client().prepareIndex(indexName, "zzz").setId(String.valueOf(i)).setSource("num", i))
.mapToObj(i -> client().prepareIndex(indexName).setId(String.valueOf(i)).setSource("num", i))
.collect(toList())
);
ensureYellowAndNoInitializingShards(indexName);
@ -460,7 +460,7 @@ public class SimpleBlocksIT extends OpenSearchIntegTestCase {
false,
randomBoolean(),
IntStream.range(0, 10)
.mapToObj(n -> client().prepareIndex(indexName, "zzz").setId(String.valueOf(n)).setSource("num", n))
.mapToObj(n -> client().prepareIndex(indexName).setId(String.valueOf(n)).setSource("num", n))
.collect(toList())
);
}

View File

@ -165,7 +165,7 @@ public class NoMasterNodeIT extends OpenSearchIntegTestCase {
checkUpdateAction(
false,
timeout,
clientToMasterlessNode.prepareUpdate("test", "type1", "1")
clientToMasterlessNode.prepareUpdate("test", "1")
.setScript(new Script(ScriptType.INLINE, Script.DEFAULT_SCRIPT_LANG, "test script", Collections.emptyMap()))
.setTimeout(timeout)
);
@ -173,7 +173,7 @@ public class NoMasterNodeIT extends OpenSearchIntegTestCase {
checkUpdateAction(
true,
timeout,
clientToMasterlessNode.prepareUpdate("no_index", "type1", "1")
clientToMasterlessNode.prepareUpdate("no_index", "1")
.setScript(new Script(ScriptType.INLINE, Script.DEFAULT_SCRIPT_LANG, "test script", Collections.emptyMap()))
.setTimeout(timeout)
);
@ -292,7 +292,7 @@ public class NoMasterNodeIT extends OpenSearchIntegTestCase {
TimeValue timeout = TimeValue.timeValueMillis(200);
long now = System.currentTimeMillis();
try {
clientToMasterlessNode.prepareUpdate("test1", "type1", "1")
clientToMasterlessNode.prepareUpdate("test1", "1")
.setDoc(Requests.INDEX_CONTENT_TYPE, "field", "value2")
.setTimeout(timeout)
.get();
@ -330,7 +330,7 @@ public class NoMasterNodeIT extends OpenSearchIntegTestCase {
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
).get();
client().admin().cluster().prepareHealth("_all").setWaitForGreenStatus().get();
client().prepareIndex("test1", "type1").setId("1").setSource("field", "value1").get();
client().prepareIndex("test1").setId("1").setSource("field", "value1").get();
refresh();
ensureGreen("test1");
@ -388,20 +388,20 @@ public class NoMasterNodeIT extends OpenSearchIntegTestCase {
);
TimeValue timeout = TimeValue.timeValueMillis(200);
client(randomFrom(nodesWithShards)).prepareUpdate("test1", "type1", "1")
client(randomFrom(nodesWithShards)).prepareUpdate("test1", "1")
.setDoc(Requests.INDEX_CONTENT_TYPE, "field", "value2")
.setTimeout(timeout)
.get();
expectThrows(
Exception.class,
() -> client(partitionedNode).prepareUpdate("test1", "type1", "1")
() -> client(partitionedNode).prepareUpdate("test1", "1")
.setDoc(Requests.INDEX_CONTENT_TYPE, "field", "value2")
.setTimeout(timeout)
.get()
);
client(randomFrom(nodesWithShards)).prepareIndex("test1", "type1")
client(randomFrom(nodesWithShards)).prepareIndex("test1")
.setId("1")
.setSource(XContentFactory.jsonBuilder().startObject().endObject())
.setTimeout(timeout)
@ -410,7 +410,7 @@ public class NoMasterNodeIT extends OpenSearchIntegTestCase {
// dynamic mapping updates fail
expectThrows(
MasterNotDiscoveredException.class,
() -> client(randomFrom(nodesWithShards)).prepareIndex("test1", "type1")
() -> client(randomFrom(nodesWithShards)).prepareIndex("test1")
.setId("1")
.setSource(XContentFactory.jsonBuilder().startObject().field("new_field", "value").endObject())
.setTimeout(timeout)
@ -420,7 +420,7 @@ public class NoMasterNodeIT extends OpenSearchIntegTestCase {
// dynamic index creation fails
expectThrows(
MasterNotDiscoveredException.class,
() -> client(randomFrom(nodesWithShards)).prepareIndex("test2", "type1")
() -> client(randomFrom(nodesWithShards)).prepareIndex("test2")
.setId("1")
.setSource(XContentFactory.jsonBuilder().startObject().endObject())
.setTimeout(timeout)
@ -429,7 +429,7 @@ public class NoMasterNodeIT extends OpenSearchIntegTestCase {
expectThrows(
Exception.class,
() -> client(partitionedNode).prepareIndex("test1", "type1")
() -> client(partitionedNode).prepareIndex("test1")
.setId("1")
.setSource(XContentFactory.jsonBuilder().startObject().endObject())
.setTimeout(timeout)

View File

@ -193,7 +193,7 @@ public class AllocationIdIT extends OpenSearchIntegTestCase {
final int numExtraDocs = between(10, 100);
IndexRequestBuilder[] builders = new IndexRequestBuilder[numExtraDocs];
for (int i = 0; i < builders.length; i++) {
builders[i] = client().prepareIndex(indexName, "type").setSource(source);
builders[i] = client().prepareIndex(indexName).setSource(source);
}
indexRandom(true, false, true, Arrays.asList(builders));

View File

@ -205,7 +205,7 @@ public class DelayedAllocationIT extends OpenSearchIntegTestCase {
int numDocs = scaledRandomIntBetween(100, 1000);
IndexRequestBuilder[] builders = new IndexRequestBuilder[numDocs];
for (int i = 0; i < builders.length; i++) {
builders[i] = client().prepareIndex("test", "type").setSource("field", "value");
builders[i] = client().prepareIndex("test").setSource("field", "value");
}
// we want to test both full divergent copies of the shard in terms of segments, and
// a case where they are the same (using sync flush), index Random does all this goodness

View File

@ -128,8 +128,8 @@ public class PrimaryAllocationIT extends OpenSearchIntegTestCase {
ensureGreen();
BulkResponse bulkResponse = client().prepareBulk()
.add(client().prepareIndex().setIndex("test").setType("_doc").setId("1").setSource("field1", "value1"))
.add(client().prepareUpdate().setIndex("test").setType("_doc").setId("1").setDoc("field2", "value2"))
.add(client().prepareIndex().setIndex("test").setId("1").setSource("field1", "value1"))
.add(client().prepareUpdate().setIndex("test").setId("1").setDoc("field2", "value2"))
.execute()
.actionGet();
@ -150,7 +150,7 @@ public class PrimaryAllocationIT extends OpenSearchIntegTestCase {
// returns data paths settings of in-sync shard copy
private Settings createStaleReplicaScenario(String master) throws Exception {
client().prepareIndex("test", "type1").setSource(jsonBuilder().startObject().field("field", "value1").endObject()).get();
client().prepareIndex("test").setSource(jsonBuilder().startObject().field("field", "value1").endObject()).get();
refresh();
ClusterState state = client().admin().cluster().prepareState().all().get().getState();
List<ShardRouting> shards = state.routingTable().allShards("test");
@ -177,7 +177,7 @@ public class PrimaryAllocationIT extends OpenSearchIntegTestCase {
ensureStableCluster(2, master);
logger.info("--> index a document into previous replica shard (that is now primary)");
client(replicaNode).prepareIndex("test", "type1").setSource(jsonBuilder().startObject().field("field", "value1").endObject()).get();
client(replicaNode).prepareIndex("test").setSource(jsonBuilder().startObject().field("field", "value1").endObject()).get();
logger.info("--> shut down node that has new acknowledged document");
final Settings inSyncDataPathSettings = internalCluster().dataPathSettings(replicaNode);
@ -558,7 +558,7 @@ public class PrimaryAllocationIT extends OpenSearchIntegTestCase {
ensureYellow("test");
assertEquals(2, client().admin().cluster().prepareState().get().getState().metadata().index("test").inSyncAllocationIds(0).size());
logger.info("--> indexing...");
client().prepareIndex("test", "type1").setSource(jsonBuilder().startObject().field("field", "value1").endObject()).get();
client().prepareIndex("test").setSource(jsonBuilder().startObject().field("field", "value1").endObject()).get();
assertEquals(1, client().admin().cluster().prepareState().get().getState().metadata().index("test").inSyncAllocationIds(0).size());
internalCluster().restartRandomDataNode(new InternalTestCluster.RestartCallback() {
@Override
@ -595,7 +595,7 @@ public class PrimaryAllocationIT extends OpenSearchIntegTestCase {
.get()
);
ensureGreen("test");
client().prepareIndex("test", "type1").setSource(jsonBuilder().startObject().field("field", "value1").endObject()).get();
client().prepareIndex("test").setSource(jsonBuilder().startObject().field("field", "value1").endObject()).get();
logger.info("--> removing 2 nodes from cluster");
internalCluster().stopRandomNode(InternalTestCluster.nameFilter(nodes.get(1), nodes.get(2)));
internalCluster().stopRandomNode(InternalTestCluster.nameFilter(nodes.get(1), nodes.get(2)));

View File

@ -302,7 +302,7 @@ public class DiskThresholdDeciderIT extends OpenSearchIntegTestCase {
while (true) {
final IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[scaledRandomIntBetween(100, 10000)];
for (int i = 0; i < indexRequestBuilders.length; i++) {
indexRequestBuilders[i] = client().prepareIndex(indexName, "_doc").setSource("field", randomAlphaOfLength(10));
indexRequestBuilders[i] = client().prepareIndex(indexName).setSource("field", randomAlphaOfLength(10));
}
indexRandom(true, indexRequestBuilders);
forceMerge();

View File

@ -227,7 +227,7 @@ public class MockDiskUsagesIT extends OpenSearchIntegTestCase {
assertBusy(
() -> assertBlocked(
client().prepareIndex().setIndex("test").setType("doc").setId("1").setSource("foo", "bar"),
client().prepareIndex().setIndex("test").setId("1").setSource("foo", "bar"),
IndexMetadata.INDEX_READ_ONLY_ALLOW_DELETE_BLOCK
)
);
@ -236,7 +236,7 @@ public class MockDiskUsagesIT extends OpenSearchIntegTestCase {
// Cannot add further documents
assertBlocked(
client().prepareIndex().setIndex("test").setType("doc").setId("2").setSource("foo", "bar"),
client().prepareIndex().setIndex("test").setId("2").setSource("foo", "bar"),
IndexMetadata.INDEX_READ_ONLY_ALLOW_DELETE_BLOCK
);
assertSearchHits(client().prepareSearch("test").get(), "1");

View File

@ -80,9 +80,7 @@ public class ClusterDisruptionCleanSettingsIT extends OpenSearchIntegTestCase {
final String node_2 = internalCluster().startDataOnlyNode();
List<IndexRequestBuilder> indexRequestBuilderList = new ArrayList<>();
for (int i = 0; i < 100; i++) {
indexRequestBuilderList.add(
client().prepareIndex().setIndex("test").setType("_doc").setSource("{\"int_field\":1}", XContentType.JSON)
);
indexRequestBuilderList.add(client().prepareIndex().setIndex("test").setSource("{\"int_field\":1}", XContentType.JSON));
}
indexRandom(true, indexRequestBuilderList);

View File

@ -308,10 +308,7 @@ public class ClusterDisruptionIT extends AbstractDisruptionTestCase {
ensureStableCluster(2, notIsolatedNode);
assertFalse(client(notIsolatedNode).admin().cluster().prepareHealth("test").setWaitForYellowStatus().get().isTimedOut());
IndexResponse indexResponse = internalCluster().client(notIsolatedNode)
.prepareIndex("test", "type")
.setSource("field", "value")
.get();
IndexResponse indexResponse = internalCluster().client(notIsolatedNode).prepareIndex("test").setSource("field", "value").get();
assertThat(indexResponse.getVersion(), equalTo(1L));
logger.info("Verifying if document exists via node[{}]", notIsolatedNode);

View File

@ -244,7 +244,7 @@ public class SnapshotDisruptionIT extends AbstractSnapshotIntegTestCase {
final String indexName = "index-one";
createIndex(indexName);
client().prepareIndex(indexName, "_doc").setSource("foo", "bar").get();
client().prepareIndex(indexName).setSource("foo", "bar").get();
blockDataNode(repoName, dataNode);

View File

@ -83,7 +83,6 @@ public class DocumentActionsIT extends OpenSearchIntegTestCase {
logger.info("Indexing [type1/1]");
IndexResponse indexResponse = client().prepareIndex()
.setIndex("test")
.setType("type1")
.setId("1")
.setSource(source("1", "test"))
.setRefreshPolicy(RefreshPolicy.IMMEDIATE)
@ -141,7 +140,7 @@ public class DocumentActionsIT extends OpenSearchIntegTestCase {
}
logger.info("Delete [type1/1]");
DeleteResponse deleteResponse = client().prepareDelete("test", "type1", "1").execute().actionGet();
DeleteResponse deleteResponse = client().prepareDelete("test", "1").execute().actionGet();
assertThat(deleteResponse.getIndex(), equalTo(getConcreteIndexName()));
assertThat(deleteResponse.getId(), equalTo("1"));
logger.info("Refreshing");
@ -211,12 +210,12 @@ public class DocumentActionsIT extends OpenSearchIntegTestCase {
ensureGreen();
BulkResponse bulkResponse = client().prepareBulk()
.add(client().prepareIndex().setIndex("test").setType("type1").setId("1").setSource(source("1", "test")))
.add(client().prepareIndex().setIndex("test").setType("type1").setId("2").setSource(source("2", "test")).setCreate(true))
.add(client().prepareIndex().setIndex("test").setType("type1").setSource(source("3", "test")))
.add(client().prepareIndex().setIndex("test").setType("type1").setCreate(true).setSource(source("4", "test")))
.add(client().prepareDelete().setIndex("test").setType("type1").setId("1"))
.add(client().prepareIndex().setIndex("test").setType("type1").setSource("{ xxx }", XContentType.JSON)) // failure
.add(client().prepareIndex().setIndex("test").setId("1").setSource(source("1", "test")))
.add(client().prepareIndex().setIndex("test").setId("2").setSource(source("2", "test")).setCreate(true))
.add(client().prepareIndex().setIndex("test").setSource(source("3", "test")))
.add(client().prepareIndex().setIndex("test").setCreate(true).setSource(source("4", "test")))
.add(client().prepareDelete().setIndex("test").setId("1"))
.add(client().prepareIndex().setIndex("test").setSource("{ xxx }", XContentType.JSON)) // failure
.execute()
.actionGet();

View File

@ -60,18 +60,15 @@ public class ShardInfoIT extends OpenSearchIntegTestCase {
public void testIndexAndDelete() throws Exception {
prepareIndex(1);
IndexResponse indexResponse = client().prepareIndex("idx", "type").setSource("{}", XContentType.JSON).get();
IndexResponse indexResponse = client().prepareIndex("idx").setSource("{}", XContentType.JSON).get();
assertShardInfo(indexResponse);
DeleteResponse deleteResponse = client().prepareDelete("idx", "type", indexResponse.getId()).get();
DeleteResponse deleteResponse = client().prepareDelete("idx", indexResponse.getId()).get();
assertShardInfo(deleteResponse);
}
public void testUpdate() throws Exception {
prepareIndex(1);
UpdateResponse updateResponse = client().prepareUpdate("idx", "type", "1")
.setDoc("{}", XContentType.JSON)
.setDocAsUpsert(true)
.get();
UpdateResponse updateResponse = client().prepareUpdate("idx", "1").setDoc("{}", XContentType.JSON).setDocAsUpsert(true).get();
assertShardInfo(updateResponse);
}
@ -79,7 +76,7 @@ public class ShardInfoIT extends OpenSearchIntegTestCase {
prepareIndex(1);
BulkRequestBuilder bulkRequestBuilder = client().prepareBulk();
for (int i = 0; i < 10; i++) {
bulkRequestBuilder.add(client().prepareIndex("idx", "type").setSource("{}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("idx").setSource("{}", XContentType.JSON));
}
BulkResponse bulkResponse = bulkRequestBuilder.get();
@ -87,7 +84,7 @@ public class ShardInfoIT extends OpenSearchIntegTestCase {
for (BulkItemResponse item : bulkResponse) {
assertThat(item.isFailed(), equalTo(false));
assertShardInfo(item.getResponse());
bulkRequestBuilder.add(client().prepareDelete("idx", "type", item.getId()));
bulkRequestBuilder.add(client().prepareDelete("idx", item.getId()));
}
bulkResponse = bulkRequestBuilder.get();
@ -101,9 +98,7 @@ public class ShardInfoIT extends OpenSearchIntegTestCase {
prepareIndex(1);
BulkRequestBuilder bulkRequestBuilder = client().prepareBulk();
for (int i = 0; i < 10; i++) {
bulkRequestBuilder.add(
client().prepareUpdate("idx", "type", Integer.toString(i)).setDoc("{}", XContentType.JSON).setDocAsUpsert(true)
);
bulkRequestBuilder.add(client().prepareUpdate("idx", Integer.toString(i)).setDoc("{}", XContentType.JSON).setDocAsUpsert(true));
}
BulkResponse bulkResponse = bulkRequestBuilder.get();

View File

@ -304,7 +304,7 @@ public class GatewayIndexStateIT extends OpenSearchIntegTestCase {
logger.info("--> create an index");
client().admin().indices().prepareCreate("test").execute().actionGet();
client().prepareIndex("test", "type1").setSource("field1", "value1").execute().actionGet();
client().prepareIndex("test").setSource("field1", "value1").execute().actionGet();
}
public void testTwoNodesSingleDoc() throws Exception {

View File

@ -530,7 +530,7 @@ public class RecoveryFromGatewayIT extends OpenSearchIntegTestCase {
logger.info("--> indexing docs");
int numDocs = randomIntBetween(1, 1024);
for (int i = 0; i < numDocs; i++) {
client(primaryNode).prepareIndex("test", "type").setSource("field", "value").execute().actionGet();
client(primaryNode).prepareIndex("test").setSource("field", "value").execute().actionGet();
}
client(primaryNode).admin().indices().prepareFlush("test").setForce(true).get();
@ -563,7 +563,7 @@ public class RecoveryFromGatewayIT extends OpenSearchIntegTestCase {
public Settings onNodeStopped(String nodeName) throws Exception {
// index some more documents; we expect to reuse the files that already exist on the replica
for (int i = 0; i < moreDocs; i++) {
client(primaryNode).prepareIndex("test", "type").setSource("field", "value").execute().actionGet();
client(primaryNode).prepareIndex("test").setSource("field", "value").execute().actionGet();
}
// prevent a sequence-number-based recovery from being possible

View File

@ -113,7 +113,7 @@ public class ReplicaShardAllocatorIT extends OpenSearchIntegTestCase {
randomBoolean(),
randomBoolean(),
IntStream.range(0, between(100, 500))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("f", "v"))
.mapToObj(n -> client().prepareIndex(indexName).setSource("f", "v"))
.collect(Collectors.toList())
);
client().admin().indices().prepareFlush(indexName).get();
@ -123,7 +123,7 @@ public class ReplicaShardAllocatorIT extends OpenSearchIntegTestCase {
false,
randomBoolean(),
IntStream.range(0, between(0, 80))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("f", "v"))
.mapToObj(n -> client().prepareIndex(indexName).setSource("f", "v"))
.collect(Collectors.toList())
);
}
@ -192,7 +192,7 @@ public class ReplicaShardAllocatorIT extends OpenSearchIntegTestCase {
false,
randomBoolean(),
IntStream.range(0, between(10, 100))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("f", "v"))
.mapToObj(n -> client().prepareIndex(indexName).setSource("f", "v"))
.collect(Collectors.toList())
);
internalCluster().stopRandomNode(InternalTestCluster.nameFilter(nodeWithReplica));
@ -202,7 +202,7 @@ public class ReplicaShardAllocatorIT extends OpenSearchIntegTestCase {
false,
randomBoolean(),
IntStream.range(0, between(10, 100))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("f", "v"))
.mapToObj(n -> client().prepareIndex(indexName).setSource("f", "v"))
.collect(Collectors.toList())
);
}
@ -231,7 +231,7 @@ public class ReplicaShardAllocatorIT extends OpenSearchIntegTestCase {
randomBoolean(),
randomBoolean(),
IntStream.range(0, between(50, 200))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("f", "v"))
.mapToObj(n -> client().prepareIndex(indexName).setSource("f", "v"))
.collect(Collectors.toList())
);
client().admin().indices().prepareFlush(indexName).get();
@ -288,7 +288,7 @@ public class ReplicaShardAllocatorIT extends OpenSearchIntegTestCase {
randomBoolean(),
randomBoolean(),
IntStream.range(0, between(200, 500))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("f", "v"))
.mapToObj(n -> client().prepareIndex(indexName).setSource("f", "v"))
.collect(Collectors.toList())
);
client().admin().indices().prepareFlush(indexName).get();
@ -297,7 +297,7 @@ public class ReplicaShardAllocatorIT extends OpenSearchIntegTestCase {
false,
randomBoolean(),
IntStream.range(0, between(0, 80))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("f", "v"))
.mapToObj(n -> client().prepareIndex(indexName).setSource("f", "v"))
.collect(Collectors.toList())
);
if (randomBoolean()) {
@ -350,7 +350,7 @@ public class ReplicaShardAllocatorIT extends OpenSearchIntegTestCase {
randomBoolean(),
randomBoolean(),
IntStream.range(0, between(200, 500))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("f", "v"))
.mapToObj(n -> client().prepareIndex(indexName).setSource("f", "v"))
.collect(Collectors.toList())
);
client().admin().indices().prepareFlush(indexName).get();
@ -364,7 +364,7 @@ public class ReplicaShardAllocatorIT extends OpenSearchIntegTestCase {
false,
randomBoolean(),
IntStream.range(0, between(1, 100))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("f", "v"))
.mapToObj(n -> client().prepareIndex(indexName).setSource("f", "v"))
.collect(Collectors.toList())
);
ensureActivePeerRecoveryRetentionLeasesAdvanced(indexName);
@ -376,7 +376,7 @@ public class ReplicaShardAllocatorIT extends OpenSearchIntegTestCase {
false,
randomBoolean(),
IntStream.range(0, between(0, 100))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("f", "v"))
.mapToObj(n -> client().prepareIndex(indexName).setSource("f", "v"))
.collect(Collectors.toList())
);
@ -422,7 +422,7 @@ public class ReplicaShardAllocatorIT extends OpenSearchIntegTestCase {
randomBoolean(),
randomBoolean(),
IntStream.range(0, between(200, 500))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("f", "v"))
.mapToObj(n -> client().prepareIndex(indexName).setSource("f", "v"))
.collect(Collectors.toList())
);
client().admin().indices().prepareFlush(indexName).get();
@ -474,7 +474,7 @@ public class ReplicaShardAllocatorIT extends OpenSearchIntegTestCase {
randomBoolean(),
randomBoolean(),
IntStream.range(0, randomIntBetween(1, 100))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("num", n))
.mapToObj(n -> client().prepareIndex(indexName).setSource("num", n))
.collect(Collectors.toList())
);
ensureActivePeerRecoveryRetentionLeasesAdvanced(indexName);
@ -536,7 +536,7 @@ public class ReplicaShardAllocatorIT extends OpenSearchIntegTestCase {
randomBoolean(),
randomBoolean(),
IntStream.range(0, between(200, 500))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("f", "v"))
.mapToObj(n -> client().prepareIndex(indexName).setSource("f", "v"))
.collect(Collectors.toList())
);
}

View File

@ -199,7 +199,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
assertThat(response.getSourceAsMap().get("field1").toString(), equalTo("value1_2"));
assertThat(response.getSourceAsMap().get("field2").toString(), equalTo("value2_2"));
DeleteResponse deleteResponse = client().prepareDelete("test", "type1", "1").get();
DeleteResponse deleteResponse = client().prepareDelete("test", "1").get();
assertEquals(DocWriteResponse.Result.DELETED, deleteResponse.getResult());
response = client().prepareGet(indexOrAlias(), "1").get();
@ -756,7 +756,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setSource(createIndexSource, XContentType.JSON));
ensureGreen();
String doc = "{\n" + " \"text\": \"some text.\"\n" + "}\n";
client().prepareIndex("test", "_doc").setId("1").setSource(doc, XContentType.JSON).setRouting("1").get();
client().prepareIndex("test").setId("1").setSource(doc, XContentType.JSON).setRouting("1").get();
String[] fieldsList = { "_routing" };
// before refresh - document is only in translog
assertGetFieldsAlwaysWorks(indexOrAlias(), "_doc", "1", fieldsList, "1");

View File

@ -107,7 +107,7 @@ public class FinalPipelineIT extends OpenSearchIntegTestCase {
final IllegalStateException e = expectThrows(
IllegalStateException.class,
() -> client().prepareIndex("index", "_doc").setId("1").setSource(Collections.singletonMap("field", "value")).get()
() -> client().prepareIndex("index").setId("1").setSource(Collections.singletonMap("field", "value")).get()
);
assertThat(e, hasToString(containsString("final pipeline [final_pipeline] can't change the target index")));
}
@ -128,7 +128,7 @@ public class FinalPipelineIT extends OpenSearchIntegTestCase {
BytesReference finalPipelineBody = new BytesArray("{\"processors\": [{\"final\": {\"exists\":\"no_such_field\"}}]}");
client().admin().cluster().putPipeline(new PutPipelineRequest("final_pipeline", finalPipelineBody, XContentType.JSON)).actionGet();
IndexResponse indexResponse = client().prepareIndex("index", "_doc")
IndexResponse indexResponse = client().prepareIndex("index")
.setId("1")
.setSource(Collections.singletonMap("field", "value"))
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
@ -155,7 +155,7 @@ public class FinalPipelineIT extends OpenSearchIntegTestCase {
BytesReference finalPipelineBody = new BytesArray("{\"processors\": [{\"final\": {}}]}");
client().admin().cluster().putPipeline(new PutPipelineRequest("final_pipeline", finalPipelineBody, XContentType.JSON)).actionGet();
IndexResponse indexResponse = client().prepareIndex("index", "_doc")
IndexResponse indexResponse = client().prepareIndex("index")
.setId("1")
.setSource(Collections.singletonMap("field", "value"))
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
@ -185,7 +185,7 @@ public class FinalPipelineIT extends OpenSearchIntegTestCase {
.putPipeline(new PutPipelineRequest("target_default_pipeline", targetPipeline, XContentType.JSON))
.actionGet();
IndexResponse indexResponse = client().prepareIndex("index", "_doc")
IndexResponse indexResponse = client().prepareIndex("index")
.setId("1")
.setSource(Collections.singletonMap("field", "value"))
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)

View File

@ -63,7 +63,7 @@ public class HiddenIndexIT extends OpenSearchIntegTestCase {
assertAcked(
client().admin().indices().prepareCreate("hidden-index").setSettings(Settings.builder().put("index.hidden", true).build()).get()
);
client().prepareIndex("hidden-index", "_doc").setSource("foo", "bar").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareIndex("hidden-index").setSource("foo", "bar").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
// default not visible to wildcard expansion
SearchResponse searchResponse = client().prepareSearch(randomFrom("*", "_all", "h*", "*index"))
@ -95,7 +95,7 @@ public class HiddenIndexIT extends OpenSearchIntegTestCase {
.setSettings(Settings.builder().put("index.hidden", true).build())
.get()
);
client().prepareIndex(".hidden-index", "_doc").setSource("foo", "bar").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareIndex(".hidden-index").setSource("foo", "bar").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
searchResponse = client().prepareSearch(randomFrom(".*", ".hidden-*")).setSize(1000).setQuery(QueryBuilders.matchAllQuery()).get();
matchedHidden = Arrays.stream(searchResponse.getHits().getHits()).anyMatch(hit -> ".hidden-index".equals(hit.getIndex()));
assertTrue(matchedHidden);

View File

@ -53,13 +53,13 @@ public class IndexRequestBuilderIT extends OpenSearchIntegTestCase {
Map<String, Object> map = new HashMap<>();
map.put("test_field", "foobar");
IndexRequestBuilder[] builders = new IndexRequestBuilder[] {
client().prepareIndex("test", "test").setSource((Object) "test_field", (Object) "foobar"),
client().prepareIndex("test", "test").setSource("{\"test_field\" : \"foobar\"}", XContentType.JSON),
client().prepareIndex("test", "test").setSource(new BytesArray("{\"test_field\" : \"foobar\"}"), XContentType.JSON),
client().prepareIndex("test", "test").setSource(new BytesArray("{\"test_field\" : \"foobar\"}"), XContentType.JSON),
client().prepareIndex("test", "test")
client().prepareIndex("test").setSource("test_field", "foobar"),
client().prepareIndex("test").setSource("{\"test_field\" : \"foobar\"}", XContentType.JSON),
client().prepareIndex("test").setSource(new BytesArray("{\"test_field\" : \"foobar\"}"), XContentType.JSON),
client().prepareIndex("test").setSource(new BytesArray("{\"test_field\" : \"foobar\"}"), XContentType.JSON),
client().prepareIndex("test")
.setSource(BytesReference.toBytes(new BytesArray("{\"test_field\" : \"foobar\"}")), XContentType.JSON),
client().prepareIndex("test", "test").setSource(map) };
client().prepareIndex("test").setSource(map) };
indexRandom(true, builders);
SearchResponse searchResponse = client().prepareSearch("test").setQuery(QueryBuilders.termQuery("test_field", "foobar")).get();
OpenSearchAssertions.assertHitCount(searchResponse, builders.length);
@ -67,7 +67,7 @@ public class IndexRequestBuilderIT extends OpenSearchIntegTestCase {
public void testOddNumberOfSourceObjects() {
try {
client().prepareIndex("test", "test").setSource("test_field", "foobar", new Object());
client().prepareIndex("test").setSource("test_field", "foobar", new Object());
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), containsString("The number of object passed must be even but was [3]"));

View File

@ -98,7 +98,7 @@ public class WaitUntilRefreshIT extends OpenSearchIntegTestCase {
assertSearchHits(client().prepareSearch("test").setQuery(matchQuery("foo", "bar")).get(), "1");
// Now delete with blockUntilRefresh
DeleteResponse delete = client().prepareDelete("test", "test", "1").setRefreshPolicy(RefreshPolicy.WAIT_UNTIL).get();
DeleteResponse delete = client().prepareDelete("test", "1").setRefreshPolicy(RefreshPolicy.WAIT_UNTIL).get();
assertEquals(DocWriteResponse.Result.DELETED, delete.getResult());
assertFalse("request shouldn't have forced a refresh", delete.forcedRefresh());
assertNoSearchHits(client().prepareSearch("test").setQuery(matchQuery("foo", "bar")).get());
@ -110,7 +110,7 @@ public class WaitUntilRefreshIT extends OpenSearchIntegTestCase {
assertSearchHits(client().prepareSearch("test").setQuery(matchQuery("foo", "bar")).get(), "1");
// Update with RefreshPolicy.WAIT_UNTIL
UpdateResponse update = client().prepareUpdate("test", "test", "1")
UpdateResponse update = client().prepareUpdate("test", "1")
.setDoc(Requests.INDEX_CONTENT_TYPE, "foo", "baz")
.setRefreshPolicy(RefreshPolicy.WAIT_UNTIL)
.get();
@ -119,7 +119,7 @@ public class WaitUntilRefreshIT extends OpenSearchIntegTestCase {
assertSearchHits(client().prepareSearch("test").setQuery(matchQuery("foo", "baz")).get(), "1");
// Upsert with RefreshPolicy.WAIT_UNTIL
update = client().prepareUpdate("test", "test", "2")
update = client().prepareUpdate("test", "2")
.setDocAsUpsert(true)
.setDoc(Requests.INDEX_CONTENT_TYPE, "foo", "cat")
.setRefreshPolicy(RefreshPolicy.WAIT_UNTIL)
@ -129,7 +129,7 @@ public class WaitUntilRefreshIT extends OpenSearchIntegTestCase {
assertSearchHits(client().prepareSearch("test").setQuery(matchQuery("foo", "cat")).get(), "2");
// Update-becomes-delete with RefreshPolicy.WAIT_UNTIL
update = client().prepareUpdate("test", "test", "2")
update = client().prepareUpdate("test", "2")
.setScript(new Script(ScriptType.INLINE, "mockscript", "delete_plz", emptyMap()))
.setRefreshPolicy(RefreshPolicy.WAIT_UNTIL)
.get();
@ -147,19 +147,19 @@ public class WaitUntilRefreshIT extends OpenSearchIntegTestCase {
// Update by bulk with RefreshPolicy.WAIT_UNTIL
bulk = client().prepareBulk().setRefreshPolicy(RefreshPolicy.WAIT_UNTIL);
bulk.add(client().prepareUpdate("test", "test", "1").setDoc(Requests.INDEX_CONTENT_TYPE, "foo", "baz"));
bulk.add(client().prepareUpdate("test", "1").setDoc(Requests.INDEX_CONTENT_TYPE, "foo", "baz"));
assertBulkSuccess(bulk.get());
assertSearchHits(client().prepareSearch("test").setQuery(matchQuery("foo", "baz")).get(), "1");
// Delete by bulk with RefreshPolicy.WAIT_UNTIL
bulk = client().prepareBulk().setRefreshPolicy(RefreshPolicy.WAIT_UNTIL);
bulk.add(client().prepareDelete("test", "test", "1"));
bulk.add(client().prepareDelete("test", "1"));
assertBulkSuccess(bulk.get());
assertNoSearchHits(client().prepareSearch("test").setQuery(matchQuery("foo", "bar")).get());
// Update makes a noop
bulk = client().prepareBulk().setRefreshPolicy(RefreshPolicy.WAIT_UNTIL);
bulk.add(client().prepareDelete("test", "test", "1"));
bulk.add(client().prepareDelete("test", "1"));
assertBulkSuccess(bulk.get());
}

View File

@ -123,7 +123,7 @@ public class MaxDocsLimitIT extends OpenSearchIntegTestCase {
assertThat(indexingResult.numSuccess, equalTo(0));
final IllegalArgumentException deleteError = expectThrows(
IllegalArgumentException.class,
() -> client().prepareDelete("test", "_doc", "any-id").get()
() -> client().prepareDelete("test", "any-id").get()
);
assertThat(deleteError.getMessage(), containsString("Number of documents in the index can't exceed [" + maxDocs.get() + "]"));
client().admin().indices().prepareRefresh("test").get();
@ -206,7 +206,7 @@ public class MaxDocsLimitIT extends OpenSearchIntegTestCase {
phaser.arriveAndAwaitAdvance();
while (completedRequests.incrementAndGet() <= numRequests) {
try {
final IndexResponse resp = client().prepareIndex("test", "_doc").setSource("{}", XContentType.JSON).get();
final IndexResponse resp = client().prepareIndex("test").setSource("{}", XContentType.JSON).get();
numSuccess.incrementAndGet();
assertThat(resp.status(), equalTo(RestStatus.CREATED));
} catch (IllegalArgumentException e) {

View File

@ -146,7 +146,7 @@ public class DynamicMappingIT extends OpenSearchIntegTestCase {
public void testPreflightCheckAvoidsMaster() throws InterruptedException {
createIndex("index", Settings.builder().put(INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING.getKey(), 2).build());
ensureGreen("index");
client().prepareIndex("index", MapperService.SINGLE_MAPPING_NAME).setId("1").setSource("field1", "value1").get();
client().prepareIndex("index").setId("1").setSource("field1", "value1").get();
final CountDownLatch masterBlockedLatch = new CountDownLatch(1);
final CountDownLatch indexingCompletedLatch = new CountDownLatch(1);
@ -167,9 +167,7 @@ public class DynamicMappingIT extends OpenSearchIntegTestCase {
});
masterBlockedLatch.await();
final IndexRequestBuilder indexRequestBuilder = client().prepareIndex("index", MapperService.SINGLE_MAPPING_NAME)
.setId("2")
.setSource("field2", "value2");
final IndexRequestBuilder indexRequestBuilder = client().prepareIndex("index").setId("2").setSource("field2", "value2");
try {
assertThat(
expectThrows(IllegalArgumentException.class, () -> indexRequestBuilder.get(TimeValue.timeValueSeconds(10))).getMessage(),
@ -184,7 +182,7 @@ public class DynamicMappingIT extends OpenSearchIntegTestCase {
createIndex("test");
final ClusterService clusterService = internalCluster().clusterService();
final long previousVersion = clusterService.state().metadata().index("test").getMappingVersion();
client().prepareIndex("test", "_doc").setId("1").setSource("field", "text").get();
client().prepareIndex("test").setId("1").setSource("field", "text").get();
assertBusy(() -> assertThat(clusterService.state().metadata().index("test").getMappingVersion(), equalTo(1 + previousVersion)));
}
}

View File

@ -82,8 +82,8 @@ public class MatchPhraseQueryIT extends OpenSearchIntegTestCase {
private List<IndexRequestBuilder> getIndexRequests() {
List<IndexRequestBuilder> requests = new ArrayList<>();
requests.add(client().prepareIndex(INDEX, "band").setSource("name", "the beatles"));
requests.add(client().prepareIndex(INDEX, "band").setSource("name", "led zeppelin"));
requests.add(client().prepareIndex(INDEX).setSource("name", "the beatles"));
requests.add(client().prepareIndex(INDEX).setSource("name", "led zeppelin"));
return requests;
}
}

View File

@ -281,7 +281,7 @@ public class GlobalCheckpointSyncIT extends OpenSearchIntegTestCase {
logger.info("numDocs {}", numDocs);
long maxSeqNo = 0;
for (int i = 0; i < numDocs; i++) {
maxSeqNo = client().prepareIndex("test", "_doc").setId(Integer.toString(i)).setSource("{}", XContentType.JSON).get().getSeqNo();
maxSeqNo = client().prepareIndex("test").setId(Integer.toString(i)).setSource("{}", XContentType.JSON).get().getSeqNo();
logger.info("got {}", maxSeqNo);
}
for (IndicesService indicesService : internalCluster().getDataNodeInstances(IndicesService.class)) {

View File

@ -195,17 +195,17 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
client().prepareIndex("test", "bar", "2").setSource("{}", XContentType.JSON).get();
assertTrue(needsSync.test(translog));
setDurability(shard, Translog.Durability.REQUEST);
client().prepareDelete("test", "bar", "1").get();
client().prepareDelete("test", "1").get();
assertFalse(needsSync.test(translog));
setDurability(shard, Translog.Durability.ASYNC);
client().prepareDelete("test", "bar", "2").get();
client().prepareDelete("test", "2").get();
assertTrue(translog.syncNeeded());
setDurability(shard, Translog.Durability.REQUEST);
assertNoFailures(
client().prepareBulk()
.add(client().prepareIndex("test", "bar", "3").setSource("{}", XContentType.JSON))
.add(client().prepareDelete("test", "bar", "1"))
.add(client().prepareDelete("test", "1"))
.get()
);
assertFalse(needsSync.test(translog));
@ -214,7 +214,7 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
assertNoFailures(
client().prepareBulk()
.add(client().prepareIndex("test", "bar", "4").setSource("{}", XContentType.JSON))
.add(client().prepareDelete("test", "bar", "3"))
.add(client().prepareDelete("test", "3"))
.get()
);
setDurability(shard, Translog.Durability.REQUEST);
@ -267,7 +267,7 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
.setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0))
);
for (int i = 0; i < 50; i++) {
client().prepareIndex("test", "test").setSource("{}", XContentType.JSON).get();
client().prepareIndex("test").setSource("{}", XContentType.JSON).get();
}
ensureGreen("test");
InternalClusterInfoService clusterInfoService = (InternalClusterInfoService) getInstanceFromNode(ClusterInfoService.class);
@ -365,7 +365,7 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
.build()
)
.get();
client().prepareIndex("test", "_doc")
client().prepareIndex("test")
.setId("0")
.setSource("{}", XContentType.JSON)
.setRefreshPolicy(randomBoolean() ? IMMEDIATE : NONE)
@ -413,7 +413,7 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
.build()
)
.get();
client().prepareDelete("test", "_doc", "2").get();
client().prepareDelete("test", "2").get();
logger.info(
"--> translog size after delete: [{}] num_ops [{}] generation [{}]",
translog.stats().getUncommittedSizeInBytes(),
@ -588,7 +588,7 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
IndexService indexService = indicesService.indexService(resolveIndex("test"));
IndexShard shard = indexService.getShardOrNull(0);
client().prepareIndex("test", "test", "0").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).get();
client().prepareDelete("test", "test", "0").get();
client().prepareDelete("test", "0").get();
client().prepareIndex("test", "test", "1").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).setRefreshPolicy(IMMEDIATE).get();
CheckedFunction<DirectoryReader, DirectoryReader, IOException> wrapper = directoryReader -> directoryReader;
@ -758,7 +758,7 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
.setSource("{}", XContentType.JSON)
.get();
} else {
client().prepareDelete("index", randomFrom("_doc", "user_doc"), randomFrom("1", "2")).get();
client().prepareDelete("index", randomFrom("1", "2")).get();
}
}
IndexShard shard = indexService.getShard(0);

View File

@ -150,7 +150,7 @@ public class RemoveCorruptedShardDataCommandIT extends OpenSearchIntegTestCase {
final int numExtraDocs = between(10, 100);
IndexRequestBuilder[] builders = new IndexRequestBuilder[numExtraDocs];
for (int i = 0; i < builders.length; i++) {
builders[i] = client().prepareIndex(indexName, "type").setSource("foo", "bar");
builders[i] = client().prepareIndex(indexName).setSource("foo", "bar");
}
numDocs += numExtraDocs;
@ -326,7 +326,7 @@ public class RemoveCorruptedShardDataCommandIT extends OpenSearchIntegTestCase {
logger.info("--> indexing [{}] docs to be kept", numDocsToKeep);
IndexRequestBuilder[] builders = new IndexRequestBuilder[numDocsToKeep];
for (int i = 0; i < builders.length; i++) {
builders[i] = client().prepareIndex(indexName, "type").setSource("foo", "bar");
builders[i] = client().prepareIndex(indexName).setSource("foo", "bar");
}
indexRandom(false, false, false, Arrays.asList(builders));
flush(indexName);
@ -337,7 +337,7 @@ public class RemoveCorruptedShardDataCommandIT extends OpenSearchIntegTestCase {
logger.info("--> indexing [{}] more doc to be truncated", numDocsToTruncate);
builders = new IndexRequestBuilder[numDocsToTruncate];
for (int i = 0; i < builders.length; i++) {
builders[i] = client().prepareIndex(indexName, "type").setSource("foo", "bar");
builders[i] = client().prepareIndex(indexName).setSource("foo", "bar");
}
indexRandom(false, false, false, Arrays.asList(builders));
@ -529,7 +529,7 @@ public class RemoveCorruptedShardDataCommandIT extends OpenSearchIntegTestCase {
logger.info("--> indexing [{}] docs to be kept", numDocsToKeep);
IndexRequestBuilder[] builders = new IndexRequestBuilder[numDocsToKeep];
for (int i = 0; i < builders.length; i++) {
builders[i] = client().prepareIndex(indexName, "type").setSource("foo", "bar");
builders[i] = client().prepareIndex(indexName).setSource("foo", "bar");
}
indexRandom(false, false, false, Arrays.asList(builders));
flush(indexName);
@ -539,7 +539,7 @@ public class RemoveCorruptedShardDataCommandIT extends OpenSearchIntegTestCase {
logger.info("--> indexing [{}] more docs to be truncated", numDocsToTruncate);
builders = new IndexRequestBuilder[numDocsToTruncate];
for (int i = 0; i < builders.length; i++) {
builders[i] = client().prepareIndex(indexName, "type").setSource("foo", "bar");
builders[i] = client().prepareIndex(indexName).setSource("foo", "bar");
}
indexRandom(false, false, false, Arrays.asList(builders));
final int totalDocs = numDocsToKeep + numDocsToTruncate;

View File

@ -177,7 +177,7 @@ public class CorruptedFileIT extends OpenSearchIntegTestCase {
disableAllocation("test");
IndexRequestBuilder[] builders = new IndexRequestBuilder[numDocs];
for (int i = 0; i < builders.length; i++) {
builders[i] = client().prepareIndex("test", "type").setSource("field", "value");
builders[i] = client().prepareIndex("test").setSource("field", "value");
}
indexRandom(true, builders);
ensureGreen();
@ -295,7 +295,7 @@ public class CorruptedFileIT extends OpenSearchIntegTestCase {
ensureGreen();
IndexRequestBuilder[] builders = new IndexRequestBuilder[numDocs];
for (int i = 0; i < builders.length; i++) {
builders[i] = client().prepareIndex("test", "type").setSource("field", "value");
builders[i] = client().prepareIndex("test").setSource("field", "value");
}
indexRandom(true, builders);
ensureGreen();
@ -456,7 +456,7 @@ public class CorruptedFileIT extends OpenSearchIntegTestCase {
ensureGreen();
IndexRequestBuilder[] builders = new IndexRequestBuilder[numDocs];
for (int i = 0; i < builders.length; i++) {
builders[i] = client().prepareIndex("test", "type").setSource("field", "value");
builders[i] = client().prepareIndex("test").setSource("field", "value");
}
indexRandom(true, builders);
ensureGreen();
@ -561,7 +561,7 @@ public class CorruptedFileIT extends OpenSearchIntegTestCase {
ensureGreen();
IndexRequestBuilder[] builders = new IndexRequestBuilder[numDocs];
for (int i = 0; i < builders.length; i++) {
builders[i] = client().prepareIndex("test", "type").setSource("field", "value");
builders[i] = client().prepareIndex("test").setSource("field", "value");
}
indexRandom(true, builders);
ensureGreen();
@ -643,7 +643,7 @@ public class CorruptedFileIT extends OpenSearchIntegTestCase {
ensureGreen();
IndexRequestBuilder[] builders = new IndexRequestBuilder[numDocs];
for (int i = 0; i < builders.length; i++) {
builders[i] = client().prepareIndex("test", "type").setSource("field", "value");
builders[i] = client().prepareIndex("test").setSource("field", "value");
}
indexRandom(true, builders);
ensureGreen();

View File

@ -88,7 +88,7 @@ public class CorruptedTranslogIT extends OpenSearchIntegTestCase {
// Index some documents
IndexRequestBuilder[] builders = new IndexRequestBuilder[scaledRandomIntBetween(100, 1000)];
for (int i = 0; i < builders.length; i++) {
builders[i] = client().prepareIndex("test", "type").setSource("foo", "bar");
builders[i] = client().prepareIndex("test").setSource("foo", "bar");
}
indexRandom(false, false, false, Arrays.asList(builders));

View File

@ -127,7 +127,7 @@ public class ExceptionRetryIT extends OpenSearchIntegTestCase {
for (int i = 0; i < numDocs; i++) {
XContentBuilder doc = null;
doc = jsonBuilder().startObject().field("foo", "bar").endObject();
bulkBuilder.add(client.prepareIndex("index", "type").setSource(doc));
bulkBuilder.add(client.prepareIndex("index").setSource(doc));
}
BulkResponse response = bulkBuilder.get();

View File

@ -72,7 +72,7 @@ public class IndexActionIT extends OpenSearchIntegTestCase {
logger.info("indexing [{}] docs", numOfDocs);
List<IndexRequestBuilder> builders = new ArrayList<>(numOfDocs);
for (int j = 0; j < numOfDocs; j++) {
builders.add(client().prepareIndex("test", "type").setSource("field", "value_" + j));
builders.add(client().prepareIndex("test").setSource("field", "value_" + j));
}
indexRandom(true, builders);
logger.info("verifying indexed content");
@ -134,7 +134,7 @@ public class IndexActionIT extends OpenSearchIntegTestCase {
indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_2").execute().actionGet();
assertEquals(DocWriteResponse.Result.UPDATED, indexResponse.getResult());
client().prepareDelete("test", "type", "1").execute().actionGet();
client().prepareDelete("test", "1").execute().actionGet();
indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_2").execute().actionGet();
assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult());
@ -148,7 +148,7 @@ public class IndexActionIT extends OpenSearchIntegTestCase {
IndexResponse indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").execute().actionGet();
assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult());
client().prepareDelete("test", "type", "1").execute().actionGet();
client().prepareDelete("test", "1").execute().actionGet();
flush();
@ -232,7 +232,7 @@ public class IndexActionIT extends OpenSearchIntegTestCase {
}
try {
client().prepareIndex(randomAlphaOfLengthBetween(min, max).toLowerCase(Locale.ROOT), "mytype").setSource("foo", "bar").get();
client().prepareIndex(randomAlphaOfLengthBetween(min, max).toLowerCase(Locale.ROOT)).setSource("foo", "bar").get();
fail("exception should have been thrown on too-long index name");
} catch (InvalidIndexNameException e) {
assertThat(
@ -247,8 +247,7 @@ public class IndexActionIT extends OpenSearchIntegTestCase {
client().prepareIndex(
randomAlphaOfLength(MetadataCreateIndexService.MAX_INDEX_NAME_BYTES - 1).toLowerCase(Locale.ROOT) + "Ϟ".toLowerCase(
Locale.ROOT
),
"mytype"
)
).setSource("foo", "bar").get();
fail("exception should have been thrown on too-long index name");
} catch (InvalidIndexNameException e) {

View File

@ -109,15 +109,15 @@ public class DateMathIndexExpressionsIntegrationIT extends OpenSearchIntegTestCa
assertThat(indicesStatsResponse.getIndex(index2), notNullValue());
assertThat(indicesStatsResponse.getIndex(index3), notNullValue());
DeleteResponse deleteResponse = client().prepareDelete(dateMathExp1, "type", "1").get();
DeleteResponse deleteResponse = client().prepareDelete(dateMathExp1, "1").get();
assertEquals(DocWriteResponse.Result.DELETED, deleteResponse.getResult());
assertThat(deleteResponse.getId(), equalTo("1"));
deleteResponse = client().prepareDelete(dateMathExp2, "type", "2").get();
deleteResponse = client().prepareDelete(dateMathExp2, "2").get();
assertEquals(DocWriteResponse.Result.DELETED, deleteResponse.getResult());
assertThat(deleteResponse.getId(), equalTo("2"));
deleteResponse = client().prepareDelete(dateMathExp3, "type", "3").get();
deleteResponse = client().prepareDelete(dateMathExp3, "3").get();
assertEquals(DocWriteResponse.Result.DELETED, deleteResponse.getResult());
assertThat(deleteResponse.getId(), equalTo("3"));
}

View File

@ -121,14 +121,14 @@ public class IndexingMemoryControllerIT extends OpenSearchSingleNodeTestCase {
);
IndexShard shard = indexService.getShard(0);
for (int i = 0; i < 100; i++) {
client().prepareIndex("index", "_doc").setId(Integer.toString(i)).setSource("field", "value").get();
client().prepareIndex("index").setId(Integer.toString(i)).setSource("field", "value").get();
}
// Force merge so we know all merges are done before we start deleting:
ForceMergeResponse r = client().admin().indices().prepareForceMerge().setMaxNumSegments(1).execute().actionGet();
assertNoFailures(r);
final RefreshStats refreshStats = shard.refreshStats();
for (int i = 0; i < 100; i++) {
client().prepareDelete("index", "_doc", Integer.toString(i)).get();
client().prepareDelete("index", Integer.toString(i)).get();
}
// need to assert busily as IndexingMemoryController refreshes in background
assertBusy(() -> assertThat(shard.refreshStats().getTotal(), greaterThan(refreshStats.getTotal() + 1)));

View File

@ -79,8 +79,8 @@ public class IndicesRequestCacheIT extends OpenSearchIntegTestCase {
);
indexRandom(
true,
client.prepareIndex("index", "type").setSource("f", "2014-03-10T00:00:00.000Z"),
client.prepareIndex("index", "type").setSource("f", "2014-05-13T00:00:00.000Z")
client.prepareIndex("index").setSource("f", "2014-03-10T00:00:00.000Z"),
client.prepareIndex("index").setSource("f", "2014-05-13T00:00:00.000Z")
);
ensureSearchable("index");
@ -590,7 +590,7 @@ public class IndicesRequestCacheIT extends OpenSearchIntegTestCase {
)
.get()
);
indexRandom(true, client.prepareIndex("index", "_doc").setSource("k", "hello"));
indexRandom(true, client.prepareIndex("index").setSource("k", "hello"));
ensureSearchable("index");
int expectedHits = 0;

View File

@ -73,9 +73,9 @@ public class IndexPrimaryRelocationIT extends OpenSearchIntegTestCase {
while (finished.get() == false && numAutoGenDocs.get() < 10_000) {
IndexResponse indexResponse = client().prepareIndex("test", "type", "id").setSource("field", "value").get();
assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult());
DeleteResponse deleteResponse = client().prepareDelete("test", "type", "id").get();
DeleteResponse deleteResponse = client().prepareDelete("test", "id").get();
assertEquals(DocWriteResponse.Result.DELETED, deleteResponse.getResult());
client().prepareIndex("test", "type").setSource("auto", true).get();
client().prepareIndex("test").setSource("auto", true).get();
numAutoGenDocs.incrementAndGet();
}
}

View File

@ -172,7 +172,6 @@ import static org.hamcrest.Matchers.not;
public class IndexRecoveryIT extends OpenSearchIntegTestCase {
private static final String INDEX_NAME = "test-idx-1";
private static final String INDEX_TYPE = "test-type-1";
private static final String REPO_NAME = "test-repo-1";
private static final String SNAP_NAME = "test-snap-1";
@ -414,7 +413,7 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase {
int numDocs = randomIntBetween(10, 200);
final IndexRequestBuilder[] docs = new IndexRequestBuilder[numDocs];
for (int i = 0; i < numDocs; i++) {
docs[i] = client().prepareIndex(INDEX_NAME, INDEX_TYPE)
docs[i] = client().prepareIndex(INDEX_NAME)
.setSource("foo-int", randomInt(), "foo-string", randomAlphaOfLength(32), "foo-float", randomFloat());
}
indexRandom(randomBoolean(), docs);
@ -828,7 +827,7 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase {
final IndexRequestBuilder[] docs = new IndexRequestBuilder[numDocs];
for (int i = 0; i < numDocs; i++) {
docs[i] = client().prepareIndex(name, INDEX_TYPE)
docs[i] = client().prepareIndex(name)
.setSource("foo-int", randomInt(), "foo-string", randomAlphaOfLength(32), "foo-float", randomFloat());
}
@ -881,14 +880,14 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase {
// is a mix of file chunks and translog ops
int threeFourths = (int) (numDocs * 0.75);
for (int i = 0; i < threeFourths; i++) {
requests.add(client().prepareIndex(indexName, "type").setSource("{}", XContentType.JSON));
requests.add(client().prepareIndex(indexName).setSource("{}", XContentType.JSON));
}
indexRandom(true, requests);
flush(indexName);
requests.clear();
for (int i = threeFourths; i < numDocs; i++) {
requests.add(client().prepareIndex(indexName, "type").setSource("{}", XContentType.JSON));
requests.add(client().prepareIndex(indexName).setSource("{}", XContentType.JSON));
}
indexRandom(true, requests);
ensureSearchable(indexName);
@ -1080,7 +1079,7 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase {
List<IndexRequestBuilder> requests = new ArrayList<>();
int numDocs = scaledRandomIntBetween(25, 250);
for (int i = 0; i < numDocs; i++) {
requests.add(client().prepareIndex(indexName, "type").setSource("{}", XContentType.JSON));
requests.add(client().prepareIndex(indexName).setSource("{}", XContentType.JSON));
}
indexRandom(true, requests);
ensureSearchable(indexName);
@ -1234,7 +1233,7 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase {
List<IndexRequestBuilder> requests = new ArrayList<>();
int numDocs = scaledRandomIntBetween(25, 250);
for (int i = 0; i < numDocs; i++) {
requests.add(client().prepareIndex(indexName, "type").setSource("{}", XContentType.JSON));
requests.add(client().prepareIndex(indexName).setSource("{}", XContentType.JSON));
}
indexRandom(true, requests);
ensureSearchable(indexName);
@ -1377,7 +1376,7 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase {
final List<IndexRequestBuilder> requests = new ArrayList<>();
final int replicatedDocCount = scaledRandomIntBetween(25, 250);
while (requests.size() < replicatedDocCount) {
requests.add(client().prepareIndex(indexName, "_doc").setSource("{}", XContentType.JSON));
requests.add(client().prepareIndex(indexName).setSource("{}", XContentType.JSON));
}
indexRandom(true, requests);
if (randomBoolean()) {
@ -1399,7 +1398,7 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase {
final int numNewDocs = scaledRandomIntBetween(25, 250);
for (int i = 0; i < numNewDocs; i++) {
client().prepareIndex(indexName, "_doc").setSource("{}", XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareIndex(indexName).setSource("{}", XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
}
// Flush twice to update the safe commit's local checkpoint
assertThat(client().admin().indices().prepareFlush(indexName).setForce(true).execute().get().getFailedShards(), equalTo(0));
@ -1562,7 +1561,7 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase {
randomBoolean(),
false,
randomBoolean(),
IntStream.range(0, numDocs).mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("num", n)).collect(toList())
IntStream.range(0, numDocs).mapToObj(n -> client().prepareIndex(indexName).setSource("num", n)).collect(toList())
);
client().admin().indices().prepareRefresh(indexName).get(); // avoid refresh when we are failing a shard
String failingNode = randomFrom(nodes);
@ -1658,9 +1657,7 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase {
randomBoolean(),
randomBoolean(),
randomBoolean(),
IntStream.range(0, between(0, 100))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("num", n))
.collect(toList())
IntStream.range(0, between(0, 100)).mapToObj(n -> client().prepareIndex(indexName).setSource("num", n)).collect(toList())
);
ensureGreen(indexName);
@ -1731,9 +1728,7 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase {
randomBoolean(),
randomBoolean(),
randomBoolean(),
IntStream.range(0, between(0, 100))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("num", n))
.collect(toList())
IntStream.range(0, between(0, 100)).mapToObj(n -> client().prepareIndex(indexName).setSource("num", n)).collect(toList())
);
ensureGreen(indexName);
@ -1767,7 +1762,7 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase {
randomBoolean(),
randomBoolean(),
IntStream.range(0, between(1, 100))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("num", n))
.mapToObj(n -> client().prepareIndex(indexName).setSource("num", n))
.collect(toList())
);
@ -1826,9 +1821,7 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase {
randomBoolean(),
false,
randomBoolean(),
IntStream.range(0, between(0, 100))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("num", n))
.collect(toList())
IntStream.range(0, between(0, 100)).mapToObj(n -> client().prepareIndex(indexName).setSource("num", n)).collect(toList())
);
ensureGreen(indexName);
@ -1912,7 +1905,7 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase {
randomBoolean(),
randomBoolean(),
IntStream.range(0, newDocCount)
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("num", n))
.mapToObj(n -> client().prepareIndex(indexName).setSource("num", n))
.collect(toList())
);
@ -1964,9 +1957,7 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase {
randomBoolean(),
randomBoolean(),
randomBoolean(),
IntStream.range(0, between(0, 100))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("num", n))
.collect(toList())
IntStream.range(0, between(0, 100)).mapToObj(n -> client().prepareIndex(indexName).setSource("num", n)).collect(toList())
);
final ShardId shardId = new ShardId(resolveIndex(indexName), 0);
@ -1985,9 +1976,7 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase {
randomBoolean(),
randomBoolean(),
randomBoolean(),
IntStream.range(0, between(0, 100))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("num", n))
.collect(toList())
IntStream.range(0, between(0, 100)).mapToObj(n -> client().prepareIndex(indexName).setSource("num", n)).collect(toList())
);
assertAcked(
@ -2056,7 +2045,7 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase {
false,
randomBoolean(),
IntStream.range(0, randomIntBetween(0, 10))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("num", n))
.mapToObj(n -> client().prepareIndex(indexName).setSource("num", n))
.collect(toList())
);
@ -2088,7 +2077,7 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase {
false,
randomBoolean(),
IntStream.range(0, randomIntBetween(0, 10))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("num", n))
.mapToObj(n -> client().prepareIndex(indexName).setSource("num", n))
.collect(toList())
);
@ -2117,7 +2106,7 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase {
.get()
);
final List<IndexRequestBuilder> indexRequests = IntStream.range(0, between(10, 500))
.mapToObj(n -> client().prepareIndex(indexName, "type").setSource("foo", "bar"))
.mapToObj(n -> client().prepareIndex(indexName).setSource("foo", "bar"))
.collect(Collectors.toList());
indexRandom(randomBoolean(), true, true, indexRequests);
ensureGreen();
@ -2179,7 +2168,7 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase {
indexers[i] = new Thread(() -> {
while (stopped.get() == false) {
try {
IndexResponse response = client().prepareIndex(indexName, "_doc")
IndexResponse response = client().prepareIndex(indexName)
.setSource(Collections.singletonMap("f" + randomIntBetween(1, 10), randomNonNegativeLong()), XContentType.JSON)
.get();
assertThat(response.getResult(), isOneOf(CREATED, UPDATED));
@ -2233,7 +2222,7 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase {
);
ensureGreen(indexName);
final List<IndexRequestBuilder> indexRequests = IntStream.range(0, between(10, 500))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("foo", "bar"))
.mapToObj(n -> client().prepareIndex(indexName).setSource("foo", "bar"))
.collect(Collectors.toList());
indexRandom(randomBoolean(), true, true, indexRequests);
assertThat(client().admin().indices().prepareFlush(indexName).get().getFailedShards(), equalTo(0));

View File

@ -507,7 +507,7 @@ public class UpdateSettingsIT extends OpenSearchIntegTestCase {
public void testEngineGCDeletesSetting() throws Exception {
createIndex("test");
client().prepareIndex("test", "type", "1").setSource("f", 1).setVersionType(VersionType.EXTERNAL).setVersion(1).get();
client().prepareDelete("test", "type", "1").setVersionType(VersionType.EXTERNAL).setVersion(2).get();
client().prepareDelete("test", "1").setVersionType(VersionType.EXTERNAL).setVersion(2).get();
// delete is still in cache this should fail
assertRequestBuilderThrows(
client().prepareIndex("test", "type", "1").setSource("f", 3).setVersionType(VersionType.EXTERNAL).setVersion(1),
@ -515,7 +515,7 @@ public class UpdateSettingsIT extends OpenSearchIntegTestCase {
);
assertAcked(client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().put("index.gc_deletes", 0)));
client().prepareDelete("test", "type", "1").setVersionType(VersionType.EXTERNAL).setVersion(4).get();
client().prepareDelete("test", "1").setVersionType(VersionType.EXTERNAL).setVersion(4).get();
// Make sure the time has advanced for InternalEngine#resolveDocVersion()
for (ThreadPool threadPool : internalCluster().getInstances(ThreadPool.class)) {

View File

@ -433,7 +433,7 @@ public class CloseIndexIT extends OpenSearchIntegTestCase {
randomBoolean(),
randomBoolean(),
IntStream.range(0, randomIntBetween(0, 50))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("num", n))
.mapToObj(n -> client().prepareIndex(indexName).setSource("num", n))
.collect(toList())
);
ensureGreen(indexName);
@ -480,7 +480,7 @@ public class CloseIndexIT extends OpenSearchIntegTestCase {
randomBoolean(),
randomBoolean(),
IntStream.range(0, randomIntBetween(0, 50))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("num", n))
.mapToObj(n -> client().prepareIndex(indexName).setSource("num", n))
.collect(toList())
);
ensureGreen(indexName);
@ -492,7 +492,7 @@ public class CloseIndexIT extends OpenSearchIntegTestCase {
Client client = client(dataNodes.get(0));
int moreDocs = randomIntBetween(1, 50);
for (int i = 0; i < moreDocs; i++) {
client.prepareIndex(indexName, "_doc").setSource("num", i).get();
client.prepareIndex(indexName).setSource("num", i).get();
}
assertAcked(client.admin().indices().prepareClose(indexName));
return super.onNodeStopped(nodeName);
@ -529,7 +529,7 @@ public class CloseIndexIT extends OpenSearchIntegTestCase {
randomBoolean(),
randomBoolean(),
IntStream.range(0, randomIntBetween(0, 50))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("num", n))
.mapToObj(n -> client().prepareIndex(indexName).setSource("num", n))
.collect(toList())
);
assertAcked(client().admin().indices().prepareClose(indexName).setWaitForActiveShards(ActiveShardCount.ALL));
@ -557,7 +557,7 @@ public class CloseIndexIT extends OpenSearchIntegTestCase {
randomBoolean(),
randomBoolean(),
IntStream.range(0, randomIntBetween(0, 50))
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("num", n))
.mapToObj(n -> client().prepareIndex(indexName).setSource("num", n))
.collect(toList())
);
ensureGreen(indexName);

View File

@ -120,7 +120,7 @@ public class CloseWhileRelocatingShardsIT extends OpenSearchIntegTestCase {
indexRandom(
randomBoolean(),
IntStream.range(0, nbDocs)
.mapToObj(n -> client().prepareIndex(indexName, "_doc").setSource("num", n))
.mapToObj(n -> client().prepareIndex(indexName).setSource("num", n))
.collect(Collectors.toList())
);
break;

View File

@ -1245,8 +1245,8 @@ public class IndexStatsIT extends OpenSearchIntegTestCase {
assertThat(stats.getTotal().queryCache.getCacheSize(), greaterThan(0L));
});
assertEquals(DocWriteResponse.Result.DELETED, client().prepareDelete("index", "type", "1").get().getResult());
assertEquals(DocWriteResponse.Result.DELETED, client().prepareDelete("index", "type", "2").get().getResult());
assertEquals(DocWriteResponse.Result.DELETED, client().prepareDelete("index", "1").get().getResult());
assertEquals(DocWriteResponse.Result.DELETED, client().prepareDelete("index", "2").get().getResult());
// Here we are testing that a fully deleted segment should be dropped and its cached is evicted.
// In order to instruct the merge policy not to keep a fully deleted segment,
// we need to flush and make that commit safe so that the SoftDeletesPolicy can drop everything.

View File

@ -319,7 +319,7 @@ public class IngestClientIT extends OpenSearchIntegTestCase {
client().admin().cluster().putPipeline(putPipelineRequest).get();
BulkItemResponse item = client(masterOnlyNode).prepareBulk()
.add(client().prepareIndex("test", "type").setSource("field", "value2", "drop", true).setPipeline("_id"))
.add(client().prepareIndex("test").setSource("field", "value2", "drop", true).setPipeline("_id"))
.get()
.getItems()[0];
assertFalse(item.isFailed());
@ -451,7 +451,7 @@ public class IngestClientIT extends OpenSearchIntegTestCase {
client().admin().cluster().putPipeline(putPipelineRequest).get();
}
client().prepareIndex("test", "_doc").setId("1").setSource("{}", XContentType.JSON).setPipeline("1").get();
client().prepareIndex("test").setId("1").setSource("{}", XContentType.JSON).setPipeline("1").get();
Map<String, Object> inserted = client().prepareGet("test", "1").get().getSourceAsMap();
assertThat(inserted.get("readme"), equalTo("pipeline with id [3] is a bad pipeline"));
}

View File

@ -376,12 +376,12 @@ public class RelocationIT extends OpenSearchIntegTestCase {
List<IndexRequestBuilder> builders1 = new ArrayList<>();
for (int numDocs = randomIntBetween(10, 30); numDocs > 0; numDocs--) {
builders1.add(client().prepareIndex("test", "type").setSource("{}", XContentType.JSON));
builders1.add(client().prepareIndex("test").setSource("{}", XContentType.JSON));
}
List<IndexRequestBuilder> builders2 = new ArrayList<>();
for (int numDocs = randomIntBetween(10, 30); numDocs > 0; numDocs--) {
builders2.add(client().prepareIndex("test", "type").setSource("{}", XContentType.JSON));
builders2.add(client().prepareIndex("test").setSource("{}", XContentType.JSON));
}
logger.info("--> START relocate the shard from {} to {}", nodes[fromNode], nodes[toNode]);
@ -441,7 +441,7 @@ public class RelocationIT extends OpenSearchIntegTestCase {
List<IndexRequestBuilder> requests = new ArrayList<>();
int numDocs = scaledRandomIntBetween(25, 250);
for (int i = 0; i < numDocs; i++) {
requests.add(client().prepareIndex(indexName, "type").setSource("{}", XContentType.JSON));
requests.add(client().prepareIndex(indexName).setSource("{}", XContentType.JSON));
}
indexRandom(true, requests);
assertFalse(client().admin().cluster().prepareHealth().setWaitForNodes("3").setWaitForGreenStatus().get().isTimedOut());

View File

@ -79,7 +79,7 @@ public class AliasRoutingIT extends OpenSearchIntegTestCase {
}
logger.info("--> updating with id [1] and routing through alias");
client().prepareUpdate("alias0", "type1", "1")
client().prepareUpdate("alias0", "1")
.setUpsert(XContentFactory.jsonBuilder().startObject().field("field", 1).endObject())
.setDoc(Requests.INDEX_CONTENT_TYPE, "field", "value2")
.execute()
@ -93,7 +93,7 @@ public class AliasRoutingIT extends OpenSearchIntegTestCase {
}
logger.info("--> deleting with no routing, should not delete anything");
client().prepareDelete("test", "type1", "1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareDelete("test", "1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test", "1").setRouting("0").execute().actionGet().isExists(), equalTo(true));
@ -101,7 +101,7 @@ public class AliasRoutingIT extends OpenSearchIntegTestCase {
}
logger.info("--> deleting with routing alias, should delete");
client().prepareDelete("alias0", "type1", "1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareDelete("alias0", "1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test", "1").setRouting("0").execute().actionGet().isExists(), equalTo(false));

View File

@ -108,14 +108,14 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
}
logger.info("--> deleting with no routing, should not delete anything");
client().prepareDelete("test", "type1", "1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareDelete("test", "1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true));
}
logger.info("--> deleting with routing, should delete");
client().prepareDelete("test", "type1", "1").setRouting(routingValue).setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareDelete("test", "1").setRouting(routingValue).setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false));
assertThat(client().prepareGet("test", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(false));
@ -386,7 +386,7 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
logger.info("--> deleting with no routing, should fail");
try {
client().prepareDelete(indexOrAlias(), "type1", "1").get();
client().prepareDelete(indexOrAlias(), "1").get();
fail("delete with missing routing when routing is required should fail");
} catch (OpenSearchException e) {
assertThat(e.unwrapCause(), instanceOf(RoutingMissingException.class));
@ -404,19 +404,13 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
}
try {
client().prepareUpdate(indexOrAlias(), "type1", "1")
.setDoc(Requests.INDEX_CONTENT_TYPE, "field", "value2")
.execute()
.actionGet();
client().prepareUpdate(indexOrAlias(), "1").setDoc(Requests.INDEX_CONTENT_TYPE, "field", "value2").execute().actionGet();
fail("update with missing routing when routing is required should fail");
} catch (OpenSearchException e) {
assertThat(e.unwrapCause(), instanceOf(RoutingMissingException.class));
}
client().prepareUpdate(indexOrAlias(), "type1", "1")
.setRouting(routingValue)
.setDoc(Requests.INDEX_CONTENT_TYPE, "field", "value2")
.get();
client().prepareUpdate(indexOrAlias(), "1").setRouting(routingValue).setDoc(Requests.INDEX_CONTENT_TYPE, "field", "value2").get();
client().admin().indices().prepareRefresh().execute().actionGet();
for (int i = 0; i < 5; i++) {
@ -432,7 +426,7 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
assertThat(getResponse.getSourceAsMap().get("field"), equalTo("value2"));
}
client().prepareDelete(indexOrAlias(), "type1", "1").setRouting(routingValue).setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareDelete(indexOrAlias(), "1").setRouting(routingValue).setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
for (int i = 0; i < 5; i++) {
try {
@ -608,7 +602,7 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
assertThat(e.getMessage(), equalTo("routing is required for [test]/[1]"));
}
UpdateResponse updateResponse = client().prepareUpdate(indexOrAlias(), "type1", "1")
UpdateResponse updateResponse = client().prepareUpdate(indexOrAlias(), "1")
.setRouting(routingValue)
.setDoc(Requests.INDEX_CONTENT_TYPE, "field1", "value1")
.get();
@ -616,7 +610,7 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
assertThat(updateResponse.getVersion(), equalTo(2L));
try {
client().prepareUpdate(indexOrAlias(), "type1", "1").setDoc(Requests.INDEX_CONTENT_TYPE, "field1", "value1").get();
client().prepareUpdate(indexOrAlias(), "1").setDoc(Requests.INDEX_CONTENT_TYPE, "field1", "value1").get();
fail();
} catch (RoutingMissingException e) {
assertThat(e.getMessage(), equalTo("routing is required for [test]/[1]"));

View File

@ -90,17 +90,14 @@ public class ScriptCacheIT extends OpenSearchIntegTestCase {
}
public void testPainlessCompilationLimit429Error() throws Exception {
client().prepareIndex("test", "1")
.setId("1")
.setSource(XContentFactory.jsonBuilder().startObject().field("field", 1).endObject())
.get();
client().prepareIndex("test").setId("1").setSource(XContentFactory.jsonBuilder().startObject().field("field", 1).endObject()).get();
ensureGreen();
Map<String, Object> params = new HashMap<>();
params.put("field", "field");
Script script = new Script(ScriptType.INLINE, "mockscript", "increase_field", params);
ExecutionException exception = expectThrows(
ExecutionException.class,
() -> client().prepareUpdate("test", "1", "1").setScript(script).execute().get()
() -> client().prepareUpdate("test", "1").setScript(script).execute().get()
);
Throwable rootCause = getRootCause(exception);
assertTrue(rootCause instanceof OpenSearchException);

View File

@ -56,7 +56,7 @@ public class AggregationsIntegrationIT extends OpenSearchIntegTestCase {
numDocs = randomIntBetween(1, 20);
List<IndexRequestBuilder> docs = new ArrayList<>();
for (int i = 0; i < numDocs; ++i) {
docs.add(client().prepareIndex("index", "type").setSource("f", Integer.toString(i / 3)));
docs.add(client().prepareIndex("index").setSource("f", Integer.toString(i / 3)));
}
indexRandom(true, docs);
}

View File

@ -73,11 +73,11 @@ public class CombiIT extends OpenSearchIntegTestCase {
String name = "name_" + randomIntBetween(1, 10);
if (rarely()) {
missingValues++;
builders[i] = client().prepareIndex("idx", "type").setSource(jsonBuilder().startObject().field("name", name).endObject());
builders[i] = client().prepareIndex("idx").setSource(jsonBuilder().startObject().field("name", name).endObject());
} else {
int value = randomIntBetween(1, 10);
values.put(value, values.getOrDefault(value, 0) + 1);
builders[i] = client().prepareIndex("idx", "type")
builders[i] = client().prepareIndex("idx")
.setSource(jsonBuilder().startObject().field("name", name).field("value", value).endObject());
}
}

View File

@ -152,7 +152,7 @@ public class EquivalenceIT extends OpenSearchIntegTestCase {
source = source.value(docs[i][j]);
}
source = source.endArray().endObject();
client().prepareIndex("idx", "type").setSource(source).get();
client().prepareIndex("idx").setSource(source).get();
}
assertNoFailures(client().admin().indices().prepareRefresh("idx").setIndicesOptions(IndicesOptions.lenientExpandOpen()).get());
@ -283,7 +283,7 @@ public class EquivalenceIT extends OpenSearchIntegTestCase {
source = source.value(Integer.toString(values[j]));
}
source = source.endArray().endObject();
indexingRequests.add(client().prepareIndex("idx", "type").setSource(source));
indexingRequests.add(client().prepareIndex("idx").setSource(source));
}
indexRandom(true, indexingRequests);
@ -387,7 +387,7 @@ public class EquivalenceIT extends OpenSearchIntegTestCase {
source = source.value(randomFrom(values));
}
source = source.endArray().endObject();
client().prepareIndex("idx", "type").setSource(source).get();
client().prepareIndex("idx").setSource(source).get();
}
assertNoFailures(
client().admin().indices().prepareRefresh("idx").setIndicesOptions(IndicesOptions.lenientExpandOpen()).execute().get()
@ -458,7 +458,7 @@ public class EquivalenceIT extends OpenSearchIntegTestCase {
public void testReduce() throws Exception {
createIndex("idx");
final int value = randomIntBetween(0, 10);
indexRandom(true, client().prepareIndex("idx", "type").setSource("f", value));
indexRandom(true, client().prepareIndex("idx").setSource("f", value));
SearchResponse response = client().prepareSearch("idx")
.addAggregation(
filter("filter", QueryBuilders.matchAllQuery()).subAggregation(
@ -518,7 +518,7 @@ public class EquivalenceIT extends OpenSearchIntegTestCase {
final int v1 = randomInt(1 << randomInt(7));
final int v2 = randomInt(1 << randomInt(7));
final int v3 = randomInt(1 << randomInt(7));
reqs.add(client().prepareIndex("idx", "type").setSource("f1", v1, "f2", v2, "f3", v3));
reqs.add(client().prepareIndex("idx").setSource("f1", v1, "f2", v2, "f3", v3));
}
indexRandom(true, reqs);

View File

@ -57,7 +57,7 @@ public class MetadataIT extends OpenSearchIntegTestCase {
IndexRequestBuilder[] builders = new IndexRequestBuilder[randomInt(30)];
for (int i = 0; i < builders.length; i++) {
String name = "name_" + randomIntBetween(1, 10);
builders[i] = client().prepareIndex("idx", "type")
builders[i] = client().prepareIndex("idx")
.setSource(jsonBuilder().startObject().field("name", name).field("value", randomInt()).endObject());
}
indexRandom(true, builders);

View File

@ -86,7 +86,7 @@ public class BooleanTermsIT extends OpenSearchIntegTestCase {
default:
throw new AssertionError();
}
builders[i] = client().prepareIndex("idx", "type")
builders[i] = client().prepareIndex("idx")
.setSource(
jsonBuilder().startObject()
.field(SINGLE_VALUED_FIELD_NAME, singleValue)

View File

@ -113,7 +113,7 @@ public class DateHistogramIT extends OpenSearchIntegTestCase {
}
private IndexRequestBuilder indexDoc(String idx, ZonedDateTime date, int value) throws Exception {
return client().prepareIndex(idx, "type")
return client().prepareIndex(idx)
.setSource(
jsonBuilder().startObject()
.timeField("date", date)
@ -127,7 +127,7 @@ public class DateHistogramIT extends OpenSearchIntegTestCase {
}
private IndexRequestBuilder indexDoc(int month, int day, int value) throws Exception {
return client().prepareIndex("idx", "type")
return client().prepareIndex("idx")
.setSource(
jsonBuilder().startObject()
.field("value", value)
@ -191,44 +191,44 @@ public class DateHistogramIT extends OpenSearchIntegTestCase {
assertAcked(client().admin().indices().prepareCreate("sort_idx").addMapping("type", "date", "type=date").get());
for (int i = 1; i <= 3; i++) {
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().timeField("date", date(1, 1)).field("l", 1).field("d", i).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().timeField("date", date(1, 2)).field("l", 2).field("d", i).endObject())
);
}
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().timeField("date", date(1, 3)).field("l", 3).field("d", 1).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().timeField("date", date(1, 3).plusHours(1)).field("l", 3).field("d", 2).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().timeField("date", date(1, 4)).field("l", 3).field("d", 1).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().timeField("date", date(1, 4).plusHours(2)).field("l", 3).field("d", 3).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().timeField("date", date(1, 5)).field("l", 5).field("d", 1).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().timeField("date", date(1, 5).plusHours(12)).field("l", 5).field("d", 2).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().timeField("date", date(1, 6)).field("l", 5).field("d", 1).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().timeField("date", date(1, 7)).field("l", 5).field("d", 1).endObject())
);
}
@ -1397,8 +1397,8 @@ public class DateHistogramIT extends OpenSearchIntegTestCase {
assertAcked(client().admin().indices().prepareCreate("test9491").addMapping("type", "d", "type=date").get());
indexRandom(
true,
client().prepareIndex("test9491", "type").setSource("d", "2014-10-08T13:00:00Z"),
client().prepareIndex("test9491", "type").setSource("d", "2014-11-08T13:00:00Z")
client().prepareIndex("test9491").setSource("d", "2014-10-08T13:00:00Z"),
client().prepareIndex("test9491").setSource("d", "2014-11-08T13:00:00Z")
);
ensureSearchable("test9491");
SearchResponse response = client().prepareSearch("test9491")
@ -1420,9 +1420,9 @@ public class DateHistogramIT extends OpenSearchIntegTestCase {
assertAcked(client().admin().indices().prepareCreate("test8209").addMapping("type", "d", "type=date").get());
indexRandom(
true,
client().prepareIndex("test8209", "type").setSource("d", "2014-01-01T00:00:00Z"),
client().prepareIndex("test8209", "type").setSource("d", "2014-04-01T00:00:00Z"),
client().prepareIndex("test8209", "type").setSource("d", "2014-04-30T00:00:00Z")
client().prepareIndex("test8209").setSource("d", "2014-01-01T00:00:00Z"),
client().prepareIndex("test8209").setSource("d", "2014-04-01T00:00:00Z"),
client().prepareIndex("test8209").setSource("d", "2014-04-30T00:00:00Z")
);
ensureSearchable("test8209");
SearchResponse response = client().prepareSearch("test8209")
@ -1471,7 +1471,7 @@ public class DateHistogramIT extends OpenSearchIntegTestCase {
*/
public void testFormatIndexUnmapped() throws InterruptedException, ExecutionException {
String indexDateUnmapped = "test31760";
indexRandom(true, client().prepareIndex(indexDateUnmapped, "_doc").setSource("foo", "bar"));
indexRandom(true, client().prepareIndex(indexDateUnmapped).setSource("foo", "bar"));
ensureSearchable(indexDateUnmapped);
SearchResponse response = client().prepareSearch(indexDateUnmapped)
@ -1499,7 +1499,7 @@ public class DateHistogramIT extends OpenSearchIntegTestCase {
public void testRewriteTimeZone_EpochMillisFormat() throws InterruptedException, ExecutionException {
String index = "test31392";
assertAcked(client().admin().indices().prepareCreate(index).addMapping("type", "d", "type=date,format=epoch_millis").get());
indexRandom(true, client().prepareIndex(index, "type").setSource("d", "1477954800000"));
indexRandom(true, client().prepareIndex(index).setSource("d", "1477954800000"));
ensureSearchable(index);
SearchResponse response = client().prepareSearch(index)
.addAggregation(

View File

@ -79,7 +79,7 @@ import static org.hamcrest.core.IsNull.nullValue;
public class DateRangeIT extends OpenSearchIntegTestCase {
private static IndexRequestBuilder indexDoc(int month, int day, int value) throws Exception {
return client().prepareIndex("idx", "type")
return client().prepareIndex("idx")
.setSource(
jsonBuilder().startObject()
.field("value", value)

View File

@ -147,7 +147,7 @@ public class DoubleTermsIT extends AbstractTermsTestCase {
List<IndexRequestBuilder> builders = new ArrayList<>();
for (int i = 0; i < NUM_DOCS; i++) {
builders.add(
client().prepareIndex("idx", "type")
client().prepareIndex("idx")
.setSource(
jsonBuilder().startObject()
.field(SINGLE_VALUED_FIELD_NAME, (double) i)
@ -164,7 +164,7 @@ public class DoubleTermsIT extends AbstractTermsTestCase {
}
for (int i = 0; i < 100; i++) {
builders.add(
client().prepareIndex("high_card_idx", "type")
client().prepareIndex("high_card_idx")
.setSource(
jsonBuilder().startObject()
.field(SINGLE_VALUED_FIELD_NAME, (double) i)
@ -240,44 +240,44 @@ public class DoubleTermsIT extends AbstractTermsTestCase {
assertAcked(prepareCreate("sort_idx").addMapping("multi_sort_type", SINGLE_VALUED_FIELD_NAME, "type=double"));
for (int i = 1; i <= 3; i++) {
builders.add(
client().prepareIndex("sort_idx", "multi_sort_type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 1).field("l", 1).field("d", i).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "multi_sort_type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 2).field("l", 2).field("d", i).endObject())
);
}
builders.add(
client().prepareIndex("sort_idx", "multi_sort_type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 3).field("l", 3).field("d", 1).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "multi_sort_type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 3).field("l", 3).field("d", 2).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "multi_sort_type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 4).field("l", 3).field("d", 1).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "multi_sort_type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 4).field("l", 3).field("d", 3).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "multi_sort_type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 5).field("l", 5).field("d", 1).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "multi_sort_type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 5).field("l", 5).field("d", 2).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "multi_sort_type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 6).field("l", 5).field("d", 1).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "multi_sort_type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 7).field("l", 5).field("d", 1).endObject())
);
}

View File

@ -87,7 +87,7 @@ public class GeoDistanceIT extends OpenSearchIntegTestCase {
}
source.endArray();
source = source.endObject();
return client().prepareIndex(idx, "type").setSource(source);
return client().prepareIndex(idx).setSource(source);
}
@Override

View File

@ -88,7 +88,7 @@ public class GeoHashGridIT extends OpenSearchIntegTestCase {
source = source.field("location", latLon);
}
source = source.endObject();
return client().prepareIndex(index, "type").setSource(source);
return client().prepareIndex(index).setSource(source);
}
private static IndexRequestBuilder indexCity(String index, String name, String latLon) throws Exception {

View File

@ -163,7 +163,7 @@ public class HistogramIT extends OpenSearchIntegTestCase {
for (int i = 0; i < numDocs; i++) {
builders.add(
client().prepareIndex("idx", "type")
client().prepareIndex("idx")
.setSource(
jsonBuilder().startObject()
.field(SINGLE_VALUED_FIELD_NAME, i + 1)
@ -213,44 +213,44 @@ public class HistogramIT extends OpenSearchIntegTestCase {
assertAcked(client().admin().indices().prepareCreate("sort_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=double").get());
for (int i = 1; i <= 3; i++) {
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 1).field("l", 1).field("d", i).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 2).field("l", 2).field("d", i).endObject())
);
}
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 3).field("l", 3).field("d", 1).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 3.8).field("l", 3).field("d", 2).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 4).field("l", 3).field("d", 1).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 4.4).field("l", 3).field("d", 3).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 5).field("l", 5).field("d", 1).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 5.1).field("l", 5).field("d", 2).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 6).field("l", 5).field("d", 1).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 7).field("l", 5).field("d", 1).endObject())
);
}

View File

@ -133,7 +133,7 @@ public class LongTermsIT extends AbstractTermsTestCase {
createIndex("idx", "high_card_idx");
IndexRequestBuilder[] lowCardBuilders = new IndexRequestBuilder[NUM_DOCS];
for (int i = 0; i < lowCardBuilders.length; i++) {
lowCardBuilders[i] = client().prepareIndex("idx", "type")
lowCardBuilders[i] = client().prepareIndex("idx")
.setSource(
jsonBuilder().startObject()
.field(SINGLE_VALUED_FIELD_NAME, i)
@ -149,7 +149,7 @@ public class LongTermsIT extends AbstractTermsTestCase {
indexRandom(true, lowCardBuilders);
IndexRequestBuilder[] highCardBuilders = new IndexRequestBuilder[100]; // TODO randomize the size?
for (int i = 0; i < highCardBuilders.length; i++) {
highCardBuilders[i] = client().prepareIndex("high_card_idx", "type")
highCardBuilders[i] = client().prepareIndex("high_card_idx")
.setSource(
jsonBuilder().startObject()
.field(SINGLE_VALUED_FIELD_NAME, i)
@ -227,44 +227,44 @@ public class LongTermsIT extends AbstractTermsTestCase {
createIndex("sort_idx");
for (int i = 1; i <= 3; i++) {
builders.add(
client().prepareIndex("sort_idx", "multi_sort_type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 1).field("l", 1).field("d", i).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "multi_sort_type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 2).field("l", 2).field("d", i).endObject())
);
}
builders.add(
client().prepareIndex("sort_idx", "multi_sort_type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 3).field("l", 3).field("d", 1).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "multi_sort_type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 3).field("l", 3).field("d", 2).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "multi_sort_type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 4).field("l", 3).field("d", 1).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "multi_sort_type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 4).field("l", 3).field("d", 3).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "multi_sort_type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 5).field("l", 5).field("d", 1).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "multi_sort_type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 5).field("l", 5).field("d", 2).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "multi_sort_type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 6).field("l", 5).field("d", 1).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "multi_sort_type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, 7).field("l", 5).field("d", 1).endObject())
);
}

View File

@ -139,7 +139,7 @@ public class MinDocCountIT extends AbstractTermsTestCase {
final int frequency = randomBoolean() ? 1 : randomIntBetween(2, 20);
for (int j = 0; j < frequency; ++j) {
indexRequests.add(
client().prepareIndex("idx", "type")
client().prepareIndex("idx")
.setSource(
jsonBuilder().startObject()
.field("s", stringTerm)

View File

@ -143,7 +143,7 @@ public class NaNSortingIT extends OpenSearchIntegTestCase {
if (randomBoolean()) {
source.field("numeric_value", randomDouble());
}
client().prepareIndex("idx", "type").setSource(source.endObject()).get();
client().prepareIndex("idx").setSource(source.endObject()).get();
}
refresh();
ensureSearchable();

View File

@ -123,7 +123,7 @@ public class RangeIT extends OpenSearchIntegTestCase {
List<IndexRequestBuilder> builders = new ArrayList<>();
for (int i = 0; i < numDocs; i++) {
builders.add(
client().prepareIndex("idx", "type")
client().prepareIndex("idx")
.setSource(
jsonBuilder().startObject()
.field(SINGLE_VALUED_FIELD_NAME, i + 1)
@ -154,10 +154,10 @@ public class RangeIT extends OpenSearchIntegTestCase {
prepareCreate("old_index").addMapping("_doc", "distance", "type=double", "route_length_miles", "type=alias,path=distance").get();
prepareCreate("new_index").addMapping("_doc", "route_length_miles", "type=double").get();
builders.add(client().prepareIndex("old_index", "_doc").setSource("distance", 42.0));
builders.add(client().prepareIndex("old_index", "_doc").setSource("distance", 50.5));
builders.add(client().prepareIndex("new_index", "_doc").setSource("route_length_miles", 100.2));
builders.add(client().prepareIndex("new_index", "_doc").setSource(Collections.emptyMap()));
builders.add(client().prepareIndex("old_index").setSource("distance", 42.0));
builders.add(client().prepareIndex("old_index").setSource("distance", 50.5));
builders.add(client().prepareIndex("new_index").setSource("route_length_miles", 100.2));
builders.add(client().prepareIndex("new_index").setSource(Collections.emptyMap()));
indexRandom(true, builders);
ensureSearchable();

View File

@ -156,7 +156,7 @@ public class ReverseNestedIT extends OpenSearchIntegTestCase {
source.startObject().field("field2", value1).endObject();
}
source.endArray().endObject();
indexRandom(false, client().prepareIndex("idx1", "type").setRouting("1").setSource(source));
indexRandom(false, client().prepareIndex("idx1").setRouting("1").setSource(source));
}
private void insertIdx2(String[][] values) throws Exception {
@ -169,7 +169,7 @@ public class ReverseNestedIT extends OpenSearchIntegTestCase {
source.endArray().endObject();
}
source.endArray().endObject();
indexRandom(false, client().prepareIndex("idx2", "type").setRouting("1").setSource(source));
indexRandom(false, client().prepareIndex("idx2").setRouting("1").setSource(source));
}
public void testSimpleReverseNestedToRoot() throws Exception {

View File

@ -74,7 +74,7 @@ import static org.hamcrest.Matchers.equalTo;
public class ShardReduceIT extends OpenSearchIntegTestCase {
private IndexRequestBuilder indexDoc(String date, int value) throws Exception {
return client().prepareIndex("idx", "type")
return client().prepareIndex("idx")
.setSource(
jsonBuilder().startObject()
.field("value", value)

View File

@ -40,6 +40,7 @@ import org.opensearch.common.xcontent.ToXContent;
import org.opensearch.common.xcontent.XContentBuilder;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.index.mapper.MapperService;
import org.opensearch.index.query.QueryBuilder;
import org.opensearch.index.query.QueryBuilders;
import org.opensearch.plugins.Plugin;
@ -92,7 +93,6 @@ import static org.hamcrest.Matchers.is;
public class SignificantTermsSignificanceScoreIT extends OpenSearchIntegTestCase {
static final String INDEX_NAME = "testidx";
static final String DOC_TYPE = "_doc";
static final String TEXT_FIELD = "text";
static final String CLASS_FIELD = "class";
@ -222,10 +222,10 @@ public class SignificantTermsSignificanceScoreIT extends OpenSearchIntegTestCase
String[] cat2v1 = { "constant", "two" };
String[] cat2v2 = { "constant", "duo" };
List<IndexRequestBuilder> indexRequestBuilderList = new ArrayList<>();
indexRequestBuilderList.add(client().prepareIndex(INDEX_NAME, DOC_TYPE, "1").setSource(TEXT_FIELD, cat1v1, CLASS_FIELD, "1"));
indexRequestBuilderList.add(client().prepareIndex(INDEX_NAME, DOC_TYPE, "2").setSource(TEXT_FIELD, cat1v2, CLASS_FIELD, "1"));
indexRequestBuilderList.add(client().prepareIndex(INDEX_NAME, DOC_TYPE, "3").setSource(TEXT_FIELD, cat2v1, CLASS_FIELD, "2"));
indexRequestBuilderList.add(client().prepareIndex(INDEX_NAME, DOC_TYPE, "4").setSource(TEXT_FIELD, cat2v2, CLASS_FIELD, "2"));
indexRequestBuilderList.add(client().prepareIndex(INDEX_NAME).setId("1").setSource(TEXT_FIELD, cat1v1, CLASS_FIELD, "1"));
indexRequestBuilderList.add(client().prepareIndex(INDEX_NAME).setId("2").setSource(TEXT_FIELD, cat1v2, CLASS_FIELD, "1"));
indexRequestBuilderList.add(client().prepareIndex(INDEX_NAME).setId("3").setSource(TEXT_FIELD, cat2v1, CLASS_FIELD, "2"));
indexRequestBuilderList.add(client().prepareIndex(INDEX_NAME).setId("4").setSource(TEXT_FIELD, cat2v2, CLASS_FIELD, "2"));
indexRandom(true, false, indexRequestBuilderList);
// Now create some holes in the index with selective deletes caused by updates.
@ -236,7 +236,7 @@ public class SignificantTermsSignificanceScoreIT extends OpenSearchIntegTestCase
indexRequestBuilderList.clear();
for (int i = 0; i < 50; i++) {
text = text == cat1v2 ? cat1v1 : cat1v2;
indexRequestBuilderList.add(client().prepareIndex(INDEX_NAME, DOC_TYPE, "1").setSource(TEXT_FIELD, text, CLASS_FIELD, "1"));
indexRequestBuilderList.add(client().prepareIndex(INDEX_NAME).setId("1").setSource(TEXT_FIELD, text, CLASS_FIELD, "1"));
}
indexRandom(true, false, indexRequestBuilderList);
@ -545,7 +545,9 @@ public class SignificantTermsSignificanceScoreIT extends OpenSearchIntegTestCase
if (type.equals("text")) {
textMappings += ",fielddata=true";
}
assertAcked(prepareCreate(INDEX_NAME).addMapping(DOC_TYPE, TEXT_FIELD, textMappings, CLASS_FIELD, "type=keyword"));
assertAcked(
prepareCreate(INDEX_NAME).addMapping(MapperService.SINGLE_MAPPING_NAME, TEXT_FIELD, textMappings, CLASS_FIELD, "type=keyword")
);
String[] gb = { "0", "1" };
List<IndexRequestBuilder> indexRequestBuilderList = new ArrayList<>();
for (int i = 0; i < randomInt(20); i++) {
@ -557,7 +559,7 @@ public class SignificantTermsSignificanceScoreIT extends OpenSearchIntegTestCase
text[0] = gb[randNum];
}
indexRequestBuilderList.add(
client().prepareIndex(INDEX_NAME, DOC_TYPE).setSource(TEXT_FIELD, text, CLASS_FIELD, randomBoolean() ? "one" : "zero")
client().prepareIndex(INDEX_NAME).setSource(TEXT_FIELD, text, CLASS_FIELD, randomBoolean() ? "one" : "zero")
);
}
indexRandom(true, indexRequestBuilderList);

View File

@ -35,6 +35,7 @@ import org.opensearch.action.index.IndexRequestBuilder;
import org.opensearch.action.search.SearchResponse;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.index.mapper.MapperService;
import org.opensearch.index.query.QueryBuilders;
import org.opensearch.search.aggregations.BucketOrder;
import org.opensearch.search.aggregations.bucket.filter.InternalFilter;
@ -57,7 +58,6 @@ import static org.hamcrest.Matchers.equalTo;
public class TermsShardMinDocCountIT extends OpenSearchIntegTestCase {
private static final String index = "someindex";
private static final String type = "testtype";
private static String randomExecutionHint() {
return randomBoolean() ? null : randomFrom(SignificantTermsAggregatorFactory.ExecutionMode.values()).toString();
@ -73,7 +73,7 @@ public class TermsShardMinDocCountIT extends OpenSearchIntegTestCase {
}
assertAcked(
prepareCreate(index).setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0))
.addMapping(type, "text", textMappings)
.addMapping(MapperService.SINGLE_MAPPING_NAME, "text", textMappings)
);
List<IndexRequestBuilder> indexBuilders = new ArrayList<>();
@ -125,10 +125,10 @@ public class TermsShardMinDocCountIT extends OpenSearchIntegTestCase {
String sourceClass = "{\"text\": \"" + term + "\", \"class\":" + "true" + "}";
String sourceNotClass = "{\"text\": \"" + term + "\", \"class\":" + "false" + "}";
for (int i = 0; i < numInClass; i++) {
builders.add(client().prepareIndex(index, type).setSource(sourceClass, XContentType.JSON));
builders.add(client().prepareIndex(index).setSource(sourceClass, XContentType.JSON));
}
for (int i = 0; i < numNotInClass; i++) {
builders.add(client().prepareIndex(index, type).setSource(sourceNotClass, XContentType.JSON));
builders.add(client().prepareIndex(index).setSource(sourceNotClass, XContentType.JSON));
}
}
@ -142,7 +142,7 @@ public class TermsShardMinDocCountIT extends OpenSearchIntegTestCase {
}
assertAcked(
prepareCreate(index).setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0))
.addMapping(type, "text", termMappings)
.addMapping(MapperService.SINGLE_MAPPING_NAME, "text", termMappings)
);
List<IndexRequestBuilder> indexBuilders = new ArrayList<>();
@ -189,7 +189,7 @@ public class TermsShardMinDocCountIT extends OpenSearchIntegTestCase {
private static void addTermsDocs(String term, int numDocs, List<IndexRequestBuilder> builders) {
String sourceClass = "{\"text\": \"" + term + "\"}";
for (int i = 0; i < numDocs; i++) {
builders.add(client().prepareIndex(index, type).setSource(sourceClass, XContentType.JSON));
builders.add(client().prepareIndex(index).setSource(sourceClass, XContentType.JSON));
}
}
}

View File

@ -171,7 +171,7 @@ public class StringTermsIT extends AbstractTermsTestCase {
List<IndexRequestBuilder> builders = new ArrayList<>();
for (int i = 0; i < 5; i++) {
builders.add(
client().prepareIndex("idx", "type")
client().prepareIndex("idx")
.setSource(
jsonBuilder().startObject()
.field(SINGLE_VALUED_FIELD_NAME, "val" + i)
@ -206,7 +206,7 @@ public class StringTermsIT extends AbstractTermsTestCase {
);
for (int i = 0; i < 100; i++) {
builders.add(
client().prepareIndex("high_card_idx", "type")
client().prepareIndex("high_card_idx")
.setSource(
jsonBuilder().startObject()
.field(SINGLE_VALUED_FIELD_NAME, "val" + Strings.padStart(i + "", 3, '0'))
@ -293,44 +293,44 @@ public class StringTermsIT extends AbstractTermsTestCase {
);
for (int i = 1; i <= 3; i++) {
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, "val1").field("l", 1).field("d", i).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, "val2").field("l", 2).field("d", i).endObject())
);
}
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, "val3").field("l", 3).field("d", 1).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, "val3").field("l", 3).field("d", 2).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, "val4").field("l", 3).field("d", 1).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, "val4").field("l", 3).field("d", 3).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, "val5").field("l", 5).field("d", 1).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, "val5").field("l", 5).field("d", 2).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, "val6").field("l", 5).field("d", 1).endObject())
);
builders.add(
client().prepareIndex("sort_idx", "type")
client().prepareIndex("sort_idx")
.setSource(jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, "val7").field("l", 5).field("d", 1).endObject())
);
}

View File

@ -160,7 +160,7 @@ public class CardinalityIT extends OpenSearchIntegTestCase {
precisionThreshold = randomIntBetween(0, 1 << randomInt(20));
IndexRequestBuilder[] builders = new IndexRequestBuilder[(int) numDocs];
for (int i = 0; i < numDocs; ++i) {
builders[i] = client().prepareIndex("idx", "type")
builders[i] = client().prepareIndex("idx")
.setSource(
jsonBuilder().startObject()
.field("str_value", "s" + i)
@ -177,7 +177,7 @@ public class CardinalityIT extends OpenSearchIntegTestCase {
IndexRequestBuilder[] dummyDocsBuilder = new IndexRequestBuilder[10];
for (int i = 0; i < dummyDocsBuilder.length; i++) {
dummyDocsBuilder[i] = client().prepareIndex("idx", "type").setSource("a_field", "1");
dummyDocsBuilder[i] = client().prepareIndex("idx").setSource("a_field", "1");
}
indexRandom(true, dummyDocsBuilder);

View File

@ -60,7 +60,7 @@ public class CardinalityWithRequestBreakerIT extends OpenSearchIntegTestCase {
true,
IntStream.range(0, randomIntBetween(10, 1000))
.mapToObj(
i -> client().prepareIndex("test", "_doc")
i -> client().prepareIndex("test")
.setId("id_" + i)
.setSource(org.opensearch.common.collect.Map.of("field0", randomAlphaOfLength(5), "field1", randomAlphaOfLength(5)))
)

View File

@ -91,9 +91,9 @@ public class SumIT extends AbstractNumericTestCase {
prepareCreate("new_index").addMapping("_doc", "transit_mode", "type=keyword", "route_length_miles", "type=double").get();
List<IndexRequestBuilder> builders = new ArrayList<>();
builders.add(client().prepareIndex("old_index", "_doc").setSource("transit_mode", "train", "distance", 42.0));
builders.add(client().prepareIndex("old_index", "_doc").setSource("transit_mode", "bus", "distance", 50.5));
builders.add(client().prepareIndex("new_index", "_doc").setSource("transit_mode", "train", "route_length_miles", 100.2));
builders.add(client().prepareIndex("old_index").setSource("transit_mode", "train", "distance", 42.0));
builders.add(client().prepareIndex("old_index").setSource("transit_mode", "bus", "distance", 50.5));
builders.add(client().prepareIndex("new_index").setSource("transit_mode", "train", "route_length_miles", 100.2));
indexRandom(true, builders);
ensureSearchable();

View File

@ -243,7 +243,7 @@ public class TopHitsIT extends OpenSearchIntegTestCase {
}
builder.endArray().endObject();
builders.add(client().prepareIndex("articles", "article").setSource(builder));
builders.add(client().prepareIndex("articles").setSource(builder));
}
builders.add(

View File

@ -88,7 +88,7 @@ public class AvgBucketIT extends OpenSearchIntegTestCase {
for (int i = 0; i < numDocs; i++) {
int fieldValue = randomIntBetween(minRandomValue, maxRandomValue);
builders.add(
client().prepareIndex("idx", "type")
client().prepareIndex("idx")
.setSource(
jsonBuilder().startObject()
.field(SINGLE_VALUED_FIELD_NAME, fieldValue)

View File

@ -155,7 +155,7 @@ public class BucketScriptIT extends OpenSearchIntegTestCase {
List<IndexRequestBuilder> builders = new ArrayList<>();
for (int docs = 0; docs < numDocs; docs++) {
builders.add(client().prepareIndex("idx", "type").setSource(newDocBuilder()));
builders.add(client().prepareIndex("idx").setSource(newDocBuilder()));
}
indexRandom(true, builders);

View File

@ -162,12 +162,12 @@ public class BucketSelectorIT extends OpenSearchIntegTestCase {
List<IndexRequestBuilder> builders = new ArrayList<>();
for (int docs = 0; docs < numDocs; docs++) {
builders.add(client().prepareIndex("idx", "type").setSource(newDocBuilder()));
builders.add(client().prepareIndex("idx").setSource(newDocBuilder()));
}
builders.add(client().prepareIndex("idx_with_gaps", "type").setSource(newDocBuilder(1, 1, 0, 0)));
builders.add(client().prepareIndex("idx_with_gaps", "type").setSource(newDocBuilder(1, 2, 0, 0)));
builders.add(client().prepareIndex("idx_with_gaps", "type").setSource(newDocBuilder(3, 1, 0, 0)));
builders.add(client().prepareIndex("idx_with_gaps", "type").setSource(newDocBuilder(3, 3, 0, 0)));
builders.add(client().prepareIndex("idx_with_gaps").setSource(newDocBuilder(1, 1, 0, 0)));
builders.add(client().prepareIndex("idx_with_gaps").setSource(newDocBuilder(1, 2, 0, 0)));
builders.add(client().prepareIndex("idx_with_gaps").setSource(newDocBuilder(3, 1, 0, 0)));
builders.add(client().prepareIndex("idx_with_gaps").setSource(newDocBuilder(3, 3, 0, 0)));
indexRandom(true, builders);
ensureSearchable();

View File

@ -102,16 +102,16 @@ public class BucketSortIT extends OpenSearchIntegTestCase {
int termCount = randomIntBetween(3, 6);
for (int i = 0; i < termCount; ++i) {
builders.add(
client().prepareIndex(INDEX, "doc").setSource(newDocBuilder(time, term, randomIntBetween(1, 10) * randomDouble()))
client().prepareIndex(INDEX).setSource(newDocBuilder(time, term, randomIntBetween(1, 10) * randomDouble()))
);
}
}
time += TimeValue.timeValueHours(1).millis();
}
builders.add(client().prepareIndex(INDEX_WITH_GAPS, "doc").setSource(newDocBuilder(1, "foo", 1.0, 42.0)));
builders.add(client().prepareIndex(INDEX_WITH_GAPS, "doc").setSource(newDocBuilder(2, "foo", null, 42.0)));
builders.add(client().prepareIndex(INDEX_WITH_GAPS, "doc").setSource(newDocBuilder(3, "foo", 3.0, 42.0)));
builders.add(client().prepareIndex(INDEX_WITH_GAPS).setSource(newDocBuilder(1, "foo", 1.0, 42.0)));
builders.add(client().prepareIndex(INDEX_WITH_GAPS).setSource(newDocBuilder(2, "foo", null, 42.0)));
builders.add(client().prepareIndex(INDEX_WITH_GAPS).setSource(newDocBuilder(3, "foo", 3.0, 42.0)));
indexRandom(true, builders);
ensureSearchable();

Some files were not shown because too many files have changed in this diff Show More