[Remove] remaining type usage in Client and AbstractClient (#2258)

Removes type parameter from remaining prepareIndex in Client and AbstractClient.

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
This commit is contained in:
Nick Knize 2022-02-25 13:35:48 -06:00 committed by GitHub
parent 3a4c2f6af4
commit 0bd7850bed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
229 changed files with 1911 additions and 1515 deletions

View File

@ -76,7 +76,7 @@ public class QueryStringWithAnalyzersIT extends OpenSearchIntegTestCase {
.addMapping("type1", "field1", "type=text,analyzer=my_analyzer", "field2", "type=text,analyzer=my_analyzer")
);
client().prepareIndex("test", "type1", "1").setSource("field1", "foo bar baz", "field2", "not needed").get();
client().prepareIndex("test").setId("1").setSource("field1", "foo bar baz", "field2", "not needed").get();
refresh();
SearchResponse response = client().prepareSearch("test")

View File

@ -137,7 +137,7 @@ public class HighlighterWithAnalyzersTests extends OpenSearchIntegTestCase {
.putList("analysis.analyzer.search_autocomplete.filter", "lowercase", "wordDelimiter")
)
);
client().prepareIndex("test", "test", "1").setSource("name", "ARCOTEL Hotels Deutschland").get();
client().prepareIndex("test").setId("1").setSource("name", "ARCOTEL Hotels Deutschland").get();
refresh();
SearchResponse search = client().prepareSearch("test")
.setQuery(matchQuery("name.autocomplete", "deut tel").operator(Operator.OR))
@ -173,7 +173,8 @@ public class HighlighterWithAnalyzersTests extends OpenSearchIntegTestCase {
);
ensureGreen();
client().prepareIndex("test", "test", "1")
client().prepareIndex("test")
.setId("1")
.setSource(
"body",
"Test: http://www.facebook.com http://elasticsearch.org "
@ -235,7 +236,7 @@ public class HighlighterWithAnalyzersTests extends OpenSearchIntegTestCase {
);
ensureGreen();
client().prepareIndex("test", "type1", "0").setSource("field1", "The quick brown fox jumps over the lazy dog").get();
client().prepareIndex("test").setId("0").setSource("field1", "The quick brown fox jumps over the lazy dog").get();
refresh();
for (String highlighterType : new String[] { "plain", "fvh", "unified" }) {
logger.info("--> highlighting (type=" + highlighterType + ") and searching on field1");
@ -263,10 +264,12 @@ public class HighlighterWithAnalyzersTests extends OpenSearchIntegTestCase {
ensureGreen();
client().prepareIndex("first_test_index", "type1", "0")
client().prepareIndex("first_test_index")
.setId("0")
.setSource("field0", "The quick brown fox jumps over the lazy dog", "field1", "The quick brown fox jumps over the lazy dog")
.get();
client().prepareIndex("first_test_index", "type1", "1")
client().prepareIndex("first_test_index")
.setId("1")
.setSource("field1", "The quick browse button is a fancy thing, right bro?")
.get();
refresh();
@ -344,7 +347,8 @@ public class HighlighterWithAnalyzersTests extends OpenSearchIntegTestCase {
)
);
// with synonyms
client().prepareIndex("second_test_index", "doc", "0")
client().prepareIndex("second_test_index")
.setId("0")
.setSource(
"type",
"type2",
@ -354,10 +358,11 @@ public class HighlighterWithAnalyzersTests extends OpenSearchIntegTestCase {
"The quick brown fox jumps over the lazy dog"
)
.get();
client().prepareIndex("second_test_index", "doc", "1")
client().prepareIndex("second_test_index")
.setId("1")
.setSource("type", "type2", "field4", "The quick browse button is a fancy thing, right bro?")
.get();
client().prepareIndex("second_test_index", "doc", "2").setSource("type", "type2", "field4", "a quick fast blue car").get();
client().prepareIndex("second_test_index").setId("2").setSource("type", "type2", "field4", "a quick fast blue car").get();
refresh();
source = searchSource().postFilter(termQuery("type", "type2"))

View File

@ -178,7 +178,8 @@ public class IngestRestartIT extends OpenSearchIntegTestCase {
checkPipelineExists.accept(pipelineIdWithoutScript);
checkPipelineExists.accept(pipelineIdWithScript);
client().prepareIndex("index", "doc", "1")
client().prepareIndex("index")
.setId("1")
.setSource("x", 0)
.setPipeline(pipelineIdWithoutScript)
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
@ -186,7 +187,8 @@ public class IngestRestartIT extends OpenSearchIntegTestCase {
IllegalStateException exception = expectThrows(
IllegalStateException.class,
() -> client().prepareIndex("index", "doc", "2")
() -> client().prepareIndex("index")
.setId("2")
.setSource("x", 0)
.setPipeline(pipelineIdWithScript)
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
@ -236,7 +238,8 @@ public class IngestRestartIT extends OpenSearchIntegTestCase {
);
client().admin().cluster().preparePutPipeline("_id", pipeline, XContentType.JSON).get();
client().prepareIndex("index", "doc", "1")
client().prepareIndex("index")
.setId("1")
.setSource("x", 0)
.setPipeline("_id")
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
@ -254,7 +257,8 @@ public class IngestRestartIT extends OpenSearchIntegTestCase {
internalCluster().fullRestart();
ensureYellow("index");
client().prepareIndex("index", "doc", "2")
client().prepareIndex("index")
.setId("2")
.setSource("x", 0)
.setPipeline("_id")
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
@ -275,7 +279,8 @@ public class IngestRestartIT extends OpenSearchIntegTestCase {
);
client().admin().cluster().preparePutPipeline("_id", pipeline, XContentType.JSON).get();
client().prepareIndex("index", "doc", "1")
client().prepareIndex("index")
.setId("1")
.setSource("x", 0)
.setPipeline("_id")
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
@ -288,7 +293,8 @@ public class IngestRestartIT extends OpenSearchIntegTestCase {
logger.info("Stopping");
internalCluster().restartNode(node, new InternalTestCluster.RestartCallback());
client(ingestNode).prepareIndex("index", "doc", "2")
client(ingestNode).prepareIndex("index")
.setId("2")
.setSource("x", 0)
.setPipeline("_id")
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)

View File

@ -100,7 +100,7 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
public void testBasic() throws Exception {
createIndex("test");
ensureGreen("test");
client().prepareIndex("test", "doc", "1").setSource("foo", 4).setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("test").setId("1").setSource("foo", 4).setRefreshPolicy(IMMEDIATE).get();
SearchResponse rsp = buildRequest("doc['foo'] + 1").get();
assertEquals(1, rsp.getHits().getTotalHits().value);
assertEquals(5.0, rsp.getHits().getAt(0).field("foo").getValue(), 0.0D);
@ -109,7 +109,7 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
public void testFunction() throws Exception {
createIndex("test");
ensureGreen("test");
client().prepareIndex("test", "doc", "1").setSource("foo", 4).setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("test").setId("1").setSource("foo", 4).setRefreshPolicy(IMMEDIATE).get();
SearchResponse rsp = buildRequest("doc['foo'] + abs(1)").get();
assertSearchResponse(rsp);
assertEquals(1, rsp.getHits().getTotalHits().value);
@ -119,7 +119,7 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
public void testBasicUsingDotValue() throws Exception {
createIndex("test");
ensureGreen("test");
client().prepareIndex("test", "doc", "1").setSource("foo", 4).setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("test").setId("1").setSource("foo", 4).setRefreshPolicy(IMMEDIATE).get();
SearchResponse rsp = buildRequest("doc['foo'].value + 1").get();
assertEquals(1, rsp.getHits().getTotalHits().value);
assertEquals(5.0, rsp.getHits().getAt(0).field("foo").getValue(), 0.0D);
@ -130,9 +130,9 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
ensureGreen("test");
indexRandom(
true,
client().prepareIndex("test", "doc", "1").setSource("text", "hello goodbye"),
client().prepareIndex("test", "doc", "2").setSource("text", "hello hello hello goodbye"),
client().prepareIndex("test", "doc", "3").setSource("text", "hello hello goodebye")
client().prepareIndex("test").setId("1").setSource("text", "hello goodbye"),
client().prepareIndex("test").setId("2").setSource("text", "hello hello hello goodbye"),
client().prepareIndex("test").setId("3").setSource("text", "hello hello goodebye")
);
ScriptScoreFunctionBuilder score = ScoreFunctionBuilders.scriptFunction(
new Script(ScriptType.INLINE, "expression", "1 / _score", Collections.emptyMap())
@ -162,8 +162,8 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
ensureGreen("test");
indexRandom(
true,
client().prepareIndex("test", "doc", "1").setSource("id", 1, "date0", "2015-04-28T04:02:07Z", "date1", "1985-09-01T23:11:01Z"),
client().prepareIndex("test", "doc", "2").setSource("id", 2, "date0", "2013-12-25T11:56:45Z", "date1", "1983-10-13T23:15:00Z")
client().prepareIndex("test").setId("1").setSource("id", 1, "date0", "2015-04-28T04:02:07Z", "date1", "1985-09-01T23:11:01Z"),
client().prepareIndex("test").setId("2").setSource("id", 2, "date0", "2013-12-25T11:56:45Z", "date1", "1983-10-13T23:15:00Z")
);
SearchResponse rsp = buildRequest("doc['date0'].getSeconds() - doc['date0'].getMinutes()").get();
assertEquals(2, rsp.getHits().getTotalHits().value);
@ -192,8 +192,8 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
ensureGreen("test");
indexRandom(
true,
client().prepareIndex("test", "doc", "1").setSource("id", 1, "date0", "2015-04-28T04:02:07Z", "date1", "1985-09-01T23:11:01Z"),
client().prepareIndex("test", "doc", "2").setSource("id", 2, "date0", "2013-12-25T11:56:45Z", "date1", "1983-10-13T23:15:00Z")
client().prepareIndex("test").setId("1").setSource("id", 1, "date0", "2015-04-28T04:02:07Z", "date1", "1985-09-01T23:11:01Z"),
client().prepareIndex("test").setId("2").setSource("id", 2, "date0", "2013-12-25T11:56:45Z", "date1", "1983-10-13T23:15:00Z")
);
SearchResponse rsp = buildRequest("doc['date0'].date.secondOfMinute - doc['date0'].date.minuteOfHour").get();
assertEquals(2, rsp.getHits().getTotalHits().value);
@ -241,9 +241,9 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
indexRandom(
true,
client().prepareIndex("test", "doc", "1").setSource(doc1),
client().prepareIndex("test", "doc", "2").setSource(doc2),
client().prepareIndex("test", "doc", "3").setSource(doc3)
client().prepareIndex("test").setId("1").setSource(doc1),
client().prepareIndex("test").setId("2").setSource(doc2),
client().prepareIndex("test").setId("3").setSource(doc3)
);
SearchResponse rsp = buildRequest("doc['double0'].count() + doc['double1'].count()").get();
@ -324,7 +324,7 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
public void testInvalidDateMethodCall() throws Exception {
OpenSearchAssertions.assertAcked(prepareCreate("test").addMapping("doc", "double", "type=double"));
ensureGreen("test");
indexRandom(true, client().prepareIndex("test", "doc", "1").setSource("double", "178000000.0"));
indexRandom(true, client().prepareIndex("test").setId("1").setSource("double", "178000000.0"));
try {
buildRequest("doc['double'].getYear()").get();
fail();
@ -347,8 +347,8 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
ensureGreen("test");
indexRandom(
true,
client().prepareIndex("test", "doc", "1").setSource("id", 1, "x", 4),
client().prepareIndex("test", "doc", "2").setSource("id", 2, "y", 2)
client().prepareIndex("test").setId("1").setSource("id", 1, "x", 4),
client().prepareIndex("test").setId("2").setSource("id", 2, "y", 2)
);
SearchResponse rsp = buildRequest("doc['x'] + 1").get();
OpenSearchAssertions.assertSearchResponse(rsp);
@ -361,7 +361,7 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
public void testMissingField() throws Exception {
createIndex("test");
ensureGreen("test");
client().prepareIndex("test", "doc", "1").setSource("x", 4).setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("test").setId("1").setSource("x", 4).setRefreshPolicy(IMMEDIATE).get();
try {
buildRequest("doc['bogus']").get();
fail("Expected missing field to cause failure");
@ -380,9 +380,9 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
ensureGreen("test");
indexRandom(
true,
client().prepareIndex("test", "doc", "1").setSource("id", 1, "x", 10),
client().prepareIndex("test", "doc", "2").setSource("id", 2, "x", 3),
client().prepareIndex("test", "doc", "3").setSource("id", 3, "x", 5)
client().prepareIndex("test").setId("1").setSource("id", 1, "x", 10),
client().prepareIndex("test").setId("2").setSource("id", 2, "x", 3),
client().prepareIndex("test").setId("3").setSource("id", 3, "x", 5)
);
// a = int, b = double, c = long
String script = "doc['x'] * a + b + ((c + doc['x']) > 5000000009 ? 1 : 0)";
@ -395,7 +395,7 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
}
public void testCompileFailure() {
client().prepareIndex("test", "doc", "1").setSource("x", 1).setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("test").setId("1").setSource("x", 1).setRefreshPolicy(IMMEDIATE).get();
try {
buildRequest("garbage%@#%@").get();
fail("Expected expression compilation failure");
@ -406,7 +406,7 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
}
public void testNonNumericParam() {
client().prepareIndex("test", "doc", "1").setSource("x", 1).setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("test").setId("1").setSource("x", 1).setRefreshPolicy(IMMEDIATE).get();
try {
buildRequest("a", "a", "astring").get();
fail("Expected string parameter to cause failure");
@ -421,7 +421,7 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
}
public void testNonNumericField() {
client().prepareIndex("test", "doc", "1").setSource("text", "this is not a number").setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("test").setId("1").setSource("text", "this is not a number").setRefreshPolicy(IMMEDIATE).get();
try {
buildRequest("doc['text.keyword']").get();
fail("Expected text field to cause execution failure");
@ -436,7 +436,7 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
}
public void testInvalidGlobalVariable() {
client().prepareIndex("test", "doc", "1").setSource("foo", 5).setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("test").setId("1").setSource("foo", 5).setRefreshPolicy(IMMEDIATE).get();
try {
buildRequest("bogus").get();
fail("Expected bogus variable to cause execution failure");
@ -451,7 +451,7 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
}
public void testDocWithoutField() {
client().prepareIndex("test", "doc", "1").setSource("foo", 5).setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("test").setId("1").setSource("foo", 5).setRefreshPolicy(IMMEDIATE).get();
try {
buildRequest("doc").get();
fail("Expected doc variable without field to cause execution failure");
@ -466,7 +466,7 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
}
public void testInvalidFieldMember() {
client().prepareIndex("test", "doc", "1").setSource("foo", 5).setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("test").setId("1").setSource("foo", 5).setRefreshPolicy(IMMEDIATE).get();
try {
buildRequest("doc['foo'].bogus").get();
fail("Expected bogus field member to cause execution failure");
@ -486,9 +486,9 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
ensureGreen("test");
indexRandom(
true,
client().prepareIndex("test", "doc", "1").setSource("x", 5, "y", 1.2),
client().prepareIndex("test", "doc", "2").setSource("x", 10, "y", 1.4),
client().prepareIndex("test", "doc", "3").setSource("x", 13, "y", 1.8)
client().prepareIndex("test").setId("1").setSource("x", 5, "y", 1.2),
client().prepareIndex("test").setId("2").setSource("x", 10, "y", 1.4),
client().prepareIndex("test").setId("3").setSource("x", 13, "y", 1.8)
);
SearchRequestBuilder req = client().prepareSearch().setIndices("test");
@ -532,9 +532,9 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
ensureGreen("test");
indexRandom(
true,
client().prepareIndex("test", "doc", "1").setSource("text", "hello"),
client().prepareIndex("test", "doc", "2").setSource("text", "goodbye"),
client().prepareIndex("test", "doc", "3").setSource("text", "hello")
client().prepareIndex("test").setId("1").setSource("text", "hello"),
client().prepareIndex("test").setId("2").setSource("text", "goodbye"),
client().prepareIndex("test").setId("3").setSource("text", "hello")
);
SearchRequestBuilder req = client().prepareSearch().setIndices("test");
@ -564,7 +564,7 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
try {
createIndex("test_index");
ensureGreen("test_index");
indexRandom(true, client().prepareIndex("test_index", "doc", "1").setSource("text_field", "text"));
indexRandom(true, client().prepareIndex("test_index").setId("1").setSource("text_field", "text"));
UpdateRequestBuilder urb = client().prepareUpdate().setIndex("test_index");
urb.setId("1");
urb.setScript(new Script(ScriptType.INLINE, ExpressionScriptEngine.NAME, "0", Collections.emptyMap()));
@ -584,11 +584,11 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
ensureGreen("agg_index");
indexRandom(
true,
client().prepareIndex("agg_index", "doc", "1").setSource("one", 1.0, "two", 2.0, "three", 3.0, "four", 4.0),
client().prepareIndex("agg_index", "doc", "2").setSource("one", 2.0, "two", 2.0, "three", 3.0, "four", 4.0),
client().prepareIndex("agg_index", "doc", "3").setSource("one", 3.0, "two", 2.0, "three", 3.0, "four", 4.0),
client().prepareIndex("agg_index", "doc", "4").setSource("one", 4.0, "two", 2.0, "three", 3.0, "four", 4.0),
client().prepareIndex("agg_index", "doc", "5").setSource("one", 5.0, "two", 2.0, "three", 3.0, "four", 4.0)
client().prepareIndex("agg_index").setId("1").setSource("one", 1.0, "two", 2.0, "three", 3.0, "four", 4.0),
client().prepareIndex("agg_index").setId("2").setSource("one", 2.0, "two", 2.0, "three", 3.0, "four", 4.0),
client().prepareIndex("agg_index").setId("3").setSource("one", 3.0, "two", 2.0, "three", 3.0, "four", 4.0),
client().prepareIndex("agg_index").setId("4").setSource("one", 4.0, "two", 2.0, "three", 3.0, "four", 4.0),
client().prepareIndex("agg_index").setId("5").setSource("one", 5.0, "two", 2.0, "three", 3.0, "four", 4.0)
);
SearchResponse response = client().prepareSearch("agg_index")
.addAggregation(
@ -648,7 +648,8 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
xContentBuilder.endObject().endObject().endObject().endObject();
assertAcked(prepareCreate("test").addMapping("type1", xContentBuilder));
ensureGreen();
client().prepareIndex("test", "type1", "1")
client().prepareIndex("test")
.setId("1")
.setSource(
jsonBuilder().startObject()
.field("name", "test")
@ -695,9 +696,9 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
ensureGreen();
indexRandom(
true,
client().prepareIndex("test", "doc", "1").setSource("id", 1, "price", 1.0, "vip", true),
client().prepareIndex("test", "doc", "2").setSource("id", 2, "price", 2.0, "vip", false),
client().prepareIndex("test", "doc", "3").setSource("id", 3, "price", 2.0, "vip", false)
client().prepareIndex("test").setId("1").setSource("id", 1, "price", 1.0, "vip", true),
client().prepareIndex("test").setId("2").setSource("id", 2, "price", 2.0, "vip", false),
client().prepareIndex("test").setId("3").setSource("id", 3, "price", 2.0, "vip", false)
);
// access .value
SearchResponse rsp = buildRequest("doc['vip'].value").get();
@ -728,8 +729,8 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
ensureGreen("test");
indexRandom(
true,
client().prepareIndex("test", "doc", "1").setSource("id", 1, "foo", 1.0),
client().prepareIndex("test", "doc", "2").setSource("id", 2, "foo", 0.0)
client().prepareIndex("test").setId("1").setSource("id", 1, "foo", 1.0),
client().prepareIndex("test").setId("2").setSource("id", 2, "foo", 0.0)
);
SearchRequestBuilder builder = buildRequest("doc['foo'].value");
Script script = new Script(ScriptType.INLINE, "expression", "doc['foo'].value", Collections.emptyMap());

View File

@ -69,7 +69,7 @@ public class StoredExpressionIT extends OpenSearchIntegTestCase {
.setId("script1")
.setContent(new BytesArray("{\"script\": {\"lang\": \"expression\", \"source\": \"2\"} }"), XContentType.JSON)
.get();
client().prepareIndex("test", "scriptTest", "1").setSource("{\"theField\":\"foo\"}", XContentType.JSON).get();
client().prepareIndex("test").setId("1").setSource("{\"theField\":\"foo\"}", XContentType.JSON).get();
try {
client().prepareUpdate("test", "1").setScript(new Script(ScriptType.STORED, null, "script1", Collections.emptyMap())).get();
fail("update script should have been rejected");

View File

@ -66,7 +66,8 @@ public class MultiSearchTemplateIT extends OpenSearchIntegTestCase {
final int numDocs = randomIntBetween(10, 100);
IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[numDocs];
for (int i = 0; i < numDocs; i++) {
indexRequestBuilders[i] = client().prepareIndex("msearch", "test", String.valueOf(i))
indexRequestBuilders[i] = client().prepareIndex("msearch")
.setId(String.valueOf(i))
.setSource("odd", (i % 2 == 0), "group", (i % 3));
}
indexRandom(true, indexRequestBuilders);

View File

@ -68,8 +68,8 @@ public class SearchTemplateIT extends OpenSearchSingleNodeTestCase {
@Before
public void setup() throws IOException {
createIndex("test");
client().prepareIndex("test", "type", "1").setSource(jsonBuilder().startObject().field("text", "value1").endObject()).get();
client().prepareIndex("test", "type", "2").setSource(jsonBuilder().startObject().field("text", "value2").endObject()).get();
client().prepareIndex("test").setId("1").setSource(jsonBuilder().startObject().field("text", "value1").endObject()).get();
client().prepareIndex("test").setId("2").setSource(jsonBuilder().startObject().field("text", "value2").endObject()).get();
client().admin().indices().prepareRefresh().get();
}
@ -185,11 +185,11 @@ public class SearchTemplateIT extends OpenSearchSingleNodeTestCase {
assertNotNull(getResponse.getSource());
BulkRequestBuilder bulkRequestBuilder = client().prepareBulk();
bulkRequestBuilder.add(client().prepareIndex("test", "type", "1").setSource("{\"theField\":\"foo\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test", "type", "2").setSource("{\"theField\":\"foo 2\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test", "type", "3").setSource("{\"theField\":\"foo 3\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test", "type", "4").setSource("{\"theField\":\"foo 4\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test", "type", "5").setSource("{\"theField\":\"bar\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test").setId("1").setSource("{\"theField\":\"foo\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test").setId("2").setSource("{\"theField\":\"foo 2\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test").setId("3").setSource("{\"theField\":\"foo 3\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test").setId("4").setSource("{\"theField\":\"foo 4\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test").setId("5").setSource("{\"theField\":\"bar\"}", XContentType.JSON));
bulkRequestBuilder.get();
client().admin().indices().prepareRefresh().get();
@ -229,11 +229,11 @@ public class SearchTemplateIT extends OpenSearchSingleNodeTestCase {
assertAcked(client().admin().cluster().preparePutStoredScript().setId("3").setContent(new BytesArray(script), XContentType.JSON));
BulkRequestBuilder bulkRequestBuilder = client().prepareBulk();
bulkRequestBuilder.add(client().prepareIndex("test", "type", "1").setSource("{\"theField\":\"foo\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test", "type", "2").setSource("{\"theField\":\"foo 2\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test", "type", "3").setSource("{\"theField\":\"foo 3\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test", "type", "4").setSource("{\"theField\":\"foo 4\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test", "type", "5").setSource("{\"theField\":\"bar\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test").setId("1").setSource("{\"theField\":\"foo\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test").setId("2").setSource("{\"theField\":\"foo 2\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test").setId("3").setSource("{\"theField\":\"foo 3\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test").setId("4").setSource("{\"theField\":\"foo 4\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test").setId("5").setSource("{\"theField\":\"bar\"}", XContentType.JSON));
bulkRequestBuilder.get();
client().admin().indices().prepareRefresh().get();
@ -270,9 +270,7 @@ public class SearchTemplateIT extends OpenSearchSingleNodeTestCase {
createIndex("testindex");
ensureGreen("testindex");
client().prepareIndex("testindex", "test", "1")
.setSource(jsonBuilder().startObject().field("searchtext", "dev1").endObject())
.get();
client().prepareIndex("testindex").setId("1").setSource(jsonBuilder().startObject().field("searchtext", "dev1").endObject()).get();
client().admin().indices().prepareRefresh().get();
int iterations = randomIntBetween(2, 11);
@ -354,11 +352,11 @@ public class SearchTemplateIT extends OpenSearchSingleNodeTestCase {
client().admin().cluster().preparePutStoredScript().setId("4").setContent(new BytesArray(multiQuery), XContentType.JSON)
);
BulkRequestBuilder bulkRequestBuilder = client().prepareBulk();
bulkRequestBuilder.add(client().prepareIndex("test", "type", "1").setSource("{\"theField\":\"foo\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test", "type", "2").setSource("{\"theField\":\"foo 2\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test", "type", "3").setSource("{\"theField\":\"foo 3\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test", "type", "4").setSource("{\"theField\":\"foo 4\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test", "type", "5").setSource("{\"theField\":\"bar\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test").setId("1").setSource("{\"theField\":\"foo\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test").setId("2").setSource("{\"theField\":\"foo 2\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test").setId("3").setSource("{\"theField\":\"foo 3\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test").setId("4").setSource("{\"theField\":\"foo 4\"}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("test").setId("5").setSource("{\"theField\":\"bar\"}", XContentType.JSON));
bulkRequestBuilder.get();
client().admin().indices().prepareRefresh().get();

View File

@ -187,7 +187,7 @@ public class TokenCountFieldMapperIntegrationIT extends OpenSearchIntegTestCase
}
private IndexRequestBuilder prepareIndex(String id, String... texts) throws IOException {
return client().prepareIndex("test", "test", id).setSource("foo", texts);
return client().prepareIndex("test").setId(id).setSource("foo", texts);
}
private SearchResponse searchById(String id) {

View File

@ -58,8 +58,8 @@ public class BWCTemplateTests extends OpenSearchSingleNodeTestCase {
client().admin().indices().preparePutTemplate("packetbeat").setSource(packetBeat, XContentType.JSON).get();
client().admin().indices().preparePutTemplate("filebeat").setSource(fileBeat, XContentType.JSON).get();
client().prepareIndex("metricbeat-foo", "doc", "1").setSource("message", "foo").get();
client().prepareIndex("packetbeat-foo", "doc", "1").setSource("message", "foo").get();
client().prepareIndex("filebeat-foo", "doc", "1").setSource("message", "foo").get();
client().prepareIndex("metricbeat-foo").setId("1").setSource("message", "foo").get();
client().prepareIndex("packetbeat-foo").setId("1").setSource("message", "foo").get();
client().prepareIndex("filebeat-foo").setId("1").setSource("message", "foo").get();
}
}

View File

@ -534,7 +534,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
createIndexRequest("test", "parent", "1", null, "p_field", 1).get();
createIndexRequest("test", "child", "2", "1", "c_field", 1).get();
client().prepareIndex("test", "doc", "3").setSource("p_field", 1).get();
client().prepareIndex("test").setId("3").setSource("p_field", 1).get();
refresh();
SearchResponse searchResponse = client().prepareSearch("test")
@ -801,7 +801,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
createIndexRequest("test", "child", "2", "1", "c_field", 1).get();
client().admin().indices().prepareFlush("test").get();
client().prepareIndex("test", "doc", "3").setSource("p_field", 2).get();
client().prepareIndex("test").setId("3").setSource("p_field", 2).get();
refresh();
SearchResponse searchResponse = client().prepareSearch("test")
@ -1326,7 +1326,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
ensureGreen();
String parentId = "p1";
client().prepareIndex("test", "doc", parentId).setSource("p_field", "1").get();
client().prepareIndex("test").setId(parentId).setSource("p_field", "1").get();
refresh();
try {

View File

@ -644,7 +644,7 @@ public class InnerHitsIT extends ParentChildTestCase {
assertAcked(prepareCreate("index2"));
createIndexRequest("index1", "parent_type", "1", null, "nested_type", Collections.singletonMap("key", "value")).get();
createIndexRequest("index1", "child_type", "2", "1").get();
client().prepareIndex("index2", "type", "3").setSource("key", "value").get();
client().prepareIndex("index2").setId("3").setSource("key", "value").get();
refresh();
SearchResponse response = client().prepareSearch("index1", "index2")

View File

@ -129,7 +129,7 @@ public abstract class ParentChildTestCase extends OpenSearchIntegTestCase {
String name = type;
type = "doc";
IndexRequestBuilder indexRequestBuilder = client().prepareIndex(index, type, id);
IndexRequestBuilder indexRequestBuilder = client().prepareIndex(index).setId(id);
Map<String, Object> joinField = new HashMap<>();
if (parentId != null) {
joinField.put("name", name);

View File

@ -104,13 +104,16 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
.addMapping("type", "id", "type=keyword", "field1", "type=keyword", "field2", "type=keyword", "query", "type=percolator")
);
client().prepareIndex("test", "type", "1")
client().prepareIndex("test")
.setId("1")
.setSource(jsonBuilder().startObject().field("id", "1").field("query", matchAllQuery()).endObject())
.get();
client().prepareIndex("test", "type", "2")
client().prepareIndex("test")
.setId("2")
.setSource(jsonBuilder().startObject().field("id", "2").field("query", matchQuery("field1", "value")).endObject())
.get();
client().prepareIndex("test", "type", "3")
client().prepareIndex("test")
.setId("3")
.setSource(
jsonBuilder().startObject()
.field("id", "3")
@ -195,13 +198,16 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
)
);
client().prepareIndex("test", "type", "1")
client().prepareIndex("test")
.setId("1")
.setSource(jsonBuilder().startObject().field("query", rangeQuery("field1").from(10).to(12)).endObject())
.get();
client().prepareIndex("test", "type", "2")
client().prepareIndex("test")
.setId("2")
.setSource(jsonBuilder().startObject().field("query", rangeQuery("field1").from(20).to(22)).endObject())
.get();
client().prepareIndex("test", "type", "3")
client().prepareIndex("test")
.setId("3")
.setSource(
jsonBuilder().startObject()
.field("query", boolQuery().must(rangeQuery("field1").from(10).to(12)).must(rangeQuery("field1").from(12).to(14)))
@ -209,13 +215,16 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
)
.get();
client().admin().indices().prepareRefresh().get();
client().prepareIndex("test", "type", "4")
client().prepareIndex("test")
.setId("4")
.setSource(jsonBuilder().startObject().field("query", rangeQuery("field2").from(10).to(12)).endObject())
.get();
client().prepareIndex("test", "type", "5")
client().prepareIndex("test")
.setId("5")
.setSource(jsonBuilder().startObject().field("query", rangeQuery("field2").from(20).to(22)).endObject())
.get();
client().prepareIndex("test", "type", "6")
client().prepareIndex("test")
.setId("6")
.setSource(
jsonBuilder().startObject()
.field("query", boolQuery().must(rangeQuery("field2").from(10).to(12)).must(rangeQuery("field2").from(12).to(14)))
@ -223,13 +232,16 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
)
.get();
client().admin().indices().prepareRefresh().get();
client().prepareIndex("test", "type", "7")
client().prepareIndex("test")
.setId("7")
.setSource(jsonBuilder().startObject().field("query", rangeQuery("field3").from("192.168.1.0").to("192.168.1.5")).endObject())
.get();
client().prepareIndex("test", "type", "8")
client().prepareIndex("test")
.setId("8")
.setSource(jsonBuilder().startObject().field("query", rangeQuery("field3").from("192.168.1.20").to("192.168.1.30")).endObject())
.get();
client().prepareIndex("test", "type", "9")
client().prepareIndex("test")
.setId("9")
.setSource(
jsonBuilder().startObject()
.field(
@ -240,7 +252,8 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
.endObject()
)
.get();
client().prepareIndex("test", "type", "10")
client().prepareIndex("test")
.setId("10")
.setSource(
jsonBuilder().startObject()
.field(
@ -315,7 +328,8 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
)
);
client().prepareIndex("test", "type", "1")
client().prepareIndex("test")
.setId("1")
.setSource(
jsonBuilder().startObject()
.field("query", geoDistanceQuery("field1").point(52.18, 4.38).distance(50, DistanceUnit.KILOMETERS))
@ -324,7 +338,8 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
)
.get();
client().prepareIndex("test", "type", "2")
client().prepareIndex("test")
.setId("2")
.setSource(
jsonBuilder().startObject()
.field("query", geoBoundingBoxQuery("field1").setCorners(52.3, 4.4, 52.1, 4.6))
@ -333,7 +348,8 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
)
.get();
client().prepareIndex("test", "type", "3")
client().prepareIndex("test")
.setId("3")
.setSource(
jsonBuilder().startObject()
.field(
@ -367,13 +383,16 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
.addMapping("type", "id", "type=keyword", "field1", "type=keyword", "field2", "type=keyword", "query", "type=percolator")
);
client().prepareIndex("test", "type", "1")
client().prepareIndex("test")
.setId("1")
.setSource(jsonBuilder().startObject().field("id", "1").field("query", matchAllQuery()).endObject())
.get();
client().prepareIndex("test", "type", "2")
client().prepareIndex("test")
.setId("2")
.setSource(jsonBuilder().startObject().field("id", "2").field("query", matchQuery("field1", "value")).endObject())
.get();
client().prepareIndex("test", "type", "3")
client().prepareIndex("test")
.setId("3")
.setSource(
jsonBuilder().startObject()
.field("id", "3")
@ -382,9 +401,9 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
)
.get();
client().prepareIndex("test", "type", "4").setSource("{\"id\": \"4\"}", XContentType.JSON).get();
client().prepareIndex("test", "type", "5").setSource(XContentType.JSON, "id", "5", "field1", "value").get();
client().prepareIndex("test", "type", "6").setSource(XContentType.JSON, "id", "6", "field1", "value", "field2", "value").get();
client().prepareIndex("test").setId("4").setSource("{\"id\": \"4\"}", XContentType.JSON).get();
client().prepareIndex("test").setId("5").setSource(XContentType.JSON, "id", "5", "field1", "value").get();
client().prepareIndex("test").setId("6").setSource(XContentType.JSON, "id", "6", "field1", "value", "field2", "value").get();
client().admin().indices().prepareRefresh().get();
logger.info("percolating empty doc");
@ -422,9 +441,9 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
.addMapping("type", "_source", "enabled=false", "field1", "type=keyword", "query", "type=percolator")
);
client().prepareIndex("test", "type", "1").setSource(jsonBuilder().startObject().field("query", matchAllQuery()).endObject()).get();
client().prepareIndex("test").setId("1").setSource(jsonBuilder().startObject().field("query", matchAllQuery()).endObject()).get();
client().prepareIndex("test", "type", "2").setSource("{}", XContentType.JSON).get();
client().prepareIndex("test").setId("2").setSource("{}", XContentType.JSON).get();
client().admin().indices().prepareRefresh().get();
logger.info("percolating empty doc with source disabled");
@ -443,10 +462,12 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
.addMapping("type", "id", "type=keyword", "field1", "type=text", "field2", "type=text", "query", "type=percolator")
);
client().prepareIndex("test", "type", "1")
client().prepareIndex("test")
.setId("1")
.setSource(jsonBuilder().startObject().field("id", 1).field("query", commonTermsQuery("field1", "quick brown fox")).endObject())
.get();
client().prepareIndex("test", "type", "2")
client().prepareIndex("test")
.setId("2")
.setSource(
jsonBuilder().startObject()
.field("id", 2)
@ -454,7 +475,8 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
.endObject()
)
.get();
client().prepareIndex("test", "type", "3")
client().prepareIndex("test")
.setId("3")
.setSource(
jsonBuilder().startObject()
.field("id", 3)
@ -469,7 +491,8 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
.get();
client().admin().indices().prepareRefresh().get();
client().prepareIndex("test", "type", "4")
client().prepareIndex("test")
.setId("4")
.setSource(
jsonBuilder().startObject()
.field("id", 4)
@ -489,7 +512,8 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
.get();
// doesn't match
client().prepareIndex("test", "type", "5")
client().prepareIndex("test")
.setId("5")
.setSource(
jsonBuilder().startObject()
.field("id", 5)
@ -543,23 +567,28 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
.prepareCreate("test")
.addMapping("type", "id", "type=keyword", "field1", fieldMapping, "query", "type=percolator")
);
client().prepareIndex("test", "type", "1")
client().prepareIndex("test")
.setId("1")
.setSource(jsonBuilder().startObject().field("id", "1").field("query", matchQuery("field1", "brown fox")).endObject())
.execute()
.actionGet();
client().prepareIndex("test", "type", "2")
client().prepareIndex("test")
.setId("2")
.setSource(jsonBuilder().startObject().field("id", "2").field("query", matchQuery("field1", "lazy dog")).endObject())
.execute()
.actionGet();
client().prepareIndex("test", "type", "3")
client().prepareIndex("test")
.setId("3")
.setSource(jsonBuilder().startObject().field("id", "3").field("query", termQuery("field1", "jumps")).endObject())
.execute()
.actionGet();
client().prepareIndex("test", "type", "4")
client().prepareIndex("test")
.setId("4")
.setSource(jsonBuilder().startObject().field("id", "4").field("query", termQuery("field1", "dog")).endObject())
.execute()
.actionGet();
client().prepareIndex("test", "type", "5")
client().prepareIndex("test")
.setId("5")
.setSource(jsonBuilder().startObject().field("id", "5").field("query", termQuery("field1", "fox")).endObject())
.execute()
.actionGet();
@ -783,10 +812,12 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
.prepareCreate("test")
.addMapping("type", "field", "type=text,position_increment_gap=5", "query", "type=percolator")
);
client().prepareIndex("test", "type", "1")
client().prepareIndex("test")
.setId("1")
.setSource(jsonBuilder().startObject().field("query", new MatchPhraseQueryBuilder("field", "brown fox").slop(4)).endObject())
.get();
client().prepareIndex("test", "type", "2")
client().prepareIndex("test")
.setId("2")
.setSource(jsonBuilder().startObject().field("query", new MatchPhraseQueryBuilder("field", "brown fox").slop(5)).endObject())
.get();
client().admin().indices().prepareRefresh().get();
@ -868,10 +899,12 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
);
// Acceptable:
client().prepareIndex("test1", "type", "1")
client().prepareIndex("test1")
.setId("1")
.setSource(jsonBuilder().startObject().field(queryFieldName, matchQuery("field", "value")).endObject())
.get();
client().prepareIndex("test2", "type", "1")
client().prepareIndex("test2")
.setId("1")
.setSource(
jsonBuilder().startObject()
.startObject("object_field")
@ -901,7 +934,8 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
// Unacceptable:
MapperParsingException e = expectThrows(MapperParsingException.class, () -> {
client().prepareIndex("test2", "type", "1")
client().prepareIndex("test2")
.setId("1")
.setSource(
jsonBuilder().startObject()
.startArray("object_field")
@ -944,7 +978,8 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
.endObject()
.endObject();
assertAcked(client().admin().indices().prepareCreate("test").addMapping("employee", mapping));
client().prepareIndex("test", "employee", "q1")
client().prepareIndex("test")
.setId("q1")
.setSource(
jsonBuilder().startObject()
.field("id", "q1")
@ -960,7 +995,8 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
)
.get();
// this query should never match as it doesn't use nested query:
client().prepareIndex("test", "employee", "q2")
client().prepareIndex("test")
.setId("q2")
.setSource(
jsonBuilder().startObject()
.field("id", "q2")
@ -970,7 +1006,8 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
.get();
client().admin().indices().prepareRefresh().get();
client().prepareIndex("test", "employee", "q3")
client().prepareIndex("test")
.setId("q3")
.setSource(jsonBuilder().startObject().field("id", "q3").field("query", QueryBuilders.matchAllQuery()).endObject())
.get();
client().admin().indices().prepareRefresh().get();
@ -1101,15 +1138,18 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
public void testPercolatorQueryViaMultiSearch() throws Exception {
assertAcked(client().admin().indices().prepareCreate("test").addMapping("type", "field1", "type=text", "query", "type=percolator"));
client().prepareIndex("test", "type", "1")
client().prepareIndex("test")
.setId("1")
.setSource(jsonBuilder().startObject().field("query", matchQuery("field1", "b")).field("a", "b").endObject())
.execute()
.actionGet();
client().prepareIndex("test", "type", "2")
client().prepareIndex("test")
.setId("2")
.setSource(jsonBuilder().startObject().field("query", matchQuery("field1", "c")).endObject())
.execute()
.actionGet();
client().prepareIndex("test", "type", "3")
client().prepareIndex("test")
.setId("3")
.setSource(
jsonBuilder().startObject()
.field("query", boolQuery().must(matchQuery("field1", "b")).must(matchQuery("field1", "c")))
@ -1117,11 +1157,13 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
)
.execute()
.actionGet();
client().prepareIndex("test", "type", "4")
client().prepareIndex("test")
.setId("4")
.setSource(jsonBuilder().startObject().field("query", matchAllQuery()).endObject())
.execute()
.actionGet();
client().prepareIndex("test", "type", "5")
client().prepareIndex("test")
.setId("5")
.setSource(jsonBuilder().startObject().field("field1", "c").endObject())
.execute()
.actionGet();

View File

@ -634,7 +634,7 @@ public class PercolatorFieldMapperTests extends OpenSearchSingleNodeTestCase {
public void testQueryWithRewrite() throws Exception {
addQueryFieldMappings();
client().prepareIndex("remote", "doc", "1").setSource("field", "value").get();
client().prepareIndex("remote").setId("1").setSource("field", "value").get();
QueryBuilder queryBuilder = termsLookupQuery("field", new TermsLookup("remote", "1", "field"));
ParsedDocument doc = mapperService.documentMapper("doc")
.parse(

View File

@ -97,7 +97,8 @@ public class PercolatorQuerySearchTests extends OpenSearchSingleNodeTestCase {
public void testPercolateScriptQuery() throws IOException {
client().admin().indices().prepareCreate("index").addMapping("type", "query", "type=percolator").get();
client().prepareIndex("index", "type", "1")
client().prepareIndex("index")
.setId("1")
.setSource(
jsonBuilder().startObject()
.field(
@ -151,7 +152,8 @@ public class PercolatorQuerySearchTests extends OpenSearchSingleNodeTestCase {
.setSettings(Settings.builder().put(BitsetFilterCache.INDEX_LOAD_RANDOM_ACCESS_FILTERS_EAGERLY_SETTING.getKey(), false))
.addMapping("employee", mapping)
);
client().prepareIndex("test", "employee", "q1")
client().prepareIndex("test")
.setId("q1")
.setSource(
jsonBuilder().startObject()
.field(
@ -238,7 +240,8 @@ public class PercolatorQuerySearchTests extends OpenSearchSingleNodeTestCase {
mapping.endObject();
createIndex("test", client().admin().indices().prepareCreate("test").addMapping("employee", mapping));
Script script = new Script(ScriptType.INLINE, MockScriptPlugin.NAME, "use_fielddata_please", Collections.emptyMap());
client().prepareIndex("test", "employee", "q1")
client().prepareIndex("test")
.setId("q1")
.setSource(
jsonBuilder().startObject()
.field("query", QueryBuilders.nestedQuery("employees", QueryBuilders.scriptQuery(script), ScoreMode.Avg))
@ -279,7 +282,8 @@ public class PercolatorQuerySearchTests extends OpenSearchSingleNodeTestCase {
public void testMapUnmappedFieldAsText() throws IOException {
Settings.Builder settings = Settings.builder().put("index.percolator.map_unmapped_fields_as_text", true);
createIndex("test", settings.build(), "query", "query", "type=percolator");
client().prepareIndex("test", "query", "1")
client().prepareIndex("test")
.setId("1")
.setSource(jsonBuilder().startObject().field("query", matchQuery("field1", "value")).endObject())
.get();
client().admin().indices().prepareRefresh().get();
@ -310,10 +314,12 @@ public class PercolatorQuerySearchTests extends OpenSearchSingleNodeTestCase {
"type=percolator"
);
client().prepareIndex("test", "_doc", "1")
client().prepareIndex("test")
.setId("1")
.setSource(jsonBuilder().startObject().field("query", rangeQuery("field2").from("now-1h").to("now+1h")).endObject())
.get();
client().prepareIndex("test", "_doc", "2")
client().prepareIndex("test")
.setId("2")
.setSource(
jsonBuilder().startObject()
.field(
@ -325,7 +331,8 @@ public class PercolatorQuerySearchTests extends OpenSearchSingleNodeTestCase {
.get();
Script script = new Script(ScriptType.INLINE, MockScriptPlugin.NAME, "1==1", Collections.emptyMap());
client().prepareIndex("test", "_doc", "3")
client().prepareIndex("test")
.setId("3")
.setSource(
jsonBuilder().startObject()
.field("query", boolQuery().filter(scriptQuery(script)).filter(rangeQuery("field2").from("now-1h").to("now+1h")))

View File

@ -302,7 +302,7 @@ public class ReindexDocumentationIT extends OpenSearchIntegTestCase {
false,
true,
IntStream.range(0, numDocs)
.mapToObj(i -> client().prepareIndex(INDEX_NAME, "_doc", Integer.toString(i)).setSource("n", Integer.toString(i)))
.mapToObj(i -> client().prepareIndex(INDEX_NAME).setId(Integer.toString(i)).setSource("n", Integer.toString(i)))
.collect(Collectors.toList())
);

View File

@ -74,13 +74,13 @@ public class DeleteByQueryBasicTests extends ReindexTestCase {
public void testBasics() throws Exception {
indexRandom(
true,
client().prepareIndex("test", "test", "1").setSource("foo", "a"),
client().prepareIndex("test", "test", "2").setSource("foo", "a"),
client().prepareIndex("test", "test", "3").setSource("foo", "b"),
client().prepareIndex("test", "test", "4").setSource("foo", "c"),
client().prepareIndex("test", "test", "5").setSource("foo", "d"),
client().prepareIndex("test", "test", "6").setSource("foo", "e"),
client().prepareIndex("test", "test", "7").setSource("foo", "f")
client().prepareIndex("test").setId("1").setSource("foo", "a"),
client().prepareIndex("test").setId("2").setSource("foo", "a"),
client().prepareIndex("test").setId("3").setSource("foo", "b"),
client().prepareIndex("test").setId("4").setSource("foo", "c"),
client().prepareIndex("test").setId("5").setSource("foo", "d"),
client().prepareIndex("test").setId("6").setSource("foo", "e"),
client().prepareIndex("test").setId("7").setSource("foo", "f")
);
assertHitCount(client().prepareSearch("test").setSize(0).get(), 7);
@ -109,7 +109,7 @@ public class DeleteByQueryBasicTests extends ReindexTestCase {
List<IndexRequestBuilder> builders = new ArrayList<>();
for (int i = 0; i < docs; i++) {
builders.add(client().prepareIndex("test", "doc", String.valueOf(i)).setSource("fields1", 1));
builders.add(client().prepareIndex("test").setId(String.valueOf(i)).setSource("fields1", 1));
}
indexRandom(true, true, true, builders);
@ -134,7 +134,7 @@ public class DeleteByQueryBasicTests extends ReindexTestCase {
for (int j = 0; j < docs; j++) {
boolean candidate = (j < candidates[i]);
builders.add(client().prepareIndex("test-" + i, "doc", String.valueOf(j)).setSource("candidate", candidate));
builders.add(client().prepareIndex("test-" + i).setId(String.valueOf(j)).setSource("candidate", candidate));
}
}
indexRandom(true, true, true, builders);
@ -151,7 +151,7 @@ public class DeleteByQueryBasicTests extends ReindexTestCase {
}
public void testDeleteByQueryWithMissingIndex() throws Exception {
indexRandom(true, client().prepareIndex("test", "test", "1").setSource("foo", "a"));
indexRandom(true, client().prepareIndex("test").setId("1").setSource("foo", "a"));
assertHitCount(client().prepareSearch().setSize(0).get(), 1);
try {
@ -171,7 +171,7 @@ public class DeleteByQueryBasicTests extends ReindexTestCase {
List<IndexRequestBuilder> builders = new ArrayList<>();
for (int i = 0; i < docs; i++) {
builders.add(client().prepareIndex("test", "test", String.valueOf(i)).setRouting(String.valueOf(i)).setSource("field1", 1));
builders.add(client().prepareIndex("test").setId(String.valueOf(i)).setRouting(String.valueOf(i)).setSource("field1", 1));
}
indexRandom(true, true, true, builders);
@ -199,7 +199,8 @@ public class DeleteByQueryBasicTests extends ReindexTestCase {
List<IndexRequestBuilder> builders = new ArrayList<>();
for (int i = 0; i < docs; i++) {
builders.add(
client().prepareIndex("test", "test", Integer.toString(i))
client().prepareIndex("test")
.setId(Integer.toString(i))
.setRouting(randomAlphaOfLengthBetween(1, 5))
.setSource("foo", "bar")
);
@ -217,7 +218,7 @@ public class DeleteByQueryBasicTests extends ReindexTestCase {
}
public void testDeleteByQueryWithDateMath() throws Exception {
indexRandom(true, client().prepareIndex("test", "type", "1").setSource("d", "2013-01-01"));
indexRandom(true, client().prepareIndex("test").setId("1").setSource("d", "2013-01-01"));
DeleteByQueryRequestBuilder delete = deleteByQuery().source("test").filter(rangeQuery("d").to("now-1h"));
assertThat(delete.refresh(true).get(), matcher().deleted(1L));
@ -231,7 +232,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", Integer.toString(i)).setSource("field", 1));
builders.add(client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", 1));
}
indexRandom(true, true, true, builders);
@ -311,13 +312,13 @@ public class DeleteByQueryBasicTests extends ReindexTestCase {
public void testSlices() throws Exception {
indexRandom(
true,
client().prepareIndex("test", "test", "1").setSource("foo", "a"),
client().prepareIndex("test", "test", "2").setSource("foo", "a"),
client().prepareIndex("test", "test", "3").setSource("foo", "b"),
client().prepareIndex("test", "test", "4").setSource("foo", "c"),
client().prepareIndex("test", "test", "5").setSource("foo", "d"),
client().prepareIndex("test", "test", "6").setSource("foo", "e"),
client().prepareIndex("test", "test", "7").setSource("foo", "f")
client().prepareIndex("test").setId("1").setSource("foo", "a"),
client().prepareIndex("test").setId("2").setSource("foo", "a"),
client().prepareIndex("test").setId("3").setSource("foo", "b"),
client().prepareIndex("test").setId("4").setSource("foo", "c"),
client().prepareIndex("test").setId("5").setSource("foo", "d"),
client().prepareIndex("test").setId("6").setSource("foo", "e"),
client().prepareIndex("test").setId("7").setSource("foo", "f")
);
assertHitCount(client().prepareSearch("test").setSize(0).get(), 7);
@ -348,7 +349,7 @@ public class DeleteByQueryBasicTests extends ReindexTestCase {
docs.put(indexName, new ArrayList<>());
int numDocs = between(5, 15);
for (int i = 0; i < numDocs; i++) {
docs.get(indexName).add(client().prepareIndex(indexName, "test", Integer.toString(i)).setSource("foo", "a"));
docs.get(indexName).add(client().prepareIndex(indexName).setId(Integer.toString(i)).setSource("foo", "a"));
}
}

View File

@ -96,7 +96,7 @@ public class DeleteByQueryConcurrentTests extends ReindexTestCase {
List<IndexRequestBuilder> builders = new ArrayList<>();
for (int i = 0; i < docs; i++) {
builders.add(client().prepareIndex("test", "doc", String.valueOf(i)).setSource("foo", "bar"));
builders.add(client().prepareIndex("test").setId(String.valueOf(i)).setSource("foo", "bar"));
}
indexRandom(true, true, true, builders);

View File

@ -51,10 +51,10 @@ public class ReindexBasicTests extends ReindexTestCase {
public void testFiltering() throws Exception {
indexRandom(
true,
client().prepareIndex("source", "test", "1").setSource("foo", "a"),
client().prepareIndex("source", "test", "2").setSource("foo", "a"),
client().prepareIndex("source", "test", "3").setSource("foo", "b"),
client().prepareIndex("source", "test", "4").setSource("foo", "c")
client().prepareIndex("source").setId("1").setSource("foo", "a"),
client().prepareIndex("source").setId("2").setSource("foo", "a"),
client().prepareIndex("source").setId("3").setSource("foo", "b"),
client().prepareIndex("source").setId("4").setSource("foo", "c")
);
assertHitCount(client().prepareSearch("source").setSize(0).get(), 4);
@ -84,7 +84,7 @@ public class ReindexBasicTests extends ReindexTestCase {
List<IndexRequestBuilder> docs = new ArrayList<>();
int max = between(150, 500);
for (int i = 0; i < max; i++) {
docs.add(client().prepareIndex("source", "test", Integer.toString(i)).setSource("foo", "a"));
docs.add(client().prepareIndex("source").setId(Integer.toString(i)).setSource("foo", "a"));
}
indexRandom(true, docs);
@ -111,7 +111,7 @@ public class ReindexBasicTests extends ReindexTestCase {
List<IndexRequestBuilder> docs = new ArrayList<>();
int max = between(150, 500);
for (int i = 0; i < max; i++) {
docs.add(client().prepareIndex("source", "test", Integer.toString(i)).setSource("foo", "a"));
docs.add(client().prepareIndex("source").setId(Integer.toString(i)).setSource("foo", "a"));
}
indexRandom(true, docs);
@ -148,7 +148,7 @@ public class ReindexBasicTests extends ReindexTestCase {
docs.put(indexName, new ArrayList<>());
int numDocs = between(50, 200);
for (int i = 0; i < numDocs; i++) {
docs.get(indexName).add(client().prepareIndex(indexName, typeName, "id_" + sourceIndex + "_" + i).setSource("foo", "a"));
docs.get(indexName).add(client().prepareIndex(indexName).setId("id_" + sourceIndex + "_" + i).setSource("foo", "a"));
}
}

View File

@ -56,7 +56,7 @@ public class ReindexFailureTests extends ReindexTestCase {
* Create the destination index such that the copy will cause a mapping
* conflict on every request.
*/
indexRandom(true, client().prepareIndex("dest", "_doc", "test").setSource("test", 10) /* Its a string in the source! */);
indexRandom(true, client().prepareIndex("dest").setId("test").setSource("test", 10) /* Its a string in the source! */);
indexDocs(100);
@ -77,7 +77,7 @@ public class ReindexFailureTests extends ReindexTestCase {
public void testAbortOnVersionConflict() throws Exception {
// Just put something in the way of the copy.
indexRandom(true, client().prepareIndex("dest", "_doc", "1").setSource("test", "test"));
indexRandom(true, client().prepareIndex("dest").setId("1").setSource("test", "test"));
indexDocs(100);
@ -139,7 +139,7 @@ public class ReindexFailureTests extends ReindexTestCase {
private void indexDocs(int count) throws Exception {
List<IndexRequestBuilder> docs = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
docs.add(client().prepareIndex("source", "_doc", Integer.toString(i)).setSource("test", "words words"));
docs.add(client().prepareIndex("source").setId(Integer.toString(i)).setSource("test", "words words"));
}
indexRandom(true, docs);
}

View File

@ -127,7 +127,7 @@ public class ReindexVersioningTests extends ReindexTestCase {
private void setupSourceAbsent() throws Exception {
indexRandom(
true,
client().prepareIndex("source", "_doc", "test").setVersionType(EXTERNAL).setVersion(SOURCE_VERSION).setSource("foo", "source")
client().prepareIndex("source").setId("test").setVersionType(EXTERNAL).setVersion(SOURCE_VERSION).setSource("foo", "source")
);
assertEquals(SOURCE_VERSION, client().prepareGet("source", "test").get().getVersion());
@ -137,7 +137,7 @@ public class ReindexVersioningTests extends ReindexTestCase {
setupSourceAbsent();
indexRandom(
true,
client().prepareIndex("dest", "_doc", "test").setVersionType(EXTERNAL).setVersion(version).setSource("foo", "dest")
client().prepareIndex("dest").setId("test").setVersionType(EXTERNAL).setVersion(version).setSource("foo", "dest")
);
assertEquals(version, client().prepareGet("dest", "test").get().getVersion());

View File

@ -99,7 +99,7 @@ public class RethrottleTests extends ReindexTestCase {
List<IndexRequestBuilder> docs = new ArrayList<>();
for (int i = 0; i < numSlices * 10; i++) {
docs.add(client().prepareIndex("test", "test", Integer.toString(i)).setSource("foo", "bar"));
docs.add(client().prepareIndex("test").setId(Integer.toString(i)).setSource("foo", "bar"));
}
indexRandom(true, docs);

View File

@ -50,10 +50,10 @@ public class UpdateByQueryBasicTests extends ReindexTestCase {
public void testBasics() throws Exception {
indexRandom(
true,
client().prepareIndex("test", "test", "1").setSource("foo", "a"),
client().prepareIndex("test", "test", "2").setSource("foo", "a"),
client().prepareIndex("test", "test", "3").setSource("foo", "b"),
client().prepareIndex("test", "test", "4").setSource("foo", "c")
client().prepareIndex("test").setId("1").setSource("foo", "a"),
client().prepareIndex("test").setId("2").setSource("foo", "a"),
client().prepareIndex("test").setId("3").setSource("foo", "b"),
client().prepareIndex("test").setId("4").setSource("foo", "c")
);
assertHitCount(client().prepareSearch("test").setSize(0).get(), 4);
assertEquals(1, client().prepareGet("test", "1").get().getVersion());
@ -90,10 +90,10 @@ public class UpdateByQueryBasicTests extends ReindexTestCase {
public void testSlices() throws Exception {
indexRandom(
true,
client().prepareIndex("test", "test", "1").setSource("foo", "a"),
client().prepareIndex("test", "test", "2").setSource("foo", "a"),
client().prepareIndex("test", "test", "3").setSource("foo", "b"),
client().prepareIndex("test", "test", "4").setSource("foo", "c")
client().prepareIndex("test").setId("1").setSource("foo", "a"),
client().prepareIndex("test").setId("2").setSource("foo", "a"),
client().prepareIndex("test").setId("3").setSource("foo", "b"),
client().prepareIndex("test").setId("4").setSource("foo", "c")
);
assertHitCount(client().prepareSearch("test").setSize(0).get(), 4);
assertEquals(1, client().prepareGet("test", "1").get().getVersion());
@ -138,7 +138,7 @@ public class UpdateByQueryBasicTests extends ReindexTestCase {
docs.put(indexName, new ArrayList<>());
int numDocs = between(5, 15);
for (int i = 0; i < numDocs; i++) {
docs.get(indexName).add(client().prepareIndex(indexName, "test", Integer.toString(i)).setSource("foo", "a"));
docs.get(indexName).add(client().prepareIndex(indexName).setId(Integer.toString(i)).setSource("foo", "a"));
}
}

View File

@ -55,7 +55,7 @@ public class UpdateByQueryWhileModifyingTests extends ReindexTestCase {
public void testUpdateWhileReindexing() throws Exception {
AtomicReference<String> value = new AtomicReference<>(randomSimpleString(random()));
indexRandom(true, client().prepareIndex("test", "test", "test").setSource("test", value.get()));
indexRandom(true, client().prepareIndex("test").setId("test").setSource("test", value.get()));
AtomicReference<Exception> failure = new AtomicReference<>();
AtomicBoolean keepUpdating = new AtomicBoolean(true);
@ -79,7 +79,8 @@ public class UpdateByQueryWhileModifyingTests extends ReindexTestCase {
GetResponse get = client().prepareGet("test", "test").get();
assertEquals(value.get(), get.getSource().get("test"));
value.set(randomSimpleString(random()));
IndexRequestBuilder index = client().prepareIndex("test", "test", "test")
IndexRequestBuilder index = client().prepareIndex("test")
.setId("test")
.setSource("test", value.get())
.setRefreshPolicy(IMMEDIATE);
/*

View File

@ -93,8 +93,8 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
// both values should collate to same value
indexRandom(
true,
client().prepareIndex(index, type, "1").setSource("{\"id\":\"1\",\"collate\":\"" + equivalent[0] + "\"}", XContentType.JSON),
client().prepareIndex(index, type, "2").setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[1] + "\"}", XContentType.JSON)
client().prepareIndex(index).setId("1").setSource("{\"id\":\"1\",\"collate\":\"" + equivalent[0] + "\"}", XContentType.JSON),
client().prepareIndex(index).setId("2").setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[1] + "\"}", XContentType.JSON)
);
// searching for either of the terms should return both results since they collate to the same value
@ -135,9 +135,10 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
// everything should be indexed fine, no exceptions
indexRandom(
true,
client().prepareIndex(index, type, "1")
client().prepareIndex(index)
.setId("1")
.setSource("{\"id\":\"1\", \"collate\":[\"" + equivalent[0] + "\", \"" + equivalent[1] + "\"]}", XContentType.JSON),
client().prepareIndex(index, type, "2").setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[2] + "\"}", XContentType.JSON)
client().prepareIndex(index).setId("2").setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[2] + "\"}", XContentType.JSON)
);
// using sort mode = max, values B and C will be used for the sort
@ -198,8 +199,8 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
indexRandom(
true,
client().prepareIndex(index, type, "1").setSource("{\"id\":\"1\",\"collate\":\"" + equivalent[0] + "\"}", XContentType.JSON),
client().prepareIndex(index, type, "2").setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[1] + "\"}", XContentType.JSON)
client().prepareIndex(index).setId("1").setSource("{\"id\":\"1\",\"collate\":\"" + equivalent[0] + "\"}", XContentType.JSON),
client().prepareIndex(index).setId("2").setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[1] + "\"}", XContentType.JSON)
);
// searching for either of the terms should return both results since they collate to the same value
@ -244,8 +245,8 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
indexRandom(
true,
client().prepareIndex(index, type, "1").setSource("{\"id\":\"1\",\"collate\":\"" + equivalent[0] + "\"}", XContentType.JSON),
client().prepareIndex(index, type, "2").setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[1] + "\"}", XContentType.JSON)
client().prepareIndex(index).setId("1").setSource("{\"id\":\"1\",\"collate\":\"" + equivalent[0] + "\"}", XContentType.JSON),
client().prepareIndex(index).setId("2").setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[1] + "\"}", XContentType.JSON)
);
SearchRequest request = new SearchRequest().indices(index)
@ -290,8 +291,8 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
indexRandom(
true,
client().prepareIndex(index, type, "1").setSource("{\"id\":\"1\",\"collate\":\"" + equivalent[0] + "\"}", XContentType.JSON),
client().prepareIndex(index, type, "2").setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[1] + "\"}", XContentType.JSON)
client().prepareIndex(index).setId("1").setSource("{\"id\":\"1\",\"collate\":\"" + equivalent[0] + "\"}", XContentType.JSON),
client().prepareIndex(index).setId("2").setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[1] + "\"}", XContentType.JSON)
);
SearchRequest request = new SearchRequest().indices(index)
@ -336,9 +337,9 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
indexRandom(
true,
client().prepareIndex(index, type, "1").setSource("{\"id\":\"1\",\"collate\":\"foo bar\"}", XContentType.JSON),
client().prepareIndex(index, type, "2").setSource("{\"id\":\"2\",\"collate\":\"foobar\"}", XContentType.JSON),
client().prepareIndex(index, type, "3").setSource("{\"id\":\"3\",\"collate\":\"foo-bar\"}", XContentType.JSON)
client().prepareIndex(index).setId("1").setSource("{\"id\":\"1\",\"collate\":\"foo bar\"}", XContentType.JSON),
client().prepareIndex(index).setId("2").setSource("{\"id\":\"2\",\"collate\":\"foobar\"}", XContentType.JSON),
client().prepareIndex(index).setId("3").setSource("{\"id\":\"3\",\"collate\":\"foo-bar\"}", XContentType.JSON)
);
SearchRequest request = new SearchRequest().indices(index)
@ -379,8 +380,8 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
indexRandom(
true,
client().prepareIndex(index, type, "1").setSource("{\"collate\":\"foobar-10\"}", XContentType.JSON),
client().prepareIndex(index, type, "2").setSource("{\"collate\":\"foobar-9\"}", XContentType.JSON)
client().prepareIndex(index).setId("1").setSource("{\"collate\":\"foobar-10\"}", XContentType.JSON),
client().prepareIndex(index).setId("2").setSource("{\"collate\":\"foobar-9\"}", XContentType.JSON)
);
SearchRequest request = new SearchRequest().indices(index)
@ -419,10 +420,10 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
indexRandom(
true,
client().prepareIndex(index, type, "1").setSource("{\"id\":\"1\",\"collate\":\"résumé\"}", XContentType.JSON),
client().prepareIndex(index, type, "2").setSource("{\"id\":\"2\",\"collate\":\"Resume\"}", XContentType.JSON),
client().prepareIndex(index, type, "3").setSource("{\"id\":\"3\",\"collate\":\"resume\"}", XContentType.JSON),
client().prepareIndex(index, type, "4").setSource("{\"id\":\"4\",\"collate\":\"Résumé\"}", XContentType.JSON)
client().prepareIndex(index).setId("1").setSource("{\"id\":\"1\",\"collate\":\"résumé\"}", XContentType.JSON),
client().prepareIndex(index).setId("2").setSource("{\"id\":\"2\",\"collate\":\"Resume\"}", XContentType.JSON),
client().prepareIndex(index).setId("3").setSource("{\"id\":\"3\",\"collate\":\"resume\"}", XContentType.JSON),
client().prepareIndex(index).setId("4").setSource("{\"id\":\"4\",\"collate\":\"Résumé\"}", XContentType.JSON)
);
SearchRequest request = new SearchRequest().indices(index)
@ -458,8 +459,8 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
indexRandom(
true,
client().prepareIndex(index, type, "1").setSource("{\"collate\":\"resume\"}", XContentType.JSON),
client().prepareIndex(index, type, "2").setSource("{\"collate\":\"Resume\"}", XContentType.JSON)
client().prepareIndex(index).setId("1").setSource("{\"collate\":\"resume\"}", XContentType.JSON),
client().prepareIndex(index).setId("2").setSource("{\"collate\":\"Resume\"}", XContentType.JSON)
);
SearchRequest request = new SearchRequest().indices(index)
@ -507,8 +508,8 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
indexRandom(
true,
client().prepareIndex(index, type, "1").setSource("{\"id\":\"1\",\"collate\":\"" + equivalent[0] + "\"}", XContentType.JSON),
client().prepareIndex(index, type, "2").setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[1] + "\"}", XContentType.JSON)
client().prepareIndex(index).setId("1").setSource("{\"id\":\"1\",\"collate\":\"" + equivalent[0] + "\"}", XContentType.JSON),
client().prepareIndex(index).setId("2").setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[1] + "\"}", XContentType.JSON)
);
SearchRequest request = new SearchRequest().indices(index)

View File

@ -136,7 +136,7 @@ public class SizeMappingIT extends OpenSearchIntegTestCase {
public void testBasic() throws Exception {
assertAcked(prepareCreate("test").addMapping("type", "_size", "enabled=true"));
final String source = "{\"f\":10}";
indexRandom(true, client().prepareIndex("test", "type", "1").setSource(source, XContentType.JSON));
indexRandom(true, client().prepareIndex("test").setId("1").setSource(source, XContentType.JSON));
GetResponse getResponse = client().prepareGet("test", "1").setStoredFields("_size").get();
assertNotNull(getResponse.getField("_size"));
assertEquals(source.length(), (int) getResponse.getField("_size").getValue());

View File

@ -88,9 +88,9 @@ public class HdfsTests extends OpenSearchSingleNodeTestCase {
logger.info("--> indexing some data");
for (int i = 0; i < 100; i++) {
client().prepareIndex("test-idx-1", "doc", Integer.toString(i)).setSource("foo", "bar" + i).get();
client().prepareIndex("test-idx-2", "doc", Integer.toString(i)).setSource("foo", "bar" + i).get();
client().prepareIndex("test-idx-3", "doc", Integer.toString(i)).setSource("foo", "bar" + i).get();
client().prepareIndex("test-idx-1").setId(Integer.toString(i)).setSource("foo", "bar" + i).get();
client().prepareIndex("test-idx-2").setId(Integer.toString(i)).setSource("foo", "bar" + i).get();
client().prepareIndex("test-idx-3").setId(Integer.toString(i)).setSource("foo", "bar" + i).get();
}
client().admin().indices().prepareRefresh().get();
assertThat(count(client, "test-idx-1"), equalTo(100L));

View File

@ -226,7 +226,7 @@ public class SearchRestCancellationIT extends HttpSmokeTestCase {
// Make sure we have a few segments
BulkRequestBuilder bulkRequestBuilder = client().prepareBulk().setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
for (int j = 0; j < 20; j++) {
bulkRequestBuilder.add(client().prepareIndex("test", "_doc", Integer.toString(i * 5 + j)).setSource("field", "value"));
bulkRequestBuilder.add(client().prepareIndex("test").setId(Integer.toString(i * 5 + j)).setSource("field", "value"));
}
assertNoFailures(bulkRequestBuilder.get());
}

View File

@ -258,7 +258,7 @@ public class IndicesRequestIT extends OpenSearchIntegTestCase {
interceptTransportActions(updateShardActions);
String indexOrAlias = randomIndexOrAlias();
client().prepareIndex(indexOrAlias, "type", "id").setSource("field", "value").get();
client().prepareIndex(indexOrAlias).setId("id").setSource("field", "value").get();
UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "id").doc(Requests.INDEX_CONTENT_TYPE, "field1", "value1");
UpdateResponse updateResponse = internalCluster().coordOnlyNodeClient().update(updateRequest).actionGet();
assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult());
@ -288,7 +288,7 @@ public class IndicesRequestIT extends OpenSearchIntegTestCase {
interceptTransportActions(updateShardActions);
String indexOrAlias = randomIndexOrAlias();
client().prepareIndex(indexOrAlias, "type", "id").setSource("field", "value").get();
client().prepareIndex(indexOrAlias).setId("id").setSource("field", "value").get();
UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "id").script(
new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "ctx.op='delete'", Collections.emptyMap())
);
@ -584,7 +584,7 @@ public class IndicesRequestIT extends OpenSearchIntegTestCase {
String[] randomIndicesOrAliases = randomIndicesOrAliases();
for (int i = 0; i < randomIndicesOrAliases.length; i++) {
client().prepareIndex(randomIndicesOrAliases[i], "type", "id-" + i).setSource("field", "value").get();
client().prepareIndex(randomIndicesOrAliases[i]).setId("id-" + i).setSource("field", "value").get();
}
refresh();
@ -609,7 +609,7 @@ public class IndicesRequestIT extends OpenSearchIntegTestCase {
String[] randomIndicesOrAliases = randomIndicesOrAliases();
for (int i = 0; i < randomIndicesOrAliases.length; i++) {
client().prepareIndex(randomIndicesOrAliases[i], "type", "id-" + i).setSource("field", "value").get();
client().prepareIndex(randomIndicesOrAliases[i]).setId("id-" + i).setSource("field", "value").get();
}
refresh();

View File

@ -69,7 +69,7 @@ public class RejectionActionIT extends OpenSearchIntegTestCase {
public void testSimulatedSearchRejectionLoad() throws Throwable {
for (int i = 0; i < 10; i++) {
client().prepareIndex("test", "type", Integer.toString(i)).setSource("field", "1").get();
client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", "1").get();
}
int numberOfAsyncOps = randomIntBetween(200, 700);

View File

@ -128,9 +128,9 @@ public class HotThreadsIT extends OpenSearchIntegTestCase {
indexRandom(
true,
client().prepareIndex("test", "type1", "1").setSource("field1", "value1"),
client().prepareIndex("test", "type1", "2").setSource("field1", "value2"),
client().prepareIndex("test", "type1", "3").setSource("field1", "value3")
client().prepareIndex("test").setId("1").setSource("field1", "value1"),
client().prepareIndex("test").setId("2").setSource("field1", "value2"),
client().prepareIndex("test").setId("3").setSource("field1", "value3")
);
ensureSearchable();
while (latch.getCount() > 0) {

View File

@ -319,9 +319,7 @@ public class TasksIT extends OpenSearchIntegTestCase {
ensureGreen("test"); // Make sure all shards are allocated to catch replication tasks
// ensures the mapping is available on all nodes so we won't retry the request (in case replicas don't have the right mapping).
client().admin().indices().preparePutMapping("test").setType("doc").setSource("foo", "type=keyword").get();
client().prepareBulk()
.add(client().prepareIndex("test", "doc", "test_id").setSource("{\"foo\": \"bar\"}", XContentType.JSON))
.get();
client().prepareBulk().add(client().prepareIndex("test").setId("test_id").setSource("{\"foo\": \"bar\"}", XContentType.JSON)).get();
// the bulk operation should produce one main task
List<TaskInfo> topTask = findEvents(BulkAction.NAME, Tuple::v1);
@ -370,7 +368,8 @@ public class TasksIT extends OpenSearchIntegTestCase {
registerTaskManagerListeners(SearchAction.NAME + "[*]"); // shard task
createIndex("test");
ensureGreen("test"); // Make sure all shards are allocated to catch replication tasks
client().prepareIndex("test", "doc", "test_id")
client().prepareIndex("test")
.setId("test_id")
.setSource("{\"foo\": \"bar\"}", XContentType.JSON)
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
.get();

View File

@ -107,7 +107,8 @@ public class ShrinkIndexIT extends OpenSearchIntegTestCase {
internalCluster().ensureAtLeastNumDataNodes(2);
prepareCreate("source").setSettings(Settings.builder().put(indexSettings()).put("number_of_shards", shardSplits[0])).get();
for (int i = 0; i < 20; i++) {
client().prepareIndex("source", "t1", Integer.toString(i))
client().prepareIndex("source")
.setId(Integer.toString(i))
.setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON)
.get();
}
@ -150,7 +151,8 @@ public class ShrinkIndexIT extends OpenSearchIntegTestCase {
assertHitCount(client().prepareSearch("first_shrink").setSize(100).setQuery(new TermsQueryBuilder("foo", "bar")).get(), 20);
for (int i = 0; i < 20; i++) { // now update
client().prepareIndex("first_shrink", "t1", Integer.toString(i))
client().prepareIndex("first_shrink")
.setId(Integer.toString(i))
.setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON)
.get();
}
@ -192,7 +194,8 @@ public class ShrinkIndexIT extends OpenSearchIntegTestCase {
assertHitCount(client().prepareSearch("second_shrink").setSize(100).setQuery(new TermsQueryBuilder("foo", "bar")).get(), 20);
for (int i = 0; i < 20; i++) { // now update
client().prepareIndex("second_shrink", "t1", Integer.toString(i))
client().prepareIndex("second_shrink")
.setId(Integer.toString(i))
.setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON)
.get();
}
@ -525,7 +528,8 @@ public class ShrinkIndexIT extends OpenSearchIntegTestCase {
.put("number_of_replicas", 0)
).addMapping("type", "id", "type=keyword,doc_values=true").get();
for (int i = 0; i < 20; i++) {
client().prepareIndex("source", "type", Integer.toString(i))
client().prepareIndex("source")
.setId(Integer.toString(i))
.setSource("{\"foo\" : \"bar\", \"id\" : " + i + "}", XContentType.JSON)
.get();
}

View File

@ -150,7 +150,8 @@ public class SplitIndexIT extends OpenSearchIntegTestCase {
BiFunction<String, Integer, IndexRequestBuilder> indexFunc = (index, id) -> {
try {
return client().prepareIndex(index, "t1", Integer.toString(id))
return client().prepareIndex(index)
.setId(Integer.toString(id))
.setSource(
jsonBuilder().startObject()
.field("foo", "bar")
@ -523,7 +524,8 @@ public class SplitIndexIT extends OpenSearchIntegTestCase {
.put("number_of_replicas", 0)
).addMapping("type", "id", "type=keyword,doc_values=true").get();
for (int i = 0; i < 20; i++) {
client().prepareIndex("source", "type", Integer.toString(i))
client().prepareIndex("source")
.setId(Integer.toString(i))
.setSource("{\"foo\" : \"bar\", \"id\" : " + i + "}", XContentType.JSON)
.get();
}

View File

@ -55,7 +55,7 @@ public class FlushBlocksIT extends OpenSearchIntegTestCase {
int docs = between(10, 100);
for (int i = 0; i < docs; i++) {
client().prepareIndex("test", "type", "" + i).setSource("test", "init").execute().actionGet();
client().prepareIndex("test").setId("" + i).setSource("test", "init").execute().actionGet();
}
// Request is not blocked

View File

@ -57,7 +57,7 @@ public class ForceMergeBlocksIT extends OpenSearchIntegTestCase {
int docs = between(10, 100);
for (int i = 0; i < docs; i++) {
client().prepareIndex("test", "type", "" + i).setSource("test", "init").execute().actionGet();
client().prepareIndex("test").setId("" + i).setSource("test", "init").execute().actionGet();
}
// Request is not blocked

View File

@ -53,7 +53,7 @@ public class IndicesSegmentsBlocksIT extends OpenSearchIntegTestCase {
int docs = between(10, 100);
for (int i = 0; i < docs; i++) {
client().prepareIndex("test-blocks", "type", "" + i).setSource("test", "init").execute().actionGet();
client().prepareIndex("test-blocks").setId("" + i).setSource("test", "init").execute().actionGet();
}
client().admin().indices().prepareFlush("test-blocks").get();

View File

@ -50,9 +50,9 @@ public class BulkProcessorClusterSettingsIT extends OpenSearchIntegTestCase {
client().admin().cluster().prepareHealth("willwork").setWaitForGreenStatus().execute().actionGet();
BulkRequestBuilder bulkRequestBuilder = client().prepareBulk();
bulkRequestBuilder.add(client().prepareIndex("willwork", "type1", "1").setSource("{\"foo\":1}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("wontwork", "type1", "2").setSource("{\"foo\":2}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("willwork", "type1", "3").setSource("{\"foo\":3}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("willwork").setId("1").setSource("{\"foo\":1}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("wontwork").setId("2").setSource("{\"foo\":2}", XContentType.JSON));
bulkRequestBuilder.add(client().prepareIndex("willwork").setId("3").setSource("{\"foo\":3}", XContentType.JSON));
BulkResponse br = bulkRequestBuilder.get();
BulkItemResponse[] responses = br.getItems();
assertEquals(3, responses.length);

View File

@ -271,9 +271,9 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
createIndex("test", Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).build());
ensureGreen();
BulkResponse bulkResponse = client().prepareBulk()
.add(client().prepareIndex("test", "type", "1").setCreate(true).setSource("field", "1"))
.add(client().prepareIndex("test", "type", "2").setCreate(true).setSource("field", "1"))
.add(client().prepareIndex("test", "type", "1").setSource("field", "2"))
.add(client().prepareIndex("test").setId("1").setCreate(true).setSource("field", "1"))
.add(client().prepareIndex("test").setId("2").setCreate(true).setSource("field", "1"))
.add(client().prepareIndex("test").setId("1").setSource("field", "2"))
.get();
assertEquals(DocWriteResponse.Result.CREATED, bulkResponse.getItems()[0].getResponse().getResult());
@ -294,9 +294,9 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
assertThat(bulkResponse.getItems()[2].getResponse().getSeqNo(), equalTo(4L));
bulkResponse = client().prepareBulk()
.add(client().prepareIndex("test", "type", "e1").setSource("field", "1").setVersion(10).setVersionType(VersionType.EXTERNAL))
.add(client().prepareIndex("test", "type", "e2").setSource("field", "1").setVersion(10).setVersionType(VersionType.EXTERNAL))
.add(client().prepareIndex("test", "type", "e1").setSource("field", "2").setVersion(12).setVersionType(VersionType.EXTERNAL))
.add(client().prepareIndex("test").setId("e1").setSource("field", "1").setVersion(10).setVersionType(VersionType.EXTERNAL))
.add(client().prepareIndex("test").setId("e2").setSource("field", "1").setVersion(10).setVersionType(VersionType.EXTERNAL))
.add(client().prepareIndex("test").setId("e1").setSource("field", "2").setVersion(12).setVersionType(VersionType.EXTERNAL))
.get();
assertEquals(DocWriteResponse.Result.CREATED, bulkResponse.getItems()[0].getResponse().getResult());
@ -538,7 +538,7 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
for (int i = 0; i < numDocs;) {
final BulkRequestBuilder builder = client().prepareBulk();
for (int j = 0; j < bulk && i < numDocs; j++, i++) {
builder.add(client().prepareIndex("test", "type1", Integer.toString(i)).setSource("val", i));
builder.add(client().prepareIndex("test").setId(Integer.toString(i)).setSource("val", i));
}
logger.info("bulk indexing {}-{}", i - bulk, i - 1);
BulkResponse response = builder.get();
@ -692,7 +692,7 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
public void testFailedRequestsOnClosedIndex() throws Exception {
createIndex("bulkindex1");
client().prepareIndex("bulkindex1", "index1_type", "1").setSource("text", "test").get();
client().prepareIndex("bulkindex1").setId("1").setSource("text", "test").get();
assertBusy(() -> assertAcked(client().admin().indices().prepareClose("bulkindex1")));
BulkRequest bulkRequest = new BulkRequest().setRefreshPolicy(RefreshPolicy.IMMEDIATE);

View File

@ -213,7 +213,7 @@ public class SearchProgressActionListenerIT extends OpenSearchSingleNodeTestCase
for (int i = 0; i < numIndices; i++) {
String indexName = String.format(Locale.ROOT, "index-%03d", i);
assertAcked(client.admin().indices().prepareCreate(indexName).get());
client.prepareIndex(indexName, "doc", Integer.toString(i)).setSource("number", i, "foo", "bar").get();
client.prepareIndex(indexName).setId(Integer.toString(i)).setSource("number", i, "foo", "bar").get();
}
client.admin().indices().prepareRefresh("index-*").get();
ClusterSearchShardsResponse resp = client.admin().cluster().prepareSearchShards("index-*").get();

View File

@ -63,9 +63,10 @@ public class WaitActiveShardCountIT extends OpenSearchIntegTestCase {
assertAcked(createIndexResponse);
// indexing, by default, will work (waiting for one shard copy only)
client().prepareIndex("test", "type1", "1").setSource(source("1", "test"), XContentType.JSON).execute().actionGet();
client().prepareIndex("test").setId("1").setSource(source("1", "test"), XContentType.JSON).execute().actionGet();
try {
client().prepareIndex("test", "type1", "1")
client().prepareIndex("test")
.setId("1")
.setSource(source("1", "test"), XContentType.JSON)
.setWaitForActiveShards(2) // wait for 2 active shard copies
.setTimeout(timeValueMillis(100))
@ -96,7 +97,8 @@ public class WaitActiveShardCountIT extends OpenSearchIntegTestCase {
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.YELLOW));
// this should work, since we now have two
client().prepareIndex("test", "type1", "1")
client().prepareIndex("test")
.setId("1")
.setSource(source("1", "test"), XContentType.JSON)
.setWaitForActiveShards(2)
.setTimeout(timeValueSeconds(1))
@ -104,7 +106,8 @@ public class WaitActiveShardCountIT extends OpenSearchIntegTestCase {
.actionGet();
try {
client().prepareIndex("test", "type1", "1")
client().prepareIndex("test")
.setId("1")
.setSource(source("1", "test"), XContentType.JSON)
.setWaitForActiveShards(ActiveShardCount.ALL)
.setTimeout(timeValueMillis(100))
@ -138,7 +141,8 @@ public class WaitActiveShardCountIT extends OpenSearchIntegTestCase {
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN));
// this should work, since we now have all shards started
client().prepareIndex("test", "type1", "1")
client().prepareIndex("test")
.setId("1")
.setSource(source("1", "test"), XContentType.JSON)
.setWaitForActiveShards(ActiveShardCount.ALL)
.setTimeout(timeValueSeconds(1))

View File

@ -92,7 +92,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
.endObject();
assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("type1", mapping));
client().prepareIndex("test", "type1", "666").setSource("field", "foo bar").execute().actionGet();
client().prepareIndex("test").setId("667").setSource("field", "foo bar").execute().actionGet();
refresh();
for (int i = 0; i < 20; i++) {
ActionFuture<TermVectorsResponse> termVector = client().termVectors(new TermVectorsRequest(indexOrAlias(), "" + i));
@ -119,7 +119,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("type1", mapping));
// when indexing a field that simply has a question mark, the term vectors will be null
client().prepareIndex("test", "type1", "0").setSource("existingfield", "?").execute().actionGet();
client().prepareIndex("test").setId("0").setSource("existingfield", "?").execute().actionGet();
refresh();
ActionFuture<TermVectorsResponse> termVector = client().termVectors(
new TermVectorsRequest(indexOrAlias(), "0").selectedFields(new String[] { "existingfield" })
@ -147,7 +147,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("type1", mapping));
// when indexing a field that simply has a question mark, the term vectors will be null
client().prepareIndex("test", "type1", "0").setSource("anotherexistingfield", 1).execute().actionGet();
client().prepareIndex("test").setId("0").setSource("anotherexistingfield", 1).execute().actionGet();
refresh();
ActionFuture<TermVectorsResponse> termVectors = client().termVectors(
new TermVectorsRequest(indexOrAlias(), "0").selectedFields(randomBoolean() ? new String[] { "existingfield" } : null)
@ -228,7 +228,8 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
)
);
for (int i = 0; i < 10; i++) {
client().prepareIndex("test", "type1", Integer.toString(i))
client().prepareIndex("test")
.setId(Integer.toString(i))
.setSource(
jsonBuilder().startObject()
.field("field", "the quick brown fox jumps over the lazy dog")
@ -336,7 +337,8 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
)
);
for (int i = 0; i < 10; i++) {
client().prepareIndex("test", "_doc", Integer.toString(i))
client().prepareIndex("test")
.setId(Integer.toString(i))
.setSource(
jsonBuilder().startObject()
.field("field", "the quick brown fox jumps over the lazy dog")
@ -492,7 +494,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
ensureGreen();
for (int i = 0; i < 10; i++) {
client().prepareIndex("test", "type1", Integer.toString(i)).setSource(source).execute().actionGet();
client().prepareIndex("test").setId(Integer.toString(i)).setSource(source).execute().actionGet();
refresh();
}
@ -652,7 +654,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("type1", mapping));
ensureGreen();
client().prepareIndex("test", "type1", "0").setSource(source).get();
client().prepareIndex("test").setId("0").setSource(source).get();
refresh();
TermVectorsResponse response = client().prepareTermVectors(indexOrAlias(), "0").setSelectedFields("field*").get();
@ -766,7 +768,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
ensureGreen();
// index a single document with prepared source
client().prepareIndex("test", "type1", "0").setSource(source).get();
client().prepareIndex("test").setId("0").setSource(source).get();
refresh();
// create random per_field_analyzer and selected fields
@ -840,7 +842,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
assertThat(response.isExists(), equalTo(false));
logger.info("--> index doc 1");
client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2").get();
client().prepareIndex("test").setId("1").setSource("field1", "value1", "field2", "value2").get();
// From translog:
@ -886,7 +888,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
}
logger.info("--> index doc 1 again, so increasing the version");
client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2").get();
client().prepareIndex("test").setId("1").setSource("field1", "value1", "field2", "value2").get();
// From translog:
@ -949,7 +951,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
}
tags.add(tag);
}
indexRandom(true, client().prepareIndex("test", "type1", "1").setSource("tags", tags));
indexRandom(true, client().prepareIndex("test").setId("1").setSource("tags", tags));
logger.info("Checking best tags by longest to shortest size ...");
TermVectorsRequest.FilterSettings filterSettings = new TermVectorsRequest.FilterSettings();
@ -985,7 +987,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
}
uniqueTags.add(tag);
}
indexRandom(true, client().prepareIndex("test", "type1", "1").setSource("tags", tags));
indexRandom(true, client().prepareIndex("test").setId("1").setSource("tags", tags));
logger.info("Checking best tags by highest to lowest term freq ...");
TermVectorsRequest.FilterSettings filterSettings = new TermVectorsRequest.FilterSettings();
@ -1016,7 +1018,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
List<String> tags = new ArrayList<>();
for (int i = 0; i < numDocs; i++) {
tags.add("tag_" + i);
builders.add(client().prepareIndex("test", "type1", i + "").setSource("tags", tags));
builders.add(client().prepareIndex("test").setId(i + "").setSource("tags", tags));
}
indexRandom(true, builders);
@ -1044,7 +1046,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
ensureGreen();
// index document
indexRandom(true, client().prepareIndex("test", "type1", "1").setSource("field1", "random permutation"));
indexRandom(true, client().prepareIndex("test").setId("1").setSource("field1", "random permutation"));
// Get search shards
ClusterSearchShardsResponse searchShardsResponse = client().admin().cluster().prepareSearchShards("test").get();

View File

@ -101,7 +101,7 @@ public class MultiTermVectorsIT extends AbstractTermVectorsTestCase {
assertThat(response.getResponses()[0].getResponse().isExists(), equalTo(false));
for (int i = 0; i < 3; i++) {
client().prepareIndex("test", "type1", Integer.toString(i)).setSource("field", "value" + i).get();
client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", "value" + i).get();
}
// Version from translog
@ -150,7 +150,7 @@ public class MultiTermVectorsIT extends AbstractTermVectorsTestCase {
assertThat(response.getResponses()[2].getFailure().getCause().getCause(), instanceOf(VersionConflictEngineException.class));
for (int i = 0; i < 3; i++) {
client().prepareIndex("test", "type1", Integer.toString(i)).setSource("field", "value" + i).get();
client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", "value" + i).get();
}
// Version from translog

View File

@ -1305,7 +1305,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
public void testRemoveIndexAndReplaceWithAlias() throws InterruptedException, ExecutionException {
assertAcked(client().admin().indices().prepareCreate("test"));
indexRandom(true, client().prepareIndex("test_2", "test", "test").setSource("test", "test"));
indexRandom(true, client().prepareIndex("test_2").setId("test").setSource("test", "test"));
assertAliasesVersionIncreases(
"test_2",
() -> assertAcked(client().admin().indices().prepareAliases().addAlias("test_2", "test").removeIndex("test"))

View File

@ -121,7 +121,7 @@ public class MinimumMasterNodesIT extends OpenSearchIntegTestCase {
NumShards numShards = getNumShards("test");
logger.info("--> indexing some data");
for (int i = 0; i < 100; i++) {
client().prepareIndex("test", "type1", Integer.toString(i)).setSource("field", "value").execute().actionGet();
client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", "value").execute().actionGet();
}
// make sure that all shards recovered before trying to flush
assertThat(
@ -286,7 +286,7 @@ public class MinimumMasterNodesIT extends OpenSearchIntegTestCase {
NumShards numShards = getNumShards("test");
logger.info("--> indexing some data");
for (int i = 0; i < 100; i++) {
client().prepareIndex("test", "type1", Integer.toString(i)).setSource("field", "value").execute().actionGet();
client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", "value").execute().actionGet();
}
ensureGreen();
// make sure that all shards recovered before trying to flush

View File

@ -179,33 +179,35 @@ public class NoMasterNodeIT extends OpenSearchIntegTestCase {
);
checkWriteAction(
clientToMasterlessNode.prepareIndex("test", "type1", "1")
clientToMasterlessNode.prepareIndex("test")
.setId("1")
.setSource(XContentFactory.jsonBuilder().startObject().endObject())
.setTimeout(timeout)
);
checkWriteAction(
clientToMasterlessNode.prepareIndex("no_index", "type1", "1")
clientToMasterlessNode.prepareIndex("no_index")
.setId("1")
.setSource(XContentFactory.jsonBuilder().startObject().endObject())
.setTimeout(timeout)
);
BulkRequestBuilder bulkRequestBuilder = clientToMasterlessNode.prepareBulk();
bulkRequestBuilder.add(
clientToMasterlessNode.prepareIndex("test", "type1", "1").setSource(XContentFactory.jsonBuilder().startObject().endObject())
clientToMasterlessNode.prepareIndex("test").setId("1").setSource(XContentFactory.jsonBuilder().startObject().endObject())
);
bulkRequestBuilder.add(
clientToMasterlessNode.prepareIndex("test", "type1", "2").setSource(XContentFactory.jsonBuilder().startObject().endObject())
clientToMasterlessNode.prepareIndex("test").setId("2").setSource(XContentFactory.jsonBuilder().startObject().endObject())
);
bulkRequestBuilder.setTimeout(timeout);
checkWriteAction(bulkRequestBuilder);
bulkRequestBuilder = clientToMasterlessNode.prepareBulk();
bulkRequestBuilder.add(
clientToMasterlessNode.prepareIndex("no_index", "type1", "1").setSource(XContentFactory.jsonBuilder().startObject().endObject())
clientToMasterlessNode.prepareIndex("no_index").setId("1").setSource(XContentFactory.jsonBuilder().startObject().endObject())
);
bulkRequestBuilder.add(
clientToMasterlessNode.prepareIndex("no_index", "type1", "2").setSource(XContentFactory.jsonBuilder().startObject().endObject())
clientToMasterlessNode.prepareIndex("no_index").setId("2").setSource(XContentFactory.jsonBuilder().startObject().endObject())
);
bulkRequestBuilder.setTimeout(timeout);
checkWriteAction(bulkRequestBuilder);
@ -252,8 +254,8 @@ public class NoMasterNodeIT extends OpenSearchIntegTestCase {
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 3).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
).get();
client().admin().cluster().prepareHealth("_all").setWaitForGreenStatus().get();
client().prepareIndex("test1", "type1", "1").setSource("field", "value1").get();
client().prepareIndex("test2", "type1", "1").setSource("field", "value1").get();
client().prepareIndex("test1").setId("1").setSource("field", "value1").get();
client().prepareIndex("test2").setId("1").setSource("field", "value1").get();
refresh();
ensureSearchable("test1", "test2");
@ -306,7 +308,8 @@ public class NoMasterNodeIT extends OpenSearchIntegTestCase {
}
try {
clientToMasterlessNode.prepareIndex("test1", "type1", "1")
clientToMasterlessNode.prepareIndex("test1")
.setId("1")
.setSource(XContentFactory.jsonBuilder().startObject().endObject())
.setTimeout(timeout)
.get();

View File

@ -335,7 +335,7 @@ public class ClusterRerouteIT extends OpenSearchIntegTestCase {
);
if (closed == false) {
client().prepareIndex("test", "type", "1").setSource("field", "value").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareIndex("test").setId("1").setSource("field", "value").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
}
final Index index = resolveIndex("test");

View File

@ -72,7 +72,7 @@ public class FilteringAllocationIT extends OpenSearchIntegTestCase {
ensureGreen("test");
logger.info("--> index some data");
for (int i = 0; i < 100; i++) {
client().prepareIndex("test", "type", Integer.toString(i)).setSource("field", "value" + i).execute().actionGet();
client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", "value" + i).execute().actionGet();
}
client().admin().indices().prepareRefresh().execute().actionGet();
assertThat(
@ -187,7 +187,7 @@ public class FilteringAllocationIT extends OpenSearchIntegTestCase {
logger.info("--> index some data");
for (int i = 0; i < 100; i++) {
client().prepareIndex("test", "type", Integer.toString(i)).setSource("field", "value" + i).execute().actionGet();
client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", "value" + i).execute().actionGet();
}
client().admin().indices().prepareRefresh().execute().actionGet();
assertThat(

View File

@ -291,7 +291,7 @@ public class RareClusterStateIT extends OpenSearchIntegTestCase {
// this request does not change the cluster state, because mapping is already created,
// we don't await and cancel committed publication
ActionFuture<IndexResponse> docIndexResponse = client().prepareIndex("index", "type", "1").setSource("field", 42).execute();
ActionFuture<IndexResponse> docIndexResponse = client().prepareIndex("index").setId("1").setSource("field", 42).execute();
// Wait a bit to make sure that the reason why we did not get a response
// is that cluster state processing is blocked and not just that it takes
@ -376,7 +376,7 @@ public class RareClusterStateIT extends OpenSearchIntegTestCase {
assertNotNull(mapper.mappers().getMapper("field"));
});
final ActionFuture<IndexResponse> docIndexResponse = client().prepareIndex("index", "type", "1").setSource("field", 42).execute();
final ActionFuture<IndexResponse> docIndexResponse = client().prepareIndex("index").setId("1").setSource("field", 42).execute();
assertBusy(() -> assertTrue(client().prepareGet("index", "1").get().isExists()));
@ -386,7 +386,7 @@ public class RareClusterStateIT extends OpenSearchIntegTestCase {
// this request does not change the cluster state, because the mapping is dynamic,
// we need to await and cancel committed publication
ActionFuture<IndexResponse> dynamicMappingsFut = executeAndCancelCommittedPublication(
client().prepareIndex("index", "type", "2").setSource("field2", 42)
client().prepareIndex("index").setId("2").setSource("field2", 42)
);
// ...and wait for second mapping to be available on master

View File

@ -430,7 +430,7 @@ public class UnsafeBootstrapAndDetachCommandIT extends OpenSearchIntegTestCase {
ensureStableCluster(2);
logger.info("--> index 1 doc and ensure index is green");
client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("test").setId("1").setSource("field1", "value1").setRefreshPolicy(IMMEDIATE).get();
ensureGreen("test");
assertBusy(
() -> internalCluster().getInstances(IndicesService.class)

View File

@ -212,7 +212,7 @@ public class MockDiskUsagesIT extends OpenSearchIntegTestCase {
assertThat("node2 has 2 shards", shardCountByNodeId.get(nodeIds.get(2)), equalTo(2));
}
client().prepareIndex("test", "doc", "1").setSource("foo", "bar").setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get();
client().prepareIndex("test").setId("1").setSource("foo", "bar").setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get();
assertSearchHits(client().prepareSearch("test").get(), "1");
// Move all nodes above the low watermark so no shard movement can occur, and at least one node above the flood stage watermark so
@ -249,7 +249,8 @@ public class MockDiskUsagesIT extends OpenSearchIntegTestCase {
// Attempt to create a new document until DiskUsageMonitor unblocks the index
assertBusy(() -> {
try {
client().prepareIndex("test", "doc", "3")
client().prepareIndex("test")
.setId("3")
.setSource("foo", "bar")
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
.get();

View File

@ -173,7 +173,7 @@ public class ClusterSearchShardsIT extends OpenSearchIntegTestCase {
int docs = between(10, 100);
for (int i = 0; i < docs; i++) {
client().prepareIndex("test-blocks", "type", "" + i).setSource("test", "init").execute().actionGet();
client().prepareIndex("test-blocks").setId("" + i).setSource("test", "init").execute().actionGet();
}
ensureGreen("test-blocks");

View File

@ -171,7 +171,8 @@ public class ClusterDisruptionIT extends AbstractDisruptionTestCase {
id = Integer.toString(idGenerator.incrementAndGet());
int shard = Math.floorMod(Murmur3HashFunction.hash(id), numPrimaries);
logger.trace("[{}] indexing id [{}] through node [{}] targeting shard [{}]", name, id, node, shard);
IndexRequestBuilder indexRequestBuilder = client.prepareIndex("test", "type", id)
IndexRequestBuilder indexRequestBuilder = client.prepareIndex("test")
.setId(id)
.setSource(Collections.singletonMap(randomFrom(fieldNames), randomNonNegativeLong()), XContentType.JSON)
.setTimeout(timeout);
@ -511,7 +512,8 @@ public class ClusterDisruptionIT extends AbstractDisruptionTestCase {
while (stopped.get() == false && docID.get() < 5000) {
String id = Integer.toString(docID.incrementAndGet());
try {
IndexResponse response = client().prepareIndex(index, "_doc", id)
IndexResponse response = client().prepareIndex(index)
.setId(id)
.setSource(Collections.singletonMap("f" + randomIntBetween(1, 10), randomNonNegativeLong()), XContentType.JSON)
.get();
assertThat(response.getResult(), is(oneOf(CREATED, UPDATED)));

View File

@ -298,9 +298,9 @@ public class MasterDisruptionIT extends AbstractDisruptionTestCase {
disruption.startDisrupting();
BulkRequestBuilder bulk = client().prepareBulk();
bulk.add(client().prepareIndex("test", "doc", "2").setSource("{ \"f\": 1 }", XContentType.JSON));
bulk.add(client().prepareIndex("test", "doc", "3").setSource("{ \"g\": 1 }", XContentType.JSON));
bulk.add(client().prepareIndex("test", "doc", "4").setSource("{ \"f\": 1 }", XContentType.JSON));
bulk.add(client().prepareIndex("test").setId("2").setSource("{ \"f\": 1 }", XContentType.JSON));
bulk.add(client().prepareIndex("test").setId("3").setSource("{ \"g\": 1 }", XContentType.JSON));
bulk.add(client().prepareIndex("test").setId("4").setSource("{ \"f\": 1 }", XContentType.JSON));
BulkResponse bulkResponse = bulk.get();
assertTrue(bulkResponse.hasFailures());

View File

@ -294,7 +294,7 @@ public class SnapshotDisruptionIT extends AbstractSnapshotIntegTestCase {
final int numdocs = randomIntBetween(10, 100);
IndexRequestBuilder[] builders = new IndexRequestBuilder[numdocs];
for (int i = 0; i < builders.length; i++) {
builders[i] = client().prepareIndex(idxName, "type1", Integer.toString(i)).setSource("field1", "bar " + i);
builders[i] = client().prepareIndex(idxName).setId(Integer.toString(i)).setSource("field1", "bar " + i);
}
indexRandom(true, builders);
}

View File

@ -104,7 +104,7 @@ public class NodeEnvironmentIT extends OpenSearchIntegTestCase {
internalCluster().startNode(dataPathSettings);
logger.info("--> indexing a simple document");
client().prepareIndex(indexName, "type1", "1").setSource("field1", "value1").get();
client().prepareIndex(indexName).setId("1").setSource("field1", "value1").get();
logger.info("--> restarting the node without the data role");
ex = expectThrows(

View File

@ -65,7 +65,7 @@ public class NodeRepurposeCommandIT extends OpenSearchIntegTestCase {
prepareCreate(indexName, Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0)).get();
logger.info("--> indexing a simple document");
client().prepareIndex(indexName, "type1", "1").setSource("field1", "value1").get();
client().prepareIndex(indexName).setId("1").setSource("field1", "value1").get();
ensureGreen();

View File

@ -63,7 +63,7 @@ public class ExplainActionIT extends OpenSearchIntegTestCase {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setSettings(Settings.builder().put("index.refresh_interval", -1)));
ensureGreen("test");
client().prepareIndex("test", "test", "1").setSource("field", "value1").get();
client().prepareIndex("test").setId("1").setSource("field", "value1").get();
ExplainResponse response = client().prepareExplain(indexOrAlias(), "1").setQuery(QueryBuilders.matchAllQuery()).get();
assertNotNull(response);
@ -120,7 +120,8 @@ public class ExplainActionIT extends OpenSearchIntegTestCase {
);
ensureGreen("test");
client().prepareIndex("test", "test", "1")
client().prepareIndex("test")
.setId("1")
.setSource(
jsonBuilder().startObject().startObject("obj1").field("field1", "value1").field("field2", "value2").endObject().endObject()
)
@ -178,7 +179,8 @@ public class ExplainActionIT extends OpenSearchIntegTestCase {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")));
ensureGreen("test");
client().prepareIndex("test", "test", "1")
client().prepareIndex("test")
.setId("1")
.setSource(
jsonBuilder().startObject().startObject("obj1").field("field1", "value1").field("field2", "value2").endObject().endObject()
)
@ -215,7 +217,7 @@ public class ExplainActionIT extends OpenSearchIntegTestCase {
);
ensureGreen("test");
client().prepareIndex("test", "test", "1").setSource("field1", "value1", "field2", "value1").get();
client().prepareIndex("test").setId("1").setSource("field1", "value1", "field2", "value1").get();
refresh();
ExplainResponse response = client().prepareExplain("alias1", "1").setQuery(QueryBuilders.matchAllQuery()).get();
@ -234,7 +236,7 @@ public class ExplainActionIT extends OpenSearchIntegTestCase {
);
ensureGreen("test");
client().prepareIndex("test", "test", "1").setSource("field1", "value1", "field2", "value1").get();
client().prepareIndex("test").setId("1").setSource("field1", "value1", "field2", "value1").get();
refresh();
ExplainResponse response = client().prepareExplain("alias1", "1")
@ -261,7 +263,7 @@ public class ExplainActionIT extends OpenSearchIntegTestCase {
String aMonthAgo = DateTimeFormatter.ISO_LOCAL_DATE.format(now.minusMonths(1));
String aMonthFromNow = DateTimeFormatter.ISO_LOCAL_DATE.format(now.plusMonths(1));
client().prepareIndex("test", "type", "1").setSource("past", aMonthAgo, "future", aMonthFromNow).get();
client().prepareIndex("test").setId("1").setSource("past", aMonthAgo, "future", aMonthFromNow).get();
refresh();

View File

@ -174,7 +174,7 @@ public class GatewayIndexStateIT extends OpenSearchIntegTestCase {
);
logger.info("--> indexing a simple document");
client().prepareIndex("test", "type1", "1").setSource("field1", "value1").get();
client().prepareIndex("test").setId("1").setSource("field1", "value1").get();
logger.info("--> closing test index...");
assertAcked(client().admin().indices().prepareClose("test"));
@ -188,14 +188,14 @@ public class GatewayIndexStateIT extends OpenSearchIntegTestCase {
logger.info("--> trying to index into a closed index ...");
try {
client().prepareIndex("test", "type1", "1").setSource("field1", "value1").execute().actionGet();
client().prepareIndex("test").setId("1").setSource("field1", "value1").execute().actionGet();
fail();
} catch (IndexClosedException e) {
// all is well
}
logger.info("--> creating another index (test2) by indexing into it");
client().prepareIndex("test2", "type1", "1").setSource("field1", "value1").execute().actionGet();
client().prepareIndex("test2").setId("1").setSource("field1", "value1").execute().actionGet();
logger.info("--> verifying that the state is green");
ensureGreen();
@ -234,7 +234,7 @@ public class GatewayIndexStateIT extends OpenSearchIntegTestCase {
logger.info("--> trying to index into a closed index ...");
try {
client().prepareIndex("test", "type1", "1").setSource("field1", "value1").execute().actionGet();
client().prepareIndex("test").setId("1").setSource("field1", "value1").execute().actionGet();
fail();
} catch (IndexClosedException e) {
// all is well
@ -259,7 +259,7 @@ public class GatewayIndexStateIT extends OpenSearchIntegTestCase {
assertThat(getResponse.isExists(), equalTo(true));
logger.info("--> indexing a simple document");
client().prepareIndex("test", "type1", "2").setSource("field1", "value1").execute().actionGet();
client().prepareIndex("test").setId("2").setSource("field1", "value1").execute().actionGet();
}
public void testJustMasterNode() throws Exception {
@ -314,7 +314,7 @@ public class GatewayIndexStateIT extends OpenSearchIntegTestCase {
internalCluster().startNodes(2);
logger.info("--> indexing a simple document");
client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("test").setId("1").setSource("field1", "value1").setRefreshPolicy(IMMEDIATE).get();
logger.info("--> waiting for green status");
ClusterHealthResponse health = client().admin()
@ -429,7 +429,7 @@ public class GatewayIndexStateIT extends OpenSearchIntegTestCase {
logger.info("--> starting one node");
internalCluster().startNode();
logger.info("--> indexing a simple document");
client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("test").setId("1").setSource("field1", "value1").setRefreshPolicy(IMMEDIATE).get();
logger.info("--> waiting for green status");
if (usually()) {
ensureYellow();
@ -516,7 +516,7 @@ public class GatewayIndexStateIT extends OpenSearchIntegTestCase {
)
.get();
logger.info("--> indexing a simple document");
client().prepareIndex("test", "type1", "1").setSource("field1", "value one").setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("test").setId("1").setSource("field1", "value one").setRefreshPolicy(IMMEDIATE).get();
logger.info("--> waiting for green status");
if (usually()) {
ensureYellow();
@ -567,7 +567,7 @@ public class GatewayIndexStateIT extends OpenSearchIntegTestCase {
public void testArchiveBrokenClusterSettings() throws Exception {
logger.info("--> starting one node");
internalCluster().startNode();
client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("test").setId("1").setSource("field1", "value1").setRefreshPolicy(IMMEDIATE).get();
logger.info("--> waiting for green status");
if (usually()) {
ensureYellow();

View File

@ -66,11 +66,11 @@ public class QuorumGatewayIT extends OpenSearchIntegTestCase {
final NumShards test = getNumShards("test");
logger.info("--> indexing...");
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject().field("field", "value1").endObject()).get();
client().prepareIndex("test").setId("1").setSource(jsonBuilder().startObject().field("field", "value1").endObject()).get();
// We don't check for failures in the flush response: if we do we might get the following:
// FlushNotAllowedEngineException[[test][1] recovery is in progress, flush [COMMIT_TRANSLOG] is not allowed]
flush();
client().prepareIndex("test", "type1", "2").setSource(jsonBuilder().startObject().field("field", "value2").endObject()).get();
client().prepareIndex("test").setId("2").setSource(jsonBuilder().startObject().field("field", "value2").endObject()).get();
refresh();
for (int i = 0; i < 10; i++) {
@ -95,7 +95,8 @@ public class QuorumGatewayIT extends OpenSearchIntegTestCase {
}, 30, TimeUnit.SECONDS);
logger.info("--> one node is closed -- index 1 document into the remaining nodes");
activeClient.prepareIndex("test", "type1", "3")
activeClient.prepareIndex("test")
.setId("3")
.setSource(jsonBuilder().startObject().field("field", "value3").endObject())
.get();
assertNoFailures(activeClient.admin().indices().prepareRefresh().get());

View File

@ -126,23 +126,28 @@ public class RecoveryFromGatewayIT extends OpenSearchIntegTestCase {
);
assertAcked(prepareCreate("test").addMapping("type1", mapping, XContentType.JSON));
client().prepareIndex("test", "type1", "10990239")
client().prepareIndex("test")
.setId("10990239")
.setSource(jsonBuilder().startObject().startArray("appAccountIds").value(14).value(179).endArray().endObject())
.execute()
.actionGet();
client().prepareIndex("test", "type1", "10990473")
client().prepareIndex("test")
.setId("10990473")
.setSource(jsonBuilder().startObject().startArray("appAccountIds").value(14).endArray().endObject())
.execute()
.actionGet();
client().prepareIndex("test", "type1", "10990513")
client().prepareIndex("test")
.setId("10990513")
.setSource(jsonBuilder().startObject().startArray("appAccountIds").value(14).value(179).endArray().endObject())
.execute()
.actionGet();
client().prepareIndex("test", "type1", "10990695")
client().prepareIndex("test")
.setId("10990695")
.setSource(jsonBuilder().startObject().startArray("appAccountIds").value(14).endArray().endObject())
.execute()
.actionGet();
client().prepareIndex("test", "type1", "11026351")
client().prepareIndex("test")
.setId("11026351")
.setSource(jsonBuilder().startObject().startArray("appAccountIds").value(14).endArray().endObject())
.execute()
.actionGet();
@ -309,12 +314,14 @@ public class RecoveryFromGatewayIT extends OpenSearchIntegTestCase {
public void testSingleNodeWithFlush() throws Exception {
internalCluster().startNode();
client().prepareIndex("test", "type1", "1")
client().prepareIndex("test")
.setId("1")
.setSource(jsonBuilder().startObject().field("field", "value1").endObject())
.execute()
.actionGet();
flush();
client().prepareIndex("test", "type1", "2")
client().prepareIndex("test")
.setId("2")
.setSource(jsonBuilder().startObject().field("field", "value2").endObject())
.execute()
.actionGet();
@ -352,12 +359,14 @@ public class RecoveryFromGatewayIT extends OpenSearchIntegTestCase {
final String firstNode = internalCluster().startNode();
internalCluster().startNode();
client().prepareIndex("test", "type1", "1")
client().prepareIndex("test")
.setId("1")
.setSource(jsonBuilder().startObject().field("field", "value1").endObject())
.execute()
.actionGet();
flush();
client().prepareIndex("test", "type1", "2")
client().prepareIndex("test")
.setId("2")
.setSource(jsonBuilder().startObject().field("field", "value2").endObject())
.execute()
.actionGet();
@ -408,12 +417,14 @@ public class RecoveryFromGatewayIT extends OpenSearchIntegTestCase {
Settings node2DataPathSettings = internalCluster().dataPathSettings(nodes.get(1));
assertAcked(client().admin().indices().prepareCreate("test"));
client().prepareIndex("test", "type1", "1")
client().prepareIndex("test")
.setId("1")
.setSource(jsonBuilder().startObject().field("field", "value1").endObject())
.execute()
.actionGet();
client().admin().indices().prepareFlush().execute().actionGet();
client().prepareIndex("test", "type1", "2")
client().prepareIndex("test")
.setId("2")
.setSource(jsonBuilder().startObject().field("field", "value2").endObject())
.execute()
.actionGet();
@ -433,7 +444,8 @@ public class RecoveryFromGatewayIT extends OpenSearchIntegTestCase {
internalCluster().stopRandomDataNode();
logger.info("--> one node is closed - start indexing data into the second one");
client().prepareIndex("test", "type1", "3")
client().prepareIndex("test")
.setId("3")
.setSource(jsonBuilder().startObject().field("field", "value3").endObject())
.execute()
.actionGet();

View File

@ -94,7 +94,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
assertThat(response.isExists(), equalTo(false));
logger.info("--> index doc 1");
client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2").get();
client().prepareIndex("test").setId("1").setSource("field1", "value1", "field2", "value2").get();
logger.info("--> non realtime get 1");
response = client().prepareGet(indexOrAlias(), "1").setRealtime(false).get();
@ -181,7 +181,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
assertThat(response.getField("field2"), nullValue());
logger.info("--> update doc 1");
client().prepareIndex("test", "type1", "1").setSource("field1", "value1_1", "field2", "value2_1").get();
client().prepareIndex("test").setId("1").setSource("field1", "value1_1", "field2", "value2_1").get();
logger.info("--> realtime get 1");
response = client().prepareGet(indexOrAlias(), "1").get();
@ -191,7 +191,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
assertThat(response.getSourceAsMap().get("field2").toString(), equalTo("value2_1"));
logger.info("--> update doc 1 again");
client().prepareIndex("test", "type1", "1").setSource("field1", "value1_2", "field2", "value2_2").get();
client().prepareIndex("test").setId("1").setSource("field1", "value1_2", "field2", "value2_2").get();
response = client().prepareGet(indexOrAlias(), "1").get();
assertThat(response.isExists(), equalTo(true));
@ -217,7 +217,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
} else {
client().admin().indices().prepareCreate("index3").addAlias(new Alias("alias1").indexRouting("1").writeIndex(true)).get();
}
IndexResponse indexResponse = client().prepareIndex("index1", "type", "id").setSource(Collections.singletonMap("foo", "bar")).get();
IndexResponse indexResponse = client().prepareIndex("index1").setId("id").setSource(Collections.singletonMap("foo", "bar")).get();
assertThat(indexResponse.status().getStatus(), equalTo(RestStatus.CREATED.getStatus()));
IllegalArgumentException exception = expectThrows(
@ -244,7 +244,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
assertThat(response.getResponses()[0].getResponse().isExists(), equalTo(false));
for (int i = 0; i < 10; i++) {
client().prepareIndex("test", "type1", Integer.toString(i)).setSource("field", "value" + i).get();
client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", "value" + i).get();
}
response = client().prepareMultiGet()
@ -308,7 +308,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
assertThat(response.isExists(), equalTo(false));
assertThat(response.isExists(), equalTo(false));
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject().array("field", "1", "2").endObject()).get();
client().prepareIndex("test").setId("1").setSource(jsonBuilder().startObject().array("field", "1", "2").endObject()).get();
response = client().prepareGet("test", "1").setStoredFields("field").get();
assertThat(response.isExists(), equalTo(true));
@ -339,7 +339,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
assertThat(response.isExists(), equalTo(false));
logger.info("--> index doc 1");
client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2").get();
client().prepareIndex("test").setId("1").setSource("field1", "value1", "field2", "value2").get();
// From translog:
@ -383,7 +383,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
}
logger.info("--> index doc 1 again, so increasing the version");
client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2").get();
client().prepareIndex("test").setId("1").setSource("field1", "value1", "field2", "value2").get();
// From translog:
@ -438,7 +438,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
assertThat(response.getResponses()[0].getResponse().isExists(), equalTo(false));
for (int i = 0; i < 3; i++) {
client().prepareIndex("test", "type1", Integer.toString(i)).setSource("field", "value" + i).get();
client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", "value" + i).get();
}
// Version from translog
@ -488,7 +488,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
assertThat(response.getResponses()[2].getFailure().getFailure(), instanceOf(VersionConflictEngineException.class));
for (int i = 0; i < 3; i++) {
client().prepareIndex("test", "type1", Integer.toString(i)).setSource("field", "value" + i).get();
client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", "value" + i).get();
}
// Version from translog
@ -562,7 +562,8 @@ public class GetActionIT extends OpenSearchIntegTestCase {
.setSettings(Settings.builder().put("index.refresh_interval", -1))
);
client().prepareIndex("test", "my-type1", "1")
client().prepareIndex("test")
.setId("1")
.setSource(jsonBuilder().startObject().startObject("field1").field("field2", "value1").endObject().endObject())
.get();
@ -640,7 +641,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
logger.info("indexing documents");
client().prepareIndex("my-index", "my-type", "1").setSource(source, XContentType.JSON).get();
client().prepareIndex("my-index").setId("1").setSource(source, XContentType.JSON).get();
logger.info("checking real time retrieval");
@ -732,7 +733,7 @@ public class GetActionIT extends OpenSearchIntegTestCase {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setSource(createIndexSource, XContentType.JSON));
ensureGreen();
client().prepareIndex("test", "_doc", "1").setRouting("routingValue").setId("1").setSource("{}", XContentType.JSON).get();
client().prepareIndex("test").setId("1").setRouting("routingValue").setId("1").setSource("{}", XContentType.JSON).get();
String[] fieldsList = { "_routing" };
// before refresh - document is only in translog

View File

@ -203,7 +203,7 @@ public class FinalPipelineIT extends OpenSearchIntegTestCase {
// this asserts that the final_pipeline was used, without us having to actually create the pipeline etc.
final IllegalArgumentException e = expectThrows(
IllegalArgumentException.class,
() -> client().prepareIndex("index", "_doc", "1").setSource(Collections.singletonMap("field", "value")).get()
() -> client().prepareIndex("index").setId("1").setSource(Collections.singletonMap("field", "value")).get()
);
assertThat(e, hasToString(containsString("pipeline with id [final_pipeline] does not exist")));
}
@ -218,7 +218,7 @@ public class FinalPipelineIT extends OpenSearchIntegTestCase {
client().admin().cluster().putPipeline(new PutPipelineRequest("final_pipeline", finalPipelineBody, XContentType.JSON)).actionGet();
final Settings settings = Settings.builder().put(IndexSettings.FINAL_PIPELINE.getKey(), "final_pipeline").build();
createIndex("index", settings);
final IndexRequestBuilder index = client().prepareIndex("index", "_doc", "1");
final IndexRequestBuilder index = client().prepareIndex("index").setId("1");
index.setSource(Collections.singletonMap("field", "value"));
index.setPipeline("request_pipeline");
index.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
@ -247,7 +247,7 @@ public class FinalPipelineIT extends OpenSearchIntegTestCase {
.put(IndexSettings.FINAL_PIPELINE.getKey(), "final_pipeline")
.build();
createIndex("index", settings);
final IndexRequestBuilder index = client().prepareIndex("index", "_doc", "1");
final IndexRequestBuilder index = client().prepareIndex("index").setId("1");
index.setSource(Collections.singletonMap("field", "value"));
index.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
final IndexResponse response = index.get();
@ -297,7 +297,7 @@ public class FinalPipelineIT extends OpenSearchIntegTestCase {
.setOrder(finalPipelineOrder)
.setSettings(finalPipelineSettings)
.get();
final IndexRequestBuilder index = client().prepareIndex("index", "_doc", "1");
final IndexRequestBuilder index = client().prepareIndex("index").setId("1");
index.setSource(Collections.singletonMap("field", "value"));
index.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
final IndexResponse response = index.get();
@ -337,7 +337,7 @@ public class FinalPipelineIT extends OpenSearchIntegTestCase {
// this asserts that the high_order_final_pipeline was selected, without us having to actually create the pipeline etc.
final IllegalArgumentException e = expectThrows(
IllegalArgumentException.class,
() -> client().prepareIndex("index", "_doc", "1").setSource(Collections.singletonMap("field", "value")).get()
() -> client().prepareIndex("index").setId("1").setSource(Collections.singletonMap("field", "value")).get()
);
assertThat(e, hasToString(containsString("pipeline with id [high_order_final_pipeline] does not exist")));
}

View File

@ -94,7 +94,8 @@ public class IndexSortIT extends OpenSearchIntegTestCase {
.putList("index.sort.field", "date", "numeric_dv", "keyword_dv")
).addMapping("test", TEST_MAPPING).get();
for (int i = 0; i < 20; i++) {
client().prepareIndex("test", "test", Integer.toString(i))
client().prepareIndex("test")
.setId(Integer.toString(i))
.setSource("numeric_dv", randomInt(), "keyword_dv", randomAlphaOfLengthBetween(10, 20))
.get();
}

View File

@ -83,7 +83,8 @@ public class WaitUntilRefreshIT extends OpenSearchIntegTestCase {
}
public void testIndex() {
IndexResponse index = client().prepareIndex("test", "index", "1")
IndexResponse index = client().prepareIndex("test")
.setId("1")
.setSource("foo", "bar")
.setRefreshPolicy(RefreshPolicy.WAIT_UNTIL)
.get();
@ -94,7 +95,7 @@ public class WaitUntilRefreshIT extends OpenSearchIntegTestCase {
public void testDelete() throws InterruptedException, ExecutionException {
// Index normally
indexRandom(true, client().prepareIndex("test", "test", "1").setSource("foo", "bar"));
indexRandom(true, client().prepareIndex("test").setId("1").setSource("foo", "bar"));
assertSearchHits(client().prepareSearch("test").setQuery(matchQuery("foo", "bar")).get(), "1");
// Now delete with blockUntilRefresh
@ -106,7 +107,7 @@ public class WaitUntilRefreshIT extends OpenSearchIntegTestCase {
public void testUpdate() throws InterruptedException, ExecutionException {
// Index normally
indexRandom(true, client().prepareIndex("test", "test", "1").setSource("foo", "bar"));
indexRandom(true, client().prepareIndex("test").setId("1").setSource("foo", "bar"));
assertSearchHits(client().prepareSearch("test").setQuery(matchQuery("foo", "bar")).get(), "1");
// Update with RefreshPolicy.WAIT_UNTIL
@ -141,7 +142,7 @@ public class WaitUntilRefreshIT extends OpenSearchIntegTestCase {
public void testBulk() {
// Index by bulk with RefreshPolicy.WAIT_UNTIL
BulkRequestBuilder bulk = client().prepareBulk().setRefreshPolicy(RefreshPolicy.WAIT_UNTIL);
bulk.add(client().prepareIndex("test", "test", "1").setSource("foo", "bar"));
bulk.add(client().prepareIndex("test").setId("1").setSource("foo", "bar"));
assertBulkSuccess(bulk.get());
assertSearchHits(client().prepareSearch("test").setQuery(matchQuery("foo", "bar")).get(), "1");
@ -169,7 +170,8 @@ public class WaitUntilRefreshIT extends OpenSearchIntegTestCase {
*/
public void testNoRefreshInterval() throws InterruptedException, ExecutionException {
client().admin().indices().prepareUpdateSettings("test").setSettings(singletonMap("index.refresh_interval", -1)).get();
ActionFuture<IndexResponse> index = client().prepareIndex("test", "index", "1")
ActionFuture<IndexResponse> index = client().prepareIndex("test")
.setId("1")
.setSource("foo", "bar")
.setRefreshPolicy(RefreshPolicy.WAIT_UNTIL)
.execute();

View File

@ -60,7 +60,7 @@ public class FieldDataLoadingIT extends OpenSearchIntegTestCase {
);
ensureGreen();
client().prepareIndex("test", "type", "1").setSource("name", "name").get();
client().prepareIndex("test").setId("1").setSource("name", "name").get();
client().admin().indices().prepareRefresh("test").get();
ClusterStatsResponse response = client().admin().cluster().prepareClusterStats().get();

View File

@ -56,7 +56,7 @@ public class CopyToMapperIntegrationIT extends OpenSearchIntegTestCase {
int recordCount = between(1, 200);
for (int i = 0; i < recordCount * 2; i++) {
client().prepareIndex("test-idx", "_doc", Integer.toString(i)).setSource("test_field", "test " + i, "even", i % 2 == 0).get();
client().prepareIndex("test-idx").setId(Integer.toString(i)).setSource("test_field", "test " + i, "even", i % 2 == 0).get();
}
client().admin().indices().prepareRefresh("test-idx").execute().actionGet();
@ -92,7 +92,7 @@ public class CopyToMapperIntegrationIT extends OpenSearchIntegTestCase {
.endObject()
);
assertAcked(client().admin().indices().prepareCreate("test-idx").addMapping("_doc", mapping, XContentType.JSON));
client().prepareIndex("test-idx", "_doc", "1").setSource("foo", "bar").get();
client().prepareIndex("test-idx").setId("1").setSource("foo", "bar").get();
client().admin().indices().prepareRefresh("test-idx").execute().actionGet();
SearchResponse response = client().prepareSearch("test-idx").setQuery(QueryBuilders.termQuery("root.top.child", "bar")).get();
assertThat(response.getHits().getTotalHits().value, equalTo(1L));

View File

@ -68,9 +68,9 @@ public class DynamicMappingIT extends OpenSearchIntegTestCase {
public void testConflictingDynamicMappings() {
// we don't use indexRandom because the order of requests is important here
createIndex("index");
client().prepareIndex("index", "type", "1").setSource("foo", 3).get();
client().prepareIndex("index").setId("1").setSource("foo", 3).get();
try {
client().prepareIndex("index", "type", "2").setSource("foo", "bar").get();
client().prepareIndex("index").setId("2").setSource("foo", "bar").get();
fail("Indexing request should have failed!");
} catch (MapperParsingException e) {
// general case, the parsing code complains that it can't parse "bar" as a "long"
@ -86,10 +86,10 @@ public class DynamicMappingIT extends OpenSearchIntegTestCase {
public void testConflictingDynamicMappingsBulk() {
// we don't use indexRandom because the order of requests is important here
createIndex("index");
client().prepareIndex("index", "type", "1").setSource("foo", 3).get();
BulkResponse bulkResponse = client().prepareBulk().add(client().prepareIndex("index", "type", "1").setSource("foo", 3)).get();
client().prepareIndex("index").setId("1").setSource("foo", 3).get();
BulkResponse bulkResponse = client().prepareBulk().add(client().prepareIndex("index").setId("1").setSource("foo", 3)).get();
assertFalse(bulkResponse.hasFailures());
bulkResponse = client().prepareBulk().add(client().prepareIndex("index", "type", "2").setSource("foo", "bar")).get();
bulkResponse = client().prepareBulk().add(client().prepareIndex("index").setId("2").setSource("foo", "bar")).get();
assertTrue(bulkResponse.hasFailures());
}
@ -117,7 +117,7 @@ public class DynamicMappingIT extends OpenSearchIntegTestCase {
startLatch.await();
assertEquals(
DocWriteResponse.Result.CREATED,
client().prepareIndex("index", "type", id).setSource("field" + id, "bar").get().getResult()
client().prepareIndex("index").setId(id).setSource("field" + id, "bar").get().getResult()
);
} catch (Exception e) {
error.compareAndSet(null, e);

View File

@ -69,7 +69,7 @@ public class MultiFieldsIntegrationIT extends OpenSearchIntegTestCase {
assertThat(titleFields.get("not_analyzed"), notNullValue());
assertThat(((Map<String, Object>) titleFields.get("not_analyzed")).get("type").toString(), equalTo("keyword"));
client().prepareIndex("my-index", "my-type", "1").setSource("title", "Multi fields").setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("my-index").setId("1").setSource("title", "Multi fields").setRefreshPolicy(IMMEDIATE).get();
SearchResponse searchResponse = client().prepareSearch("my-index").setQuery(matchQuery("title", "multi")).get();
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
@ -90,7 +90,7 @@ public class MultiFieldsIntegrationIT extends OpenSearchIntegTestCase {
assertThat(titleFields.get("uncased"), notNullValue());
assertThat(((Map<String, Object>) titleFields.get("uncased")).get("analyzer").toString(), equalTo("whitespace"));
client().prepareIndex("my-index", "my-type", "1").setSource("title", "Multi fields").setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("my-index").setId("1").setSource("title", "Multi fields").setRefreshPolicy(IMMEDIATE).get();
searchResponse = client().prepareSearch("my-index").setQuery(matchQuery("title.uncased", "Multi")).get();
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
@ -115,7 +115,7 @@ public class MultiFieldsIntegrationIT extends OpenSearchIntegTestCase {
assertThat(bField.get("type").toString(), equalTo("keyword"));
GeoPoint point = new GeoPoint(51, 19);
client().prepareIndex("my-index", "my-type", "1").setSource("a", point.toString()).setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("my-index").setId("1").setSource("a", point.toString()).setRefreshPolicy(IMMEDIATE).get();
SearchResponse countResponse = client().prepareSearch("my-index")
.setSize(0)
.setQuery(constantScoreQuery(geoDistanceQuery("a").point(51, 19).distance(50, DistanceUnit.KILOMETERS)))
@ -142,7 +142,7 @@ public class MultiFieldsIntegrationIT extends OpenSearchIntegTestCase {
assertThat(bField.size(), equalTo(1));
assertThat(bField.get("type").toString(), equalTo("keyword"));
client().prepareIndex("my-index", "my-type", "1").setSource("a", "complete me").setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("my-index").setId("1").setSource("a", "complete me").setRefreshPolicy(IMMEDIATE).get();
SearchResponse countResponse = client().prepareSearch("my-index").setSize(0).setQuery(matchQuery("a.b", "complete me")).get();
assertThat(countResponse.getHits().getTotalHits().value, equalTo(1L));
}
@ -164,7 +164,7 @@ public class MultiFieldsIntegrationIT extends OpenSearchIntegTestCase {
assertThat(bField.size(), equalTo(1));
assertThat(bField.get("type").toString(), equalTo("keyword"));
client().prepareIndex("my-index", "my-type", "1").setSource("a", "127.0.0.1").setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("my-index").setId("1").setSource("a", "127.0.0.1").setRefreshPolicy(IMMEDIATE).get();
SearchResponse countResponse = client().prepareSearch("my-index").setSize(0).setQuery(matchQuery("a.b", "127.0.0.1")).get();
assertThat(countResponse.getHits().getTotalHits().value, equalTo(1L));
}

View File

@ -54,7 +54,7 @@ public class CustomQueryParserIT extends OpenSearchIntegTestCase {
super.setUp();
createIndex("test");
ensureGreen();
client().prepareIndex("index", "type", "1").setSource("field", "value").get();
client().prepareIndex("index").setId("1").setSource("field", "value").get();
refresh();
}

View File

@ -82,7 +82,7 @@ public class GlobalCheckpointSyncIT extends OpenSearchIntegTestCase {
for (int j = 0; j < 10; j++) {
final String id = Integer.toString(j);
client().prepareIndex("test", "test", id).setSource("{\"foo\": " + id + "}", XContentType.JSON).get();
client().prepareIndex("test").setId(id).setSource("{\"foo\": " + id + "}", XContentType.JSON).get();
}
assertBusy(() -> {
@ -194,7 +194,7 @@ public class GlobalCheckpointSyncIT extends OpenSearchIntegTestCase {
}
for (int j = 0; j < numberOfDocuments; j++) {
final String id = Integer.toString(index * numberOfDocuments + j);
client().prepareIndex("test", "test", id).setSource("{\"foo\": " + id + "}", XContentType.JSON).get();
client().prepareIndex("test").setId(id).setSource("{\"foo\": " + id + "}", XContentType.JSON).get();
}
try {
barrier.await();
@ -251,7 +251,7 @@ public class GlobalCheckpointSyncIT extends OpenSearchIntegTestCase {
}
int numDocs = randomIntBetween(1, 20);
for (int i = 0; i < numDocs; i++) {
client().prepareIndex("test", "test", Integer.toString(i)).setSource("{}", XContentType.JSON).get();
client().prepareIndex("test").setId(Integer.toString(i)).setSource("{}", XContentType.JSON).get();
}
ensureGreen("test");
assertBusy(() -> {

View File

@ -88,7 +88,7 @@ public class GlobalCheckpointListenersIT extends OpenSearchSingleNodeTestCase {
}
}, null);
client().prepareIndex("test", "_doc", Integer.toString(i)).setSource("{}", XContentType.JSON).get();
client().prepareIndex("test").setId(Integer.toString(i)).setSource("{}", XContentType.JSON).get();
assertBusy(() -> assertThat(globalCheckpoint.get(), equalTo((long) index)));
// adding a listener expecting a lower global checkpoint should fire immediately
final AtomicLong immediateGlobalCheckpint = new AtomicLong();

View File

@ -172,7 +172,7 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
public void testDurableFlagHasEffect() throws Exception {
createIndex("test");
ensureGreen();
client().prepareIndex("test", "bar", "1").setSource("{}", XContentType.JSON).get();
client().prepareIndex("test").setId("1").setSource("{}", XContentType.JSON).get();
IndicesService indicesService = getInstanceFromNode(IndicesService.class);
IndexService test = indicesService.indexService(resolveIndex("test"));
IndexShard shard = test.getShardOrNull(0);
@ -192,7 +192,7 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
setDurability(shard, Translog.Durability.REQUEST);
assertFalse(needsSync.test(translog));
setDurability(shard, Translog.Durability.ASYNC);
client().prepareIndex("test", "bar", "2").setSource("{}", XContentType.JSON).get();
client().prepareIndex("test").setId("2").setSource("{}", XContentType.JSON).get();
assertTrue(needsSync.test(translog));
setDurability(shard, Translog.Durability.REQUEST);
client().prepareDelete("test", "1").get();
@ -204,7 +204,7 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
setDurability(shard, Translog.Durability.REQUEST);
assertNoFailures(
client().prepareBulk()
.add(client().prepareIndex("test", "bar", "3").setSource("{}", XContentType.JSON))
.add(client().prepareIndex("test").setId("3").setSource("{}", XContentType.JSON))
.add(client().prepareDelete("test", "1"))
.get()
);
@ -213,7 +213,7 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
setDurability(shard, Translog.Durability.ASYNC);
assertNoFailures(
client().prepareBulk()
.add(client().prepareIndex("test", "bar", "4").setSource("{}", XContentType.JSON))
.add(client().prepareIndex("test").setId("4").setSource("{}", XContentType.JSON))
.add(client().prepareDelete("test", "3"))
.get()
);
@ -251,7 +251,7 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
Settings idxSettings = Settings.builder().put(IndexMetadata.SETTING_DATA_PATH, idxPath).build();
createIndex("test", idxSettings);
ensureGreen("test");
client().prepareIndex("test", "bar", "1").setSource("{}", XContentType.JSON).setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("test").setId("1").setSource("{}", XContentType.JSON).setRefreshPolicy(IMMEDIATE).get();
SearchResponse response = client().prepareSearch("test").get();
assertHitCount(response, 1L);
client().admin().indices().prepareDelete("test").get();
@ -286,7 +286,7 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
logger.info("--> creating index [{}] with data_path [{}]", index, indexDataPath);
createIndex(index, Settings.builder().put(IndexMetadata.SETTING_DATA_PATH, indexDataPath.toAbsolutePath().toString()).build());
client().prepareIndex(index, "bar", "1").setSource("foo", "bar").setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex(index).setId("1").setSource("foo", "bar").setRefreshPolicy(IMMEDIATE).get();
ensureGreen(index);
assertHitCount(client().prepareSearch(index).setSize(0).get(), 1L);
@ -384,7 +384,8 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
final Translog translog = getTranslog(shard);
assertEquals(2, translog.stats().getUncommittedOperations());
assertThat(shard.flushStats().getTotal(), equalTo(0L));
client().prepareIndex("test", "_doc", "2")
client().prepareIndex("test")
.setId("2")
.setSource("{}", XContentType.JSON)
.setRefreshPolicy(randomBoolean() ? IMMEDIATE : NONE)
.get();
@ -492,7 +493,8 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
settings = Settings.builder().put("index.translog.generation_threshold_size", "117b").build();
}
client().admin().indices().prepareUpdateSettings("test").setSettings(settings).get();
client().prepareIndex("test", "test", "0")
client().prepareIndex("test")
.setId("0")
.setSource("{}", XContentType.JSON)
.setRefreshPolicy(randomBoolean() ? IMMEDIATE : NONE)
.get();
@ -518,7 +520,7 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
final CheckedRunnable<Exception> check;
if (flush) {
final FlushStats initialStats = shard.flushStats();
client().prepareIndex("test", "test", "1").setSource("{}", XContentType.JSON).get();
client().prepareIndex("test").setId("1").setSource("{}", XContentType.JSON).get();
check = () -> {
assertFalse(shard.shouldPeriodicallyFlush());
final FlushStats currentStats = shard.flushStats();
@ -543,7 +545,7 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
};
} else {
final long generation = getTranslog(shard).currentFileGeneration();
client().prepareIndex("test", "test", "1").setSource("{}", XContentType.JSON).get();
client().prepareIndex("test").setId("1").setSource("{}", XContentType.JSON).get();
check = () -> {
assertFalse(shard.shouldRollTranslogGeneration());
assertEquals(generation + 1, getTranslog(shard).currentFileGeneration());
@ -564,7 +566,7 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
client().admin().indices().prepareUpdateSettings("test").setSettings(settings).get();
final int numDocs = between(10, 100);
for (int i = 0; i < numDocs; i++) {
client().prepareIndex("test", "doc", Integer.toString(i)).setSource("{}", XContentType.JSON).get();
client().prepareIndex("test").setId(Integer.toString(i)).setSource("{}", XContentType.JSON).get();
}
// A flush stats may include the new total count but the old period count - assert eventually.
assertBusy(() -> {
@ -575,7 +577,7 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
settings = Settings.builder().put("index.translog.flush_threshold_size", (String) null).build();
client().admin().indices().prepareUpdateSettings("test").setSettings(settings).get();
client().prepareIndex("test", "doc", UUIDs.randomBase64UUID()).setSource("{}", XContentType.JSON).get();
client().prepareIndex("test").setId(UUIDs.randomBase64UUID()).setSource("{}", XContentType.JSON).get();
client().admin().indices().prepareFlush("test").setForce(randomBoolean()).setWaitIfOngoing(true).get();
final FlushStats flushStats = client().admin().indices().prepareStats("test").clear().setFlush(true).get().getTotal().flush;
assertThat(flushStats.getTotal(), greaterThan(flushStats.getPeriodic()));
@ -587,9 +589,9 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
IndicesService indicesService = getInstanceFromNode(IndicesService.class);
IndexService indexService = indicesService.indexService(resolveIndex("test"));
IndexShard shard = indexService.getShardOrNull(0);
client().prepareIndex("test", "test", "0").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).get();
client().prepareIndex("test").setId("0").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).get();
client().prepareDelete("test", "0").get();
client().prepareIndex("test", "test", "1").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("test").setId("1").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).setRefreshPolicy(IMMEDIATE).get();
CheckedFunction<DirectoryReader, DirectoryReader, IOException> wrapper = directoryReader -> directoryReader;
shard.close("simon says", false);
@ -701,7 +703,7 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
final SearchRequest countRequest = new SearchRequest("test").source(new SearchSourceBuilder().size(0));
final long numDocs = between(10, 20);
for (int i = 0; i < numDocs; i++) {
client().prepareIndex("test", "_doc", Integer.toString(i)).setSource("{}", XContentType.JSON).get();
client().prepareIndex("test").setId(Integer.toString(i)).setSource("{}", XContentType.JSON).get();
if (randomBoolean()) {
shard.refresh("test");
}
@ -723,7 +725,7 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
final long moreDocs = between(10, 20);
for (int i = 0; i < moreDocs; i++) {
client().prepareIndex("test", "_doc", Long.toString(i + numDocs)).setSource("{}", XContentType.JSON).get();
client().prepareIndex("test").setId(Long.toString(i + numDocs)).setSource("{}", XContentType.JSON).get();
if (randomBoolean()) {
shard.refresh("test");
}
@ -754,9 +756,7 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
int numOps = between(1, 10);
for (int i = 0; i < numOps; i++) {
if (randomBoolean()) {
client().prepareIndex("index", randomFrom("_doc", "user_doc"), randomFrom("1", "2"))
.setSource("{}", XContentType.JSON)
.get();
client().prepareIndex("index").setId(randomFrom("1", "2")).setSource("{}", XContentType.JSON).get();
} else {
client().prepareDelete("index", randomFrom("1", "2")).get();
}
@ -819,7 +819,7 @@ public class IndexShardIT extends OpenSearchSingleNodeTestCase {
}
};
for (int i = 0; i < 100; i++) {
client().prepareIndex(indexName, "_doc", Integer.toString(i)).setSource("{}", XContentType.JSON).get();
client().prepareIndex(indexName).setId(Integer.toString(i)).setSource("{}", XContentType.JSON).get();
if (randomInt(100) < 10) {
client().admin().indices().prepareFlush(indexName).setWaitIfOngoing(true).get();
checkTranslog.run();

View File

@ -102,7 +102,7 @@ public class SearchIdleIT extends OpenSearchSingleNodeTestCase {
int numDocs = scaledRandomIntBetween(25, 100);
totalNumDocs.set(numDocs);
CountDownLatch indexingDone = new CountDownLatch(numDocs);
client().prepareIndex("test", "test", "0").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).get();
client().prepareIndex("test").setId("0").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).get();
indexingDone.countDown(); // one doc is indexed above blocking
IndexShard shard = indexService.getShard(0);
boolean hasRefreshed = shard.scheduledRefresh();
@ -133,7 +133,8 @@ public class SearchIdleIT extends OpenSearchSingleNodeTestCase {
started.await();
assertThat(count.applyAsLong(totalNumDocs.get()), equalTo(1L));
for (int i = 1; i < numDocs; i++) {
client().prepareIndex("test", "test", "" + i)
client().prepareIndex("test")
.setId("" + i)
.setSource("{\"foo\" : \"bar\"}", XContentType.JSON)
.execute(new ActionListener<IndexResponse>() {
@Override
@ -158,7 +159,7 @@ public class SearchIdleIT extends OpenSearchSingleNodeTestCase {
IndexService indexService = createIndex("test", builder.build());
assertFalse(indexService.getIndexSettings().isExplicitRefresh());
ensureGreen();
client().prepareIndex("test", "test", "0").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).get();
client().prepareIndex("test").setId("0").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).get();
IndexShard shard = indexService.getShard(0);
assertFalse(shard.scheduledRefresh());
assertTrue(shard.isSearchIdle());
@ -166,7 +167,7 @@ public class SearchIdleIT extends OpenSearchSingleNodeTestCase {
client().admin().indices().prepareRefresh().execute(ActionListener.wrap(refreshLatch::countDown));// async on purpose to make sure
// it happens concurrently
assertHitCount(client().prepareSearch().get(), 1);
client().prepareIndex("test", "test", "1").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).get();
client().prepareIndex("test").setId("1").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).get();
assertFalse(shard.scheduledRefresh());
assertTrue(shard.hasRefreshPending());
@ -185,7 +186,7 @@ public class SearchIdleIT extends OpenSearchSingleNodeTestCase {
// We need to ensure a `scheduledRefresh` triggered by the internal refresh setting update is executed before we index a new doc;
// otherwise, it will compete to call `Engine#maybeRefresh` with the `scheduledRefresh` that we are going to verify.
ensureNoPendingScheduledRefresh(indexService.getThreadPool());
client().prepareIndex("test", "test", "2").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).get();
client().prepareIndex("test").setId("2").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).get();
assertTrue(shard.scheduledRefresh());
assertFalse(shard.hasRefreshPending());
assertTrue(shard.isSearchIdle());

View File

@ -128,15 +128,15 @@ public class IndexActionIT extends OpenSearchIntegTestCase {
createIndex("test");
ensureGreen();
IndexResponse indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").execute().actionGet();
IndexResponse indexResponse = client().prepareIndex("test").setId("1").setSource("field1", "value1_1").execute().actionGet();
assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult());
indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_2").execute().actionGet();
indexResponse = client().prepareIndex("test").setId("1").setSource("field1", "value1_2").execute().actionGet();
assertEquals(DocWriteResponse.Result.UPDATED, indexResponse.getResult());
client().prepareDelete("test", "1").execute().actionGet();
indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_2").execute().actionGet();
indexResponse = client().prepareIndex("test").setId("1").setSource("field1", "value1_2").execute().actionGet();
assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult());
}
@ -145,14 +145,14 @@ public class IndexActionIT extends OpenSearchIntegTestCase {
createIndex("test");
ensureGreen();
IndexResponse indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").execute().actionGet();
IndexResponse indexResponse = client().prepareIndex("test").setId("1").setSource("field1", "value1_1").execute().actionGet();
assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult());
client().prepareDelete("test", "1").execute().actionGet();
flush();
indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_2").execute().actionGet();
indexResponse = client().prepareIndex("test").setId("1").setSource("field1", "value1_2").execute().actionGet();
assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult());
}
@ -194,7 +194,8 @@ public class IndexActionIT extends OpenSearchIntegTestCase {
createIndex("test");
ensureGreen();
IndexResponse indexResponse = client().prepareIndex("test", "type", "1")
IndexResponse indexResponse = client().prepareIndex("test")
.setId("1")
.setSource("field1", "value1_1")
.setVersion(123)
.setVersionType(VersionType.EXTERNAL)
@ -208,7 +209,7 @@ public class IndexActionIT extends OpenSearchIntegTestCase {
ensureGreen();
BulkResponse bulkResponse = client().prepareBulk()
.add(client().prepareIndex("test", "type", "1").setSource("field1", "value1_1"))
.add(client().prepareIndex("test").setId("1").setSource("field1", "value1_1"))
.execute()
.actionGet();
assertThat(bulkResponse.hasFailures(), equalTo(false));
@ -289,7 +290,7 @@ public class IndexActionIT extends OpenSearchIntegTestCase {
public void testDocumentWithBlankFieldName() {
MapperParsingException e = expectThrows(
MapperParsingException.class,
() -> { client().prepareIndex("test", "type", "1").setSource("", "value1_2").execute().actionGet(); }
() -> { client().prepareIndex("test").setId("1").setSource("", "value1_2").execute().actionGet(); }
);
assertThat(e.getMessage(), containsString("failed to parse"));
assertThat(e.getRootCause().getMessage(), containsString("field name cannot be an empty string"));

View File

@ -71,9 +71,9 @@ public class DateMathIndexExpressionsIntegrationIT extends OpenSearchIntegTestCa
String dateMathExp1 = "<.marvel-{now/d}>";
String dateMathExp2 = "<.marvel-{now/d-1d}>";
String dateMathExp3 = "<.marvel-{now/d-2d}>";
client().prepareIndex(dateMathExp1, "type", "1").setSource("{}", XContentType.JSON).get();
client().prepareIndex(dateMathExp2, "type", "2").setSource("{}", XContentType.JSON).get();
client().prepareIndex(dateMathExp3, "type", "3").setSource("{}", XContentType.JSON).get();
client().prepareIndex(dateMathExp1).setId("1").setSource("{}", XContentType.JSON).get();
client().prepareIndex(dateMathExp2).setId("2").setSource("{}", XContentType.JSON).get();
client().prepareIndex(dateMathExp3).setId("3").setSource("{}", XContentType.JSON).get();
refresh();
SearchResponse searchResponse = client().prepareSearch(dateMathExp1, dateMathExp2, dateMathExp3).get();
@ -131,9 +131,9 @@ public class DateMathIndexExpressionsIntegrationIT extends OpenSearchIntegTestCa
String dateMathExp1 = "<.marvel-{now/d}>";
String dateMathExp2 = "<.marvel-{now/d-1d}>";
String dateMathExp3 = "<.marvel-{now/d-2d}>";
client().prepareIndex(dateMathExp1, "type", "1").setSource("{}", XContentType.JSON).get();
client().prepareIndex(dateMathExp2, "type", "2").setSource("{}", XContentType.JSON).get();
client().prepareIndex(dateMathExp3, "type", "3").setSource("{}", XContentType.JSON).get();
client().prepareIndex(dateMathExp1).setId("1").setSource("{}", XContentType.JSON).get();
client().prepareIndex(dateMathExp2).setId("2").setSource("{}", XContentType.JSON).get();
client().prepareIndex(dateMathExp3).setId("3").setSource("{}", XContentType.JSON).get();
refresh();
SearchResponse searchResponse = client().prepareSearch(dateMathExp1, dateMathExp2, dateMathExp3).get();

View File

@ -361,7 +361,7 @@ public class IndicesOptionsIntegrationIT extends OpenSearchIntegTestCase {
verify(getSettings(indices).setIndicesOptions(options), false);
assertAcked(prepareCreate("foobar"));
client().prepareIndex("foobar", "type", "1").setSource("k", "v").setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("foobar").setId("1").setSource("k", "v").setRefreshPolicy(IMMEDIATE).get();
// Verify defaults for wildcards, with one wildcard expression and one existing index
indices = new String[] { "foo*" };
@ -455,7 +455,7 @@ public class IndicesOptionsIntegrationIT extends OpenSearchIntegTestCase {
public void testAllMissingLenient() throws Exception {
createIndex("test1");
client().prepareIndex("test1", "type", "1").setSource("k", "v").setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("test1").setId("1").setSource("k", "v").setRefreshPolicy(IMMEDIATE).get();
SearchResponse response = client().prepareSearch("test2")
.setIndicesOptions(IndicesOptions.lenientExpandOpen())
.setQuery(matchAllQuery())

View File

@ -149,15 +149,15 @@ public class IndicesRequestCacheIT extends OpenSearchIntegTestCase {
);
indexRandom(
true,
client.prepareIndex("index", "type", "1").setRouting("1").setSource("s", "2016-03-19"),
client.prepareIndex("index", "type", "2").setRouting("1").setSource("s", "2016-03-20"),
client.prepareIndex("index", "type", "3").setRouting("1").setSource("s", "2016-03-21"),
client.prepareIndex("index", "type", "4").setRouting("2").setSource("s", "2016-03-22"),
client.prepareIndex("index", "type", "5").setRouting("2").setSource("s", "2016-03-23"),
client.prepareIndex("index", "type", "6").setRouting("2").setSource("s", "2016-03-24"),
client.prepareIndex("index", "type", "7").setRouting("3").setSource("s", "2016-03-25"),
client.prepareIndex("index", "type", "8").setRouting("3").setSource("s", "2016-03-26"),
client.prepareIndex("index", "type", "9").setRouting("3").setSource("s", "2016-03-27")
client.prepareIndex("index").setId("1").setRouting("1").setSource("s", "2016-03-19"),
client.prepareIndex("index").setId("2").setRouting("1").setSource("s", "2016-03-20"),
client.prepareIndex("index").setId("3").setRouting("1").setSource("s", "2016-03-21"),
client.prepareIndex("index").setId("4").setRouting("2").setSource("s", "2016-03-22"),
client.prepareIndex("index").setId("5").setRouting("2").setSource("s", "2016-03-23"),
client.prepareIndex("index").setId("6").setRouting("2").setSource("s", "2016-03-24"),
client.prepareIndex("index").setId("7").setRouting("3").setSource("s", "2016-03-25"),
client.prepareIndex("index").setId("8").setRouting("3").setSource("s", "2016-03-26"),
client.prepareIndex("index").setId("9").setRouting("3").setSource("s", "2016-03-27")
);
ensureSearchable("index");
assertCacheState(client, "index", 0, 0);
@ -219,15 +219,15 @@ public class IndicesRequestCacheIT extends OpenSearchIntegTestCase {
);
indexRandom(
true,
client.prepareIndex("index", "type", "1").setSource("s", "2016-03-19"),
client.prepareIndex("index", "type", "2").setSource("s", "2016-03-20"),
client.prepareIndex("index", "type", "3").setSource("s", "2016-03-21"),
client.prepareIndex("index", "type", "4").setSource("s", "2016-03-22"),
client.prepareIndex("index", "type", "5").setSource("s", "2016-03-23"),
client.prepareIndex("index", "type", "6").setSource("s", "2016-03-24"),
client.prepareIndex("index", "type", "7").setSource("other", "value"),
client.prepareIndex("index", "type", "8").setSource("s", "2016-03-26"),
client.prepareIndex("index", "type", "9").setSource("s", "2016-03-27")
client.prepareIndex("index").setId("1").setSource("s", "2016-03-19"),
client.prepareIndex("index").setId("2").setSource("s", "2016-03-20"),
client.prepareIndex("index").setId("3").setSource("s", "2016-03-21"),
client.prepareIndex("index").setId("4").setSource("s", "2016-03-22"),
client.prepareIndex("index").setId("5").setSource("s", "2016-03-23"),
client.prepareIndex("index").setId("6").setSource("s", "2016-03-24"),
client.prepareIndex("index").setId("7").setSource("other", "value"),
client.prepareIndex("index").setId("8").setSource("s", "2016-03-26"),
client.prepareIndex("index").setId("9").setSource("s", "2016-03-27")
);
ensureSearchable("index");
assertCacheState(client, "index", 0, 0);
@ -285,15 +285,15 @@ public class IndicesRequestCacheIT extends OpenSearchIntegTestCase {
);
indexRandom(
true,
client.prepareIndex("index", "type", "1").setSource("d", "2014-01-01T00:00:00"),
client.prepareIndex("index", "type", "2").setSource("d", "2014-02-01T00:00:00"),
client.prepareIndex("index", "type", "3").setSource("d", "2014-03-01T00:00:00"),
client.prepareIndex("index", "type", "4").setSource("d", "2014-04-01T00:00:00"),
client.prepareIndex("index", "type", "5").setSource("d", "2014-05-01T00:00:00"),
client.prepareIndex("index", "type", "6").setSource("d", "2014-06-01T00:00:00"),
client.prepareIndex("index", "type", "7").setSource("d", "2014-07-01T00:00:00"),
client.prepareIndex("index", "type", "8").setSource("d", "2014-08-01T00:00:00"),
client.prepareIndex("index", "type", "9").setSource("d", "2014-09-01T00:00:00")
client.prepareIndex("index").setId("1").setSource("d", "2014-01-01T00:00:00"),
client.prepareIndex("index").setId("2").setSource("d", "2014-02-01T00:00:00"),
client.prepareIndex("index").setId("3").setSource("d", "2014-03-01T00:00:00"),
client.prepareIndex("index").setId("4").setSource("d", "2014-04-01T00:00:00"),
client.prepareIndex("index").setId("5").setSource("d", "2014-05-01T00:00:00"),
client.prepareIndex("index").setId("6").setSource("d", "2014-06-01T00:00:00"),
client.prepareIndex("index").setId("7").setSource("d", "2014-07-01T00:00:00"),
client.prepareIndex("index").setId("8").setSource("d", "2014-08-01T00:00:00"),
client.prepareIndex("index").setId("9").setSource("d", "2014-09-01T00:00:00")
);
ensureSearchable("index");
assertCacheState(client, "index", 0, 0);
@ -352,15 +352,15 @@ public class IndicesRequestCacheIT extends OpenSearchIntegTestCase {
DateFormatter formatter = DateFormatter.forPattern("strict_date_optional_time");
indexRandom(
true,
client.prepareIndex("index-1", "type", "1").setSource("d", formatter.format(now)),
client.prepareIndex("index-1", "type", "2").setSource("d", formatter.format(now.minusDays(1))),
client.prepareIndex("index-1", "type", "3").setSource("d", formatter.format(now.minusDays(2))),
client.prepareIndex("index-2", "type", "4").setSource("d", formatter.format(now.minusDays(3))),
client.prepareIndex("index-2", "type", "5").setSource("d", formatter.format(now.minusDays(4))),
client.prepareIndex("index-2", "type", "6").setSource("d", formatter.format(now.minusDays(5))),
client.prepareIndex("index-3", "type", "7").setSource("d", formatter.format(now.minusDays(6))),
client.prepareIndex("index-3", "type", "8").setSource("d", formatter.format(now.minusDays(7))),
client.prepareIndex("index-3", "type", "9").setSource("d", formatter.format(now.minusDays(8)))
client.prepareIndex("index-1").setId("1").setSource("d", formatter.format(now)),
client.prepareIndex("index-1").setId("2").setSource("d", formatter.format(now.minusDays(1))),
client.prepareIndex("index-1").setId("3").setSource("d", formatter.format(now.minusDays(2))),
client.prepareIndex("index-2").setId("4").setSource("d", formatter.format(now.minusDays(3))),
client.prepareIndex("index-2").setId("5").setSource("d", formatter.format(now.minusDays(4))),
client.prepareIndex("index-2").setId("6").setSource("d", formatter.format(now.minusDays(5))),
client.prepareIndex("index-3").setId("7").setSource("d", formatter.format(now.minusDays(6))),
client.prepareIndex("index-3").setId("8").setSource("d", formatter.format(now.minusDays(7))),
client.prepareIndex("index-3").setId("9").setSource("d", formatter.format(now.minusDays(8)))
);
ensureSearchable("index-1", "index-2", "index-3");
assertCacheState(client, "index-1", 0, 0);
@ -429,15 +429,15 @@ public class IndicesRequestCacheIT extends OpenSearchIntegTestCase {
assertAcked(client.admin().indices().prepareCreate("index").addMapping("type", "s", "type=date").setSettings(settings).get());
indexRandom(
true,
client.prepareIndex("index", "type", "1").setRouting("1").setSource("s", "2016-03-19"),
client.prepareIndex("index", "type", "2").setRouting("1").setSource("s", "2016-03-20"),
client.prepareIndex("index", "type", "3").setRouting("1").setSource("s", "2016-03-21"),
client.prepareIndex("index", "type", "4").setRouting("2").setSource("s", "2016-03-22"),
client.prepareIndex("index", "type", "5").setRouting("2").setSource("s", "2016-03-23"),
client.prepareIndex("index", "type", "6").setRouting("2").setSource("s", "2016-03-24"),
client.prepareIndex("index", "type", "7").setRouting("3").setSource("s", "2016-03-25"),
client.prepareIndex("index", "type", "8").setRouting("3").setSource("s", "2016-03-26"),
client.prepareIndex("index", "type", "9").setRouting("3").setSource("s", "2016-03-27")
client.prepareIndex("index").setId("1").setRouting("1").setSource("s", "2016-03-19"),
client.prepareIndex("index").setId("2").setRouting("1").setSource("s", "2016-03-20"),
client.prepareIndex("index").setId("3").setRouting("1").setSource("s", "2016-03-21"),
client.prepareIndex("index").setId("4").setRouting("2").setSource("s", "2016-03-22"),
client.prepareIndex("index").setId("5").setRouting("2").setSource("s", "2016-03-23"),
client.prepareIndex("index").setId("6").setRouting("2").setSource("s", "2016-03-24"),
client.prepareIndex("index").setId("7").setRouting("3").setSource("s", "2016-03-25"),
client.prepareIndex("index").setId("8").setRouting("3").setSource("s", "2016-03-26"),
client.prepareIndex("index").setId("9").setRouting("3").setSource("s", "2016-03-27")
);
ensureSearchable("index");
assertCacheState(client, "index", 0, 0);
@ -535,10 +535,7 @@ public class IndicesRequestCacheIT extends OpenSearchIntegTestCase {
.get()
);
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
client.prepareIndex("index", "type", "1")
.setRouting("1")
.setSource("created_at", DateTimeFormatter.ISO_LOCAL_DATE.format(now))
.get();
client.prepareIndex("index").setId("1").setRouting("1").setSource("created_at", DateTimeFormatter.ISO_LOCAL_DATE.format(now)).get();
// Force merge the index to ensure there can be no background merges during the subsequent searches that would invalidate the cache
ForceMergeResponse forceMergeResponse = client.admin().indices().prepareForceMerge("index").setFlush(true).get();
OpenSearchAssertions.assertAllSuccessful(forceMergeResponse);

View File

@ -80,7 +80,8 @@ public class ConcurrentDynamicTemplateIT extends OpenSearchIntegTestCase {
for (int j = 0; j < numDocs; j++) {
Map<String, Object> source = new HashMap<>();
source.put(fieldName, "test-user");
client().prepareIndex("test", mappingType, Integer.toString(currentID++))
client().prepareIndex("test")
.setId(Integer.toString(currentID++))
.setSource(source)
.execute(new ActionListener<IndexResponse>() {
@Override

View File

@ -112,7 +112,8 @@ public class UpdateMappingIntegrationIT extends OpenSearchIntegTestCase {
String type = "type";
String fieldName = "field_" + type + "_" + rec;
indexRequests.add(
client().prepareIndex("test", type, Integer.toString(rec))
client().prepareIndex("test")
.setId(Integer.toString(rec))
.setTimeout(TimeValue.timeValueMinutes(5))
.setSource(fieldName, "some_value")
);

View File

@ -70,7 +70,7 @@ public class CircuitBreakerNoopIT extends OpenSearchIntegTestCase {
int docCount = scaledRandomIntBetween(300, 1000);
List<IndexRequestBuilder> reqs = new ArrayList<>();
for (long id = 0; id < docCount; id++) {
reqs.add(client.prepareIndex("cb-test", "type", Long.toString(id)).setSource("test", id));
reqs.add(client.prepareIndex("cb-test").setId(Long.toString(id)).setSource("test", id));
}
indexRandom(true, reqs);
@ -87,7 +87,7 @@ public class CircuitBreakerNoopIT extends OpenSearchIntegTestCase {
int docCount = scaledRandomIntBetween(300, 1000);
List<IndexRequestBuilder> reqs = new ArrayList<>();
for (long id = 0; id < docCount; id++) {
reqs.add(client.prepareIndex("cb-test", "type", Long.toString(id)).setSource("test", id));
reqs.add(client.prepareIndex("cb-test").setId(Long.toString(id)).setSource("test", id));
}
indexRandom(true, reqs);

View File

@ -154,7 +154,7 @@ public class CircuitBreakerServiceIT extends OpenSearchIntegTestCase {
int docCount = scaledRandomIntBetween(300, 1000);
List<IndexRequestBuilder> reqs = new ArrayList<>();
for (long id = 0; id < docCount; id++) {
reqs.add(client.prepareIndex("cb-test", "type", Long.toString(id)).setSource("test", "value" + id));
reqs.add(client.prepareIndex("cb-test").setId(Long.toString(id)).setSource("test", "value" + id));
}
indexRandom(true, false, true, reqs);
@ -208,7 +208,7 @@ public class CircuitBreakerServiceIT extends OpenSearchIntegTestCase {
int docCount = scaledRandomIntBetween(300, 1000);
List<IndexRequestBuilder> reqs = new ArrayList<>();
for (long id = 0; id < docCount; id++) {
reqs.add(client.prepareIndex("ramtest", "type", Long.toString(id)).setSource("test", "value" + id));
reqs.add(client.prepareIndex("ramtest").setId(Long.toString(id)).setSource("test", "value" + id));
}
indexRandom(true, false, true, reqs);
@ -261,7 +261,7 @@ public class CircuitBreakerServiceIT extends OpenSearchIntegTestCase {
int docCount = scaledRandomIntBetween(300, 1000);
List<IndexRequestBuilder> reqs = new ArrayList<>();
for (long id = 0; id < docCount; id++) {
reqs.add(client.prepareIndex("cb-test", "type", Long.toString(id)).setSource("test", id));
reqs.add(client.prepareIndex("cb-test").setId(Long.toString(id)).setSource("test", id));
}
indexRandom(true, reqs);
@ -295,7 +295,7 @@ public class CircuitBreakerServiceIT extends OpenSearchIntegTestCase {
int docCount = scaledRandomIntBetween(100, 1000);
List<IndexRequestBuilder> reqs = new ArrayList<>();
for (long id = 0; id < docCount; id++) {
reqs.add(client.prepareIndex("cb-test", "type", Long.toString(id)).setSource("test", id));
reqs.add(client.prepareIndex("cb-test").setId(Long.toString(id)).setSource("test", id));
}
indexRandom(true, reqs);

View File

@ -169,7 +169,8 @@ public class RandomExceptionCircuitBreakerIT extends OpenSearchIntegTestCase {
}
for (int i = 0; i < numDocs; i++) {
try {
client().prepareIndex("test", "type", "" + i)
client().prepareIndex("test")
.setId("" + i)
.setTimeout(TimeValue.timeValueSeconds(1))
.setSource("test-str", randomUnicodeOfLengthBetween(5, 25), "test-num", i)
.get();

View File

@ -71,7 +71,7 @@ public class IndexPrimaryRelocationIT extends OpenSearchIntegTestCase {
@Override
public void run() {
while (finished.get() == false && numAutoGenDocs.get() < 10_000) {
IndexResponse indexResponse = client().prepareIndex("test", "type", "id").setSource("field", "value").get();
IndexResponse indexResponse = client().prepareIndex("test").setId("id").setSource("field", "value").get();
assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult());
DeleteResponse deleteResponse = client().prepareDelete("test", "id").get();
assertEquals(DocWriteResponse.Result.DELETED, deleteResponse.getResult());

View File

@ -1442,7 +1442,8 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase {
.get();
int numDocs = between(1, 10);
for (int i = 0; i < numDocs; i++) {
client().prepareIndex("test", "_doc", "u" + i)
client().prepareIndex("test")
.setId("u" + i)
.setSource(singletonMap("test_field", Integer.toString(i)), XContentType.JSON)
.get();
}

View File

@ -80,7 +80,8 @@ public class UpdateNumberOfReplicasIT extends OpenSearchIntegTestCase {
assertThat(clusterHealth.getIndices().get("test").getActiveShards(), equalTo(numShards.totalNumShards));
for (int i = 0; i < 10; i++) {
client().prepareIndex("test", "type1", Integer.toString(i))
client().prepareIndex("test")
.setId(Integer.toString(i))
.setSource(jsonBuilder().startObject().field("value", "test" + i).endObject())
.get();
}

View File

@ -506,11 +506,11 @@ 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().prepareIndex("test").setId("1").setSource("f", 1).setVersionType(VersionType.EXTERNAL).setVersion(1).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),
client().prepareIndex("test").setId("1").setSource("f", 3).setVersionType(VersionType.EXTERNAL).setVersion(1),
VersionConflictEngineException.class
);
assertAcked(client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().put("index.gc_deletes", 0)));
@ -524,7 +524,7 @@ public class UpdateSettingsIT extends OpenSearchIntegTestCase {
}
// delete should not be in cache
client().prepareIndex("test", "type", "1").setSource("f", 2).setVersionType(VersionType.EXTERNAL).setVersion(1);
client().prepareIndex("test").setId("1").setSource("f", 2).setVersionType(VersionType.EXTERNAL).setVersion(1);
}
public void testUpdateSettingsWithBlocks() {

View File

@ -143,7 +143,7 @@ public class CloseIndexIT extends OpenSearchIntegTestCase {
false,
randomBoolean(),
IntStream.range(0, nbDocs)
.mapToObj(i -> client().prepareIndex(indexName, "_doc", String.valueOf(i)).setSource("num", i))
.mapToObj(i -> client().prepareIndex(indexName).setId(String.valueOf(i)).setSource("num", i))
.collect(toList())
);
@ -164,7 +164,7 @@ public class CloseIndexIT extends OpenSearchIntegTestCase {
false,
randomBoolean(),
IntStream.range(0, randomIntBetween(1, 10))
.mapToObj(i -> client().prepareIndex(indexName, "_doc", String.valueOf(i)).setSource("num", i))
.mapToObj(i -> client().prepareIndex(indexName).setId(String.valueOf(i)).setSource("num", i))
.collect(toList())
);
}
@ -207,7 +207,7 @@ public class CloseIndexIT extends OpenSearchIntegTestCase {
false,
randomBoolean(),
IntStream.range(0, nbDocs)
.mapToObj(i -> client().prepareIndex(indexName, "_doc", String.valueOf(i)).setSource("num", i))
.mapToObj(i -> client().prepareIndex(indexName).setId(String.valueOf(i)).setSource("num", i))
.collect(toList())
);
ensureYellowAndNoInitializingShards(indexName);
@ -268,7 +268,7 @@ public class CloseIndexIT extends OpenSearchIntegTestCase {
false,
randomBoolean(),
IntStream.range(0, 10)
.mapToObj(n -> client().prepareIndex(indexName, "_doc", String.valueOf(n)).setSource("num", n))
.mapToObj(n -> client().prepareIndex(indexName).setId(String.valueOf(n)).setSource("num", n))
.collect(toList())
);
}
@ -395,7 +395,7 @@ public class CloseIndexIT extends OpenSearchIntegTestCase {
false,
randomBoolean(),
IntStream.range(0, nbDocs)
.mapToObj(i -> client().prepareIndex(indexName, "_doc", String.valueOf(i)).setSource("num", i))
.mapToObj(i -> client().prepareIndex(indexName).setId(String.valueOf(i)).setSource("num", i))
.collect(toList())
);
ensureGreen(indexName);

View File

@ -320,7 +320,7 @@ public class OpenCloseIndexIT extends OpenSearchIntegTestCase {
int docs = between(10, 100);
IndexRequestBuilder[] builder = new IndexRequestBuilder[docs];
for (int i = 0; i < docs; i++) {
builder[i] = client().prepareIndex("test", "type", "" + i).setSource("test", "init");
builder[i] = client().prepareIndex("test").setId("" + i).setSource("test", "init");
}
indexRandom(true, builder);
if (randomBoolean()) {
@ -342,7 +342,7 @@ public class OpenCloseIndexIT extends OpenSearchIntegTestCase {
int docs = between(10, 100);
for (int i = 0; i < docs; i++) {
client().prepareIndex("test", "type", "" + i).setSource("test", "init").execute().actionGet();
client().prepareIndex("test").setId("" + i).setSource("test", "init").execute().actionGet();
}
for (String blockSetting : Arrays.asList(SETTING_BLOCKS_READ, SETTING_BLOCKS_WRITE)) {
@ -398,7 +398,7 @@ public class OpenCloseIndexIT extends OpenSearchIntegTestCase {
final int nbDocs = randomIntBetween(0, 50);
int uncommittedOps = 0;
for (long i = 0; i < nbDocs; i++) {
final IndexResponse indexResponse = client().prepareIndex(indexName, "_doc", Long.toString(i)).setSource("field", i).get();
final IndexResponse indexResponse = client().prepareIndex(indexName).setId(Long.toString(i)).setSource("field", i).get();
assertThat(indexResponse.status(), is(RestStatus.CREATED));
if (rarely()) {

View File

@ -75,7 +75,7 @@ public class SimpleIndexStateIT extends OpenSearchIntegTestCase {
);
logger.info("--> indexing a simple document");
client().prepareIndex("test", "type1", "1").setSource("field1", "value1").get();
client().prepareIndex("test").setId("1").setSource("field1", "value1").get();
logger.info("--> closing test index...");
assertAcked(client().admin().indices().prepareClose("test"));
@ -86,7 +86,7 @@ public class SimpleIndexStateIT extends OpenSearchIntegTestCase {
logger.info("--> trying to index into a closed index ...");
try {
client().prepareIndex("test", "type1", "1").setSource("field1", "value1").get();
client().prepareIndex("test").setId("1").setSource("field1", "value1").get();
fail();
} catch (IndexClosedException e) {
// all is well
@ -109,7 +109,7 @@ public class SimpleIndexStateIT extends OpenSearchIntegTestCase {
);
logger.info("--> indexing a simple document");
client().prepareIndex("test", "type1", "1").setSource("field1", "value1").get();
client().prepareIndex("test").setId("1").setSource("field1", "value1").get();
}
public void testFastCloseAfterCreateContinuesCreateAfterOpen() {
@ -150,7 +150,7 @@ public class SimpleIndexStateIT extends OpenSearchIntegTestCase {
);
logger.info("--> indexing a simple document");
client().prepareIndex("test", "type1", "1").setSource("field1", "value1").get();
client().prepareIndex("test").setId("1").setSource("field1", "value1").get();
}
public void testConsistencyAfterIndexCreationFailure() {

View File

@ -152,8 +152,8 @@ public class IndexStatsIT extends OpenSearchIntegTestCase {
.get()
);
ensureGreen();
client().prepareIndex("test", "type", "1").setSource("field", "value1", "field2", "value1").execute().actionGet();
client().prepareIndex("test", "type", "2").setSource("field", "value2", "field2", "value2").execute().actionGet();
client().prepareIndex("test").setId("1").setSource("field", "value1", "field2", "value1").execute().actionGet();
client().prepareIndex("test").setId("2").setSource("field", "value2", "field2", "value2").execute().actionGet();
client().admin().indices().prepareRefresh().execute().actionGet();
NodesStatsResponse nodesStats = client().admin().cluster().prepareNodesStats("data:true").setIndices(true).execute().actionGet();
@ -275,8 +275,8 @@ public class IndexStatsIT extends OpenSearchIntegTestCase {
);
ensureGreen();
client().admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
client().prepareIndex("test", "type", "1").setSource("field", "value1").execute().actionGet();
client().prepareIndex("test", "type", "2").setSource("field", "value2").execute().actionGet();
client().prepareIndex("test").setId("1").setSource("field", "value1").execute().actionGet();
client().prepareIndex("test").setId("2").setSource("field", "value2").execute().actionGet();
client().admin().indices().prepareRefresh().execute().actionGet();
NodesStatsResponse nodesStats = client().admin().cluster().prepareNodesStats("data:true").setIndices(true).execute().actionGet();
@ -385,7 +385,8 @@ public class IndexStatsIT extends OpenSearchIntegTestCase {
while (true) {
IndexRequestBuilder[] builders = new IndexRequestBuilder[pageDocs];
for (int i = 0; i < pageDocs; ++i) {
builders[i] = client().prepareIndex("idx", "type", Integer.toString(counter++))
builders[i] = client().prepareIndex("idx")
.setId(Integer.toString(counter++))
.setSource(jsonBuilder().startObject().field("common", "field").field("str_value", "s" + i).endObject());
}
indexRandom(true, builders);
@ -445,7 +446,8 @@ public class IndexStatsIT extends OpenSearchIntegTestCase {
// index the data again...
IndexRequestBuilder[] builders = new IndexRequestBuilder[numDocs];
for (int i = 0; i < numDocs; ++i) {
builders[i] = client().prepareIndex("idx", "type", Integer.toString(i))
builders[i] = client().prepareIndex("idx")
.setId(Integer.toString(i))
.setSource(jsonBuilder().startObject().field("common", "field").field("str_value", "s" + i).endObject());
}
indexRandom(true, builders);
@ -577,7 +579,7 @@ public class IndexStatsIT extends OpenSearchIntegTestCase {
sb.append(termUpto++);
sb.append(" some random text that keeps repeating over and over again hambone");
}
client().prepareIndex("test", "type", "" + termUpto).setSource("field" + (i % 10), sb.toString()).get();
client().prepareIndex("test").setId("" + termUpto).setSource("field" + (i % 10), sb.toString()).get();
}
refresh();
stats = client().admin().indices().prepareStats().execute().actionGet();
@ -613,7 +615,7 @@ public class IndexStatsIT extends OpenSearchIntegTestCase {
sb.append(' ');
sb.append(termUpto++);
}
client().prepareIndex("test", "type", "" + termUpto).setSource("field" + (i % 10), sb.toString()).get();
client().prepareIndex("test").setId("" + termUpto).setSource("field" + (i % 10), sb.toString()).get();
if (i % 2 == 0) {
refresh();
}
@ -639,9 +641,9 @@ public class IndexStatsIT extends OpenSearchIntegTestCase {
createIndex("test1", "test2");
ensureGreen();
client().prepareIndex("test1", "type", Integer.toString(1)).setSource("field", "value").execute().actionGet();
client().prepareIndex("test1", "type", Integer.toString(2)).setSource("field", "value").execute().actionGet();
client().prepareIndex("test2", "type", Integer.toString(1)).setSource("field", "value").execute().actionGet();
client().prepareIndex("test1").setId(Integer.toString(1)).setSource("field", "value").execute().actionGet();
client().prepareIndex("test1").setId(Integer.toString(2)).setSource("field", "value").execute().actionGet();
client().prepareIndex("test2").setId(Integer.toString(1)).setSource("field", "value").execute().actionGet();
refresh();
NumShards test1 = getNumShards("test1");
@ -733,7 +735,8 @@ public class IndexStatsIT extends OpenSearchIntegTestCase {
// index failed
try {
client().prepareIndex("test1", "type", Integer.toString(1))
client().prepareIndex("test1")
.setId(Integer.toString(1))
.setSource("field", "value")
.setVersion(1)
.setVersionType(VersionType.EXTERNAL)
@ -742,7 +745,8 @@ public class IndexStatsIT extends OpenSearchIntegTestCase {
fail("Expected a version conflict");
} catch (VersionConflictEngineException e) {}
try {
client().prepareIndex("test2", "type", Integer.toString(1))
client().prepareIndex("test2")
.setId(Integer.toString(1))
.setSource("field", "value")
.setVersion(1)
.setVersionType(VersionType.EXTERNAL)
@ -751,7 +755,8 @@ public class IndexStatsIT extends OpenSearchIntegTestCase {
fail("Expected a version conflict");
} catch (VersionConflictEngineException e) {}
try {
client().prepareIndex("test2", "type", Integer.toString(1))
client().prepareIndex("test2")
.setId(Integer.toString(1))
.setSource("field", "value")
.setVersion(1)
.setVersionType(VersionType.EXTERNAL)
@ -791,7 +796,7 @@ public class IndexStatsIT extends OpenSearchIntegTestCase {
assertThat(stats.getTotal().getSearch(), nullValue());
for (int i = 0; i < 20; i++) {
client().prepareIndex("test_index", "_doc", Integer.toString(i)).setSource("field", "value").execute().actionGet();
client().prepareIndex("test_index").setId(Integer.toString(i)).setSource("field", "value").execute().actionGet();
client().admin().indices().prepareFlush().execute().actionGet();
}
client().admin().indices().prepareForceMerge().setMaxNumSegments(1).execute().actionGet();
@ -837,9 +842,9 @@ public class IndexStatsIT extends OpenSearchIntegTestCase {
ensureGreen();
client().prepareIndex("test_index", "_doc", Integer.toString(1)).setSource("field", "value").execute().actionGet();
client().prepareIndex("test_index", "_doc", Integer.toString(2)).setSource("field", "value").execute().actionGet();
client().prepareIndex("test_index_2", "type", Integer.toString(1)).setSource("field", "value").execute().actionGet();
client().prepareIndex("test_index").setId(Integer.toString(1)).setSource("field", "value").execute().actionGet();
client().prepareIndex("test_index").setId(Integer.toString(2)).setSource("field", "value").execute().actionGet();
client().prepareIndex("test_index_2").setId(Integer.toString(1)).setSource("field", "value").execute().actionGet();
client().admin().indices().prepareRefresh().execute().actionGet();
IndicesStatsRequestBuilder builder = client().admin().indices().prepareStats();
@ -964,9 +969,9 @@ public class IndexStatsIT extends OpenSearchIntegTestCase {
ensureGreen();
client().prepareIndex("test1", "_doc", Integer.toString(1)).setSource("field", "value").execute().actionGet();
client().prepareIndex("test1", "_doc", Integer.toString(2)).setSource("field", "value").execute().actionGet();
client().prepareIndex("test2", "_doc", Integer.toString(1)).setSource("field", "value").execute().actionGet();
client().prepareIndex("test1").setId(Integer.toString(1)).setSource("field", "value").execute().actionGet();
client().prepareIndex("test1").setId(Integer.toString(2)).setSource("field", "value").execute().actionGet();
client().prepareIndex("test2").setId(Integer.toString(1)).setSource("field", "value").execute().actionGet();
refresh();
int numShards1 = getNumShards("test1").totalNumShards;
@ -1008,7 +1013,7 @@ public class IndexStatsIT extends OpenSearchIntegTestCase {
);
ensureGreen();
client().prepareIndex("test1", "_doc", Integer.toString(1)).setSource("{\"bar\":\"bar\",\"baz\":\"baz\"}", XContentType.JSON).get();
client().prepareIndex("test1").setId(Integer.toString(1)).setSource("{\"bar\":\"bar\",\"baz\":\"baz\"}", XContentType.JSON).get();
refresh();
IndicesStatsRequestBuilder builder = client().admin().indices().prepareStats();
@ -1050,7 +1055,7 @@ public class IndexStatsIT extends OpenSearchIntegTestCase {
ensureGreen();
client().prepareIndex("test1", "bar", Integer.toString(1)).setSource("foo", "bar").execute().actionGet();
client().prepareIndex("test1").setId(Integer.toString(1)).setSource("foo", "bar").execute().actionGet();
refresh();
client().prepareSearch("_all").setStats("bar", "baz").execute().actionGet();
@ -1210,8 +1215,8 @@ public class IndexStatsIT extends OpenSearchIntegTestCase {
indexRandom(
false,
true,
client().prepareIndex("index", "type", "1").setSource("foo", "bar"),
client().prepareIndex("index", "type", "2").setSource("foo", "baz")
client().prepareIndex("index").setId("1").setSource("foo", "bar"),
client().prepareIndex("index").setId("2").setSource("foo", "baz")
);
persistGlobalCheckpoint("index"); // Need to persist the global checkpoint for the soft-deletes retention MP.
refresh();
@ -1285,8 +1290,8 @@ public class IndexStatsIT extends OpenSearchIntegTestCase {
indexRandom(
true,
client().prepareIndex("index", "type", "1").setSource("foo", "bar"),
client().prepareIndex("index", "type", "2").setSource("foo", "baz")
client().prepareIndex("index").setId("1").setSource("foo", "bar"),
client().prepareIndex("index").setId("2").setSource("foo", "baz")
);
assertBusy(() -> {
@ -1353,7 +1358,7 @@ public class IndexStatsIT extends OpenSearchIntegTestCase {
}
while (!stop.get()) {
final String id = Integer.toString(idGenerator.incrementAndGet());
final IndexResponse response = client().prepareIndex("test", "type", id).setSource("{}", XContentType.JSON).get();
final IndexResponse response = client().prepareIndex("test").setId(id).setSource("{}", XContentType.JSON).get();
assertThat(response.getResult(), equalTo(DocWriteResponse.Result.CREATED));
}
});

View File

@ -182,10 +182,7 @@ public class SimpleIndexTemplateIT extends OpenSearchIntegTestCase {
assertThat(response.getIndexTemplates(), hasSize(2));
// index something into test_index, will match on both templates
client().prepareIndex("test_index", "type1", "1")
.setSource("field1", "value1", "field2", "value 2")
.setRefreshPolicy(IMMEDIATE)
.get();
client().prepareIndex("test_index").setId("1").setSource("field1", "value1", "field2", "value 2").setRefreshPolicy(IMMEDIATE).get();
ensureGreen();
SearchResponse searchResponse = client().prepareSearch("test_index")
@ -200,10 +197,7 @@ public class SimpleIndexTemplateIT extends OpenSearchIntegTestCase {
// field2 is not stored.
assertThat(searchResponse.getHits().getAt(0).field("field2"), nullValue());
client().prepareIndex("text_index", "type1", "1")
.setSource("field1", "value1", "field2", "value 2")
.setRefreshPolicy(IMMEDIATE)
.get();
client().prepareIndex("text_index").setId("1").setSource("field1", "value1", "field2", "value 2").setRefreshPolicy(IMMEDIATE).get();
ensureGreen();
// now only match on one template (template_1)
@ -570,11 +564,11 @@ public class SimpleIndexTemplateIT extends OpenSearchIntegTestCase {
assertAcked(prepareCreate("test_index"));
ensureGreen();
client().prepareIndex("test_index", "_doc", "1").setSource("type", "type1", "field", "A value").get();
client().prepareIndex("test_index", "_doc", "2").setSource("type", "type2", "field", "B value").get();
client().prepareIndex("test_index", "_doc", "3").setSource("type", "typeX", "field", "C value").get();
client().prepareIndex("test_index", "_doc", "4").setSource("type", "typeY", "field", "D value").get();
client().prepareIndex("test_index", "_doc", "5").setSource("type", "typeZ", "field", "E value").get();
client().prepareIndex("test_index").setId("1").setSource("type", "type1", "field", "A value").get();
client().prepareIndex("test_index").setId("2").setSource("type", "type2", "field", "B value").get();
client().prepareIndex("test_index").setId("3").setSource("type", "typeX", "field", "C value").get();
client().prepareIndex("test_index").setId("4").setSource("type", "typeY", "field", "D value").get();
client().prepareIndex("test_index").setId("5").setSource("type", "typeZ", "field", "E value").get();
GetAliasesResponse getAliasesResponse = client().admin().indices().prepareGetAliases().setIndices("test_index").get();
assertThat(getAliasesResponse.getAliases().size(), equalTo(1));
@ -637,8 +631,8 @@ public class SimpleIndexTemplateIT extends OpenSearchIntegTestCase {
assertThat(getAliasesResponse.getAliases().size(), equalTo(1));
assertThat(getAliasesResponse.getAliases().get("test_index").size(), equalTo(1));
client().prepareIndex("test_index", "_doc", "1").setSource("field", "value1").get();
client().prepareIndex("test_index", "_doc", "2").setSource("field", "value2").get();
client().prepareIndex("test_index").setId("1").setSource("field", "value1").get();
client().prepareIndex("test_index").setId("2").setSource("field", "value2").get();
refresh();
SearchResponse searchResponse = client().prepareSearch("test_index").get();
@ -676,8 +670,8 @@ public class SimpleIndexTemplateIT extends OpenSearchIntegTestCase {
assertThat(getAliasesResponse.getAliases().size(), equalTo(1));
assertThat(getAliasesResponse.getAliases().get("test_index").size(), equalTo(3));
client().prepareIndex("test_index", "_doc", "1").setSource("field", "value1").get();
client().prepareIndex("test_index", "_doc", "2").setSource("field", "value2").get();
client().prepareIndex("test_index").setId("1").setSource("field", "value1").get();
client().prepareIndex("test_index").setId("2").setSource("field", "value2").get();
refresh();
SearchResponse searchResponse = client().prepareSearch("test_index").get();
@ -838,7 +832,7 @@ public class SimpleIndexTemplateIT extends OpenSearchIntegTestCase {
.addAlias(new Alias("alias4").filter(termQuery("field", "value")))
.get();
client().prepareIndex("a1", "test", "test").setSource("{}", XContentType.JSON).get();
client().prepareIndex("a1").setId("test").setSource("{}", XContentType.JSON).get();
BulkResponse response = client().prepareBulk().add(new IndexRequest("a2").id("test").source("{}", XContentType.JSON)).get();
assertThat(response.hasFailures(), is(false));
assertThat(response.getItems()[0].isFailed(), equalTo(false));
@ -854,7 +848,7 @@ public class SimpleIndexTemplateIT extends OpenSearchIntegTestCase {
// So the aliases defined in the index template for this index will not fail
// even though the fields in the alias fields don't exist yet and indexing into
// an index that doesn't exist yet will succeed
client().prepareIndex("b1", "test", "test").setSource("{}", XContentType.JSON).get();
client().prepareIndex("b1").setId("test").setSource("{}", XContentType.JSON).get();
response = client().prepareBulk().add(new IndexRequest("b2").id("test").source("{}", XContentType.JSON)).get();
assertThat(response.hasFailures(), is(false));
@ -972,9 +966,9 @@ public class SimpleIndexTemplateIT extends OpenSearchIntegTestCase {
)
.get();
client().prepareIndex("ax", "type1", "1").setSource("field1", "value1", "field2", "value2").setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("ax").setId("1").setSource("field1", "value1", "field2", "value2").setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("bx", "type1", "1").setSource("field1", "value1", "field2", "value2").setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("bx").setId("1").setSource("field1", "value1", "field2", "value2").setRefreshPolicy(IMMEDIATE).get();
ensureGreen();

View File

@ -256,14 +256,14 @@ public class IngestClientIT extends OpenSearchIntegTestCase {
assertThat(getResponse.pipelines().size(), equalTo(1));
assertThat(getResponse.pipelines().get(0).getId(), equalTo("_id"));
client().prepareIndex("test", "type", "1").setPipeline("_id").setSource("field", "value", "fail", false).get();
client().prepareIndex("test").setId("1").setPipeline("_id").setSource("field", "value", "fail", false).get();
Map<String, Object> doc = client().prepareGet("test", "1").get().getSourceAsMap();
assertThat(doc.get("field"), equalTo("value"));
assertThat(doc.get("processed"), equalTo(true));
client().prepareBulk()
.add(client().prepareIndex("test", "type", "2").setSource("field", "value2", "fail", false).setPipeline("_id"))
.add(client().prepareIndex("test").setId("2").setSource("field", "value2", "fail", false).setPipeline("_id"))
.get();
doc = client().prepareGet("test", "2").get().getSourceAsMap();
assertThat(doc.get("field"), equalTo("value2"));

View File

@ -62,7 +62,8 @@ public class SimpleMgetIT extends OpenSearchIntegTestCase {
public void testThatMgetShouldWorkWithOneIndexMissing() throws IOException {
createIndex("test");
client().prepareIndex("test", "test", "1")
client().prepareIndex("test")
.setId("1")
.setSource(jsonBuilder().startObject().field("foo", "bar").endObject())
.setRefreshPolicy(IMMEDIATE)
.get();
@ -99,7 +100,8 @@ public class SimpleMgetIT extends OpenSearchIntegTestCase {
assertAcked(prepareCreate("test").addAlias(new Alias("multiIndexAlias")));
assertAcked(prepareCreate("test2").addAlias(new Alias("multiIndexAlias")));
client().prepareIndex("test", "test", "1")
client().prepareIndex("test")
.setId("1")
.setSource(jsonBuilder().startObject().field("foo", "bar").endObject())
.setRefreshPolicy(IMMEDIATE)
.get();
@ -139,7 +141,8 @@ public class SimpleMgetIT extends OpenSearchIntegTestCase {
)
);
client().prepareIndex("alias1", "test", "1")
client().prepareIndex("alias1")
.setId("1")
.setSource(jsonBuilder().startObject().field("foo", "bar").endObject())
.setRefreshPolicy(IMMEDIATE)
.get();
@ -165,7 +168,7 @@ public class SimpleMgetIT extends OpenSearchIntegTestCase {
.endObject()
);
for (int i = 0; i < 100; i++) {
client().prepareIndex("test", "type", Integer.toString(i)).setSource(sourceBytesRef, XContentType.JSON).get();
client().prepareIndex("test").setId(Integer.toString(i)).setSource(sourceBytesRef, XContentType.JSON).get();
}
MultiGetRequestBuilder request = client().prepareMultiGet();
@ -212,7 +215,8 @@ public class SimpleMgetIT extends OpenSearchIntegTestCase {
final String id = routingKeyForShard("test", 0);
final String routingOtherShard = routingKeyForShard("test", 1);
client().prepareIndex("test", "test", id)
client().prepareIndex("test")
.setId(id)
.setRefreshPolicy(IMMEDIATE)
.setRouting(routingOtherShard)
.setSource(jsonBuilder().startObject().field("foo", "bar").endObject())

View File

@ -73,14 +73,16 @@ public class FullRollingRestartIT extends OpenSearchIntegTestCase {
final String healthTimeout = "1m";
for (int i = 0; i < 1000; i++) {
client().prepareIndex("test", "type1", Long.toString(i))
client().prepareIndex("test")
.setId(Long.toString(i))
.setSource(MapBuilder.<String, Object>newMapBuilder().put("test", "value" + i).map())
.execute()
.actionGet();
}
flush();
for (int i = 1000; i < 2000; i++) {
client().prepareIndex("test", "type1", Long.toString(i))
client().prepareIndex("test")
.setId(Long.toString(i))
.setSource(MapBuilder.<String, Object>newMapBuilder().put("test", "value" + i).map())
.execute()
.actionGet();
@ -210,7 +212,8 @@ public class FullRollingRestartIT extends OpenSearchIntegTestCase {
).get();
for (int i = 0; i < 100; i++) {
client().prepareIndex("test", "type1", Long.toString(i))
client().prepareIndex("test")
.setId(Long.toString(i))
.setSource(MapBuilder.<String, Object>newMapBuilder().put("test", "value" + i).map())
.execute()
.actionGet();

View File

@ -150,13 +150,13 @@ public class RelocationIT extends OpenSearchIntegTestCase {
logger.info("--> index 10 docs");
for (int i = 0; i < 10; i++) {
client().prepareIndex("test", "type", Integer.toString(i)).setSource("field", "value" + i).execute().actionGet();
client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", "value" + i).execute().actionGet();
}
logger.info("--> flush so we have an actual index");
client().admin().indices().prepareFlush().execute().actionGet();
logger.info("--> index more docs so we have something in the translog");
for (int i = 10; i < 20; i++) {
client().prepareIndex("test", "type", Integer.toString(i)).setSource("field", "value" + i).execute().actionGet();
client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", "value" + i).execute().actionGet();
}
logger.info("--> verifying count");
@ -560,7 +560,7 @@ public class RelocationIT extends OpenSearchIntegTestCase {
for (int i = 0; i < numDocs; i++) {
String id = randomRealisticUnicodeOfLength(10) + String.valueOf(i);
ids.add(id);
docs[i] = client().prepareIndex("test", "type1", id).setSource("field1", English.intToEnglish(i));
docs[i] = client().prepareIndex("test").setId(id).setSource("field1", English.intToEnglish(i));
}
indexRandom(true, docs);
SearchResponse countResponse = client().prepareSearch("test").get();
@ -578,7 +578,7 @@ public class RelocationIT extends OpenSearchIntegTestCase {
for (int i = 0; i < numDocs; i++) {
String id = randomRealisticUnicodeOfLength(10) + String.valueOf(numDocs + i);
ids.add(id);
docs[i] = client().prepareIndex("test", "type1", id).setSource("field1", English.intToEnglish(numDocs + i));
docs[i] = client().prepareIndex("test").setId(id).setSource("field1", English.intToEnglish(numDocs + i));
}
indexRandom(true, docs);
@ -614,13 +614,14 @@ public class RelocationIT extends OpenSearchIntegTestCase {
logger.info("--> index 10 docs");
for (int i = 0; i < 10; i++) {
client().prepareIndex("test", "type", Integer.toString(i)).setSource("field", "value" + i).execute().actionGet();
client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", "value" + i).execute().actionGet();
}
logger.info("--> flush so we have an actual index");
client().admin().indices().prepareFlush().execute().actionGet();
logger.info("--> index more docs so we have something in the translog");
for (int i = 10; i < 20; i++) {
client().prepareIndex("test", "type", Integer.toString(i))
client().prepareIndex("test")
.setId(Integer.toString(i))
.setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL)
.setSource("field", "value" + i)
.execute();
@ -671,7 +672,7 @@ public class RelocationIT extends OpenSearchIntegTestCase {
logger.info("--> index 10 docs");
for (int i = 0; i < 10; i++) {
client().prepareIndex("test", "type", Integer.toString(i)).setSource("field", "value" + i).execute().actionGet();
client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", "value" + i).execute().actionGet();
}
logger.info("--> flush so we have an actual index");
client().admin().indices().prepareFlush().execute().actionGet();
@ -679,7 +680,8 @@ public class RelocationIT extends OpenSearchIntegTestCase {
final List<ActionFuture<IndexResponse>> pendingIndexResponses = new ArrayList<>();
for (int i = 10; i < 20; i++) {
pendingIndexResponses.add(
client().prepareIndex("test", "type", Integer.toString(i))
client().prepareIndex("test")
.setId(Integer.toString(i))
.setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL)
.setSource("field", "value" + i)
.execute()
@ -706,7 +708,8 @@ public class RelocationIT extends OpenSearchIntegTestCase {
logger.info("--> index 100 docs while relocating");
for (int i = 20; i < 120; i++) {
pendingIndexResponses.add(
client().prepareIndex("test", "type", Integer.toString(i))
client().prepareIndex("test")
.setId(Integer.toString(i))
.setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL)
.setSource("field", "value" + i)
.execute()

View File

@ -122,7 +122,7 @@ public class TruncatedRecoveryIT extends OpenSearchIntegTestCase {
List<IndexRequestBuilder> builder = new ArrayList<>();
for (int i = 0; i < numDocs; i++) {
String id = Integer.toString(i);
builder.add(client().prepareIndex("test", "type1", id).setSource("field1", English.intToEnglish(i), "the_id", id));
builder.add(client().prepareIndex("test").setId(id).setSource("field1", English.intToEnglish(i), "the_id", id));
}
indexRandom(true, builder);
for (int i = 0; i < numDocs; i++) {

View File

@ -61,9 +61,9 @@ public class AliasResolveRoutingIT extends OpenSearchIntegTestCase {
client().admin().indices().prepareClose("test-1").get();
indexRandom(
true,
client().prepareIndex("test-0", "type1", "1").setSource("field1", "the quick brown fox jumps"),
client().prepareIndex("test-0", "type1", "2").setSource("field1", "quick brown"),
client().prepareIndex("test-0", "type1", "3").setSource("field1", "quick")
client().prepareIndex("test-0").setId("1").setSource("field1", "the quick brown fox jumps"),
client().prepareIndex("test-0").setId("2").setSource("field1", "quick brown"),
client().prepareIndex("test-0").setId("3").setSource("field1", "quick")
);
refresh("test-*");
assertHitCount(

View File

@ -63,7 +63,7 @@ public class AliasRoutingIT extends OpenSearchIntegTestCase {
assertAcked(admin().indices().prepareAliases().addAliasAction(AliasActions.add().index("test").alias("alias0").routing("0")));
logger.info("--> indexing with id [1], and routing [0] using alias");
client().prepareIndex("alias0", "type1", "1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareIndex("alias0").setId("1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
logger.info("--> verifying get with no routing, should not find anything");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false));
@ -109,7 +109,7 @@ public class AliasRoutingIT extends OpenSearchIntegTestCase {
}
logger.info("--> indexing with id [1], and routing [0] using alias");
client().prepareIndex("alias0", "type1", "1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareIndex("alias0").setId("1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
logger.info("--> verifying get with no routing, should not find anything");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false));
@ -134,7 +134,7 @@ public class AliasRoutingIT extends OpenSearchIntegTestCase {
);
logger.info("--> indexing with id [1], and routing [0] using alias");
client().prepareIndex("alias0", "type1", "1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareIndex("alias0").setId("1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
logger.info("--> verifying get with no routing, should not find anything");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false));
@ -245,7 +245,7 @@ public class AliasRoutingIT extends OpenSearchIntegTestCase {
}
logger.info("--> indexing with id [2], and routing [1] using alias");
client().prepareIndex("alias1", "type1", "2").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareIndex("alias1").setId("2").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
logger.info("--> search with no routing, should fine two");
for (int i = 0; i < 5; i++) {
@ -491,7 +491,7 @@ public class AliasRoutingIT extends OpenSearchIntegTestCase {
);
ensureGreen(); // wait for events again to make sure we got the aliases on all nodes
logger.info("--> indexing with id [1], and routing [0] using alias to test-a");
client().prepareIndex("alias-a0", "type1", "1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareIndex("alias-a0").setId("1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
logger.info("--> verifying get with no routing, should not find anything");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test-a", "1").execute().actionGet().isExists(), equalTo(false));
@ -502,7 +502,7 @@ public class AliasRoutingIT extends OpenSearchIntegTestCase {
}
logger.info("--> indexing with id [0], and routing [1] using alias to test-b");
client().prepareIndex("alias-b1", "type1", "1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareIndex("alias-b1").setId("1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
logger.info("--> verifying get with no routing, should not find anything");
for (int i = 0; i < 5; i++) {
assertThat(client().prepareGet("test-a", "1").execute().actionGet().isExists(), equalTo(false));
@ -594,9 +594,9 @@ public class AliasRoutingIT extends OpenSearchIntegTestCase {
assertAcked(admin().indices().prepareAliases().addAliasAction(AliasActions.add().index("index").alias("index_1").routing("1")));
logger.info("--> indexing on index_1 which is an alias for index with routing [1]");
client().prepareIndex("index_1", "type1", "1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareIndex("index_1").setId("1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
logger.info("--> indexing on index_2 which is a concrete index");
client().prepareIndex("index_2", "type2", "2").setSource("field", "value2").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareIndex("index_2").setId("2").setSource("field", "value2").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
logger.info("--> search all on index_* should find two");
for (int i = 0; i < 5; i++) {
@ -625,9 +625,9 @@ public class AliasRoutingIT extends OpenSearchIntegTestCase {
assertAcked(admin().indices().prepareAliases().addAliasAction(AliasActions.add().index("index").alias("index_1").routing("1")));
logger.info("--> indexing on index_1 which is an alias for index with routing [1]");
client().prepareIndex("index_1", "type1", "1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareIndex("index_1").setId("1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
logger.info("--> indexing on index_2 which is a concrete index");
client().prepareIndex("index_2", "type2", "2").setSource("field", "value2").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareIndex("index_2").setId("2").setSource("field", "value2").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
SearchResponse searchResponse = client().prepareSearch("index_*")
.setSearchType(SearchType.QUERY_THEN_FETCH)
@ -650,7 +650,7 @@ public class AliasRoutingIT extends OpenSearchIntegTestCase {
assertAcked(admin().indices().prepareAliases().addAliasAction(AliasActions.add().index("test").alias("alias").routing("3")));
logger.info("--> indexing with id [0], and routing [3]");
client().prepareIndex("alias", "type1", "0").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareIndex("alias").setId("0").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
logger.info("--> verifying get with no routing, should not find anything");
logger.info("--> verifying get and search with routing, should find");
@ -712,7 +712,7 @@ public class AliasRoutingIT extends OpenSearchIntegTestCase {
);
logger.info("--> indexing with id [1], and routing [4]");
client().prepareIndex("alias", "type1", "1").setSource("field", "value2").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
client().prepareIndex("alias").setId("1").setSource("field", "value2").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
logger.info("--> verifying get with no routing, should not find anything");
logger.info("--> verifying get and search with routing, should find");

View File

@ -249,7 +249,7 @@ public class PartitionedRoutingIT extends OpenSearchIntegTestCase {
String id = routingValue + "_" + String.valueOf(k);
routingToDocumentIds.get(routingValue).add(id);
client().prepareIndex(index, "type", id).setRouting(routingValue).setSource("foo", "bar").get();
client().prepareIndex(index).setId(id).setRouting(routingValue).setSource("foo", "bar").get();
}
}

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