[Remove] Types from DocWrite Request and Response (#2239)
Removes type support from DocWrite Request and Response, all derived classes, and all places used. Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
This commit is contained in:
parent
37235fafd9
commit
d892c51d66
|
@ -116,7 +116,7 @@ public class RestNoopBulkAction extends BaseRestHandler {
|
|||
private final BulkItemResponse ITEM_RESPONSE = new BulkItemResponse(
|
||||
1,
|
||||
DocWriteRequest.OpType.UPDATE,
|
||||
new UpdateResponse(new ShardId("mock", "", 1), "mock_type", "1", 0L, 1L, 1L, DocWriteResponse.Result.CREATED)
|
||||
new UpdateResponse(new ShardId("mock", "", 1), "1", 0L, 1L, 1L, DocWriteResponse.Result.CREATED)
|
||||
);
|
||||
|
||||
private final RestRequest request;
|
||||
|
|
|
@ -49,7 +49,7 @@ public class TransportNoopBulkAction extends HandledTransportAction<BulkRequest,
|
|||
private static final BulkItemResponse ITEM_RESPONSE = new BulkItemResponse(
|
||||
1,
|
||||
DocWriteRequest.OpType.UPDATE,
|
||||
new UpdateResponse(new ShardId("mock", "", 1), "mock_type", "1", 0L, 1L, 1L, DocWriteResponse.Result.CREATED)
|
||||
new UpdateResponse(new ShardId("mock", "", 1), "1", 0L, 1L, 1L, DocWriteResponse.Result.CREATED)
|
||||
);
|
||||
|
||||
@Inject
|
||||
|
|
|
@ -117,7 +117,7 @@ final class RequestConverters {
|
|||
}
|
||||
|
||||
static Request delete(DeleteRequest deleteRequest) {
|
||||
String endpoint = endpoint(deleteRequest.index(), deleteRequest.type(), deleteRequest.id());
|
||||
String endpoint = endpoint(deleteRequest.index(), deleteRequest.id());
|
||||
Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
|
||||
|
||||
Params parameters = new Params();
|
||||
|
@ -185,11 +185,6 @@ final class RequestConverters {
|
|||
if (Strings.hasLength(action.index())) {
|
||||
metadata.field("_index", action.index());
|
||||
}
|
||||
if (Strings.hasLength(action.type())) {
|
||||
if (MapperService.SINGLE_MAPPING_NAME.equals(action.type()) == false) {
|
||||
metadata.field("_type", action.type());
|
||||
}
|
||||
}
|
||||
if (Strings.hasLength(action.id())) {
|
||||
metadata.field("_id", action.id());
|
||||
}
|
||||
|
@ -338,11 +333,9 @@ final class RequestConverters {
|
|||
|
||||
String endpoint;
|
||||
if (indexRequest.opType() == DocWriteRequest.OpType.CREATE) {
|
||||
endpoint = indexRequest.type().equals(MapperService.SINGLE_MAPPING_NAME)
|
||||
? endpoint(indexRequest.index(), "_create", indexRequest.id())
|
||||
: endpoint(indexRequest.index(), indexRequest.type(), indexRequest.id(), "_create");
|
||||
endpoint = endpoint(indexRequest.index(), "_create", indexRequest.id());
|
||||
} else {
|
||||
endpoint = endpoint(indexRequest.index(), indexRequest.type(), indexRequest.id());
|
||||
endpoint = endpoint(indexRequest.index(), indexRequest.id());
|
||||
}
|
||||
|
||||
Request request = new Request(method, endpoint);
|
||||
|
@ -371,9 +364,7 @@ final class RequestConverters {
|
|||
}
|
||||
|
||||
static Request update(UpdateRequest updateRequest) throws IOException {
|
||||
String endpoint = updateRequest.type().equals(MapperService.SINGLE_MAPPING_NAME)
|
||||
? endpoint(updateRequest.index(), "_update", updateRequest.id())
|
||||
: endpoint(updateRequest.index(), updateRequest.type(), updateRequest.id(), "_update");
|
||||
String endpoint = endpoint(updateRequest.index(), "_update", updateRequest.id());
|
||||
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
|
||||
Params parameters = new Params();
|
||||
|
|
|
@ -359,8 +359,6 @@ public class BulkProcessorIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
{
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
BulkProcessorTestListener listener = new BulkProcessorTestListener(latch);
|
||||
// Check that untyped document additions inherit the global type
|
||||
String localType = null;
|
||||
try (
|
||||
BulkProcessor processor = initBulkProcessorBuilder(listener)
|
||||
// let's make sure that the bulk action limit trips, one single execution will index all the documents
|
||||
|
@ -374,7 +372,7 @@ public class BulkProcessorIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
.build()
|
||||
) {
|
||||
|
||||
indexDocs(processor, numDocs, null, localType, "test", "pipeline_id");
|
||||
indexDocs(processor, numDocs, null, "test", "pipeline_id");
|
||||
latch.await();
|
||||
|
||||
assertThat(listener.beforeCounts.get(), equalTo(1));
|
||||
|
@ -395,26 +393,17 @@ public class BulkProcessorIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
return IntStream.rangeClosed(1, numDocs).boxed().map(n -> hasId(n.toString())).<Matcher<SearchHit>>toArray(Matcher[]::new);
|
||||
}
|
||||
|
||||
private MultiGetRequest indexDocs(
|
||||
BulkProcessor processor,
|
||||
int numDocs,
|
||||
String localIndex,
|
||||
String localType,
|
||||
String globalIndex,
|
||||
String globalPipeline
|
||||
) throws Exception {
|
||||
private MultiGetRequest indexDocs(BulkProcessor processor, int numDocs, String localIndex, String globalIndex, String globalPipeline)
|
||||
throws Exception {
|
||||
MultiGetRequest multiGetRequest = new MultiGetRequest();
|
||||
for (int i = 1; i <= numDocs; i++) {
|
||||
if (randomBoolean()) {
|
||||
processor.add(
|
||||
new IndexRequest(localIndex, localType, Integer.toString(i)).source(
|
||||
XContentType.JSON,
|
||||
"field",
|
||||
randomRealisticUnicodeOfLengthBetween(1, 30)
|
||||
)
|
||||
new IndexRequest(localIndex).id(Integer.toString(i))
|
||||
.source(XContentType.JSON, "field", randomRealisticUnicodeOfLengthBetween(1, 30))
|
||||
);
|
||||
} else {
|
||||
BytesArray data = bytesBulkRequest(localIndex, localType, i);
|
||||
BytesArray data = bytesBulkRequest(localIndex, i);
|
||||
processor.add(data, globalIndex, globalPipeline, XContentType.JSON);
|
||||
}
|
||||
multiGetRequest.add(localIndex, Integer.toString(i));
|
||||
|
@ -422,17 +411,13 @@ public class BulkProcessorIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
return multiGetRequest;
|
||||
}
|
||||
|
||||
private static BytesArray bytesBulkRequest(String localIndex, String localType, int id) throws IOException {
|
||||
private static BytesArray bytesBulkRequest(String localIndex, int id) throws IOException {
|
||||
XContentBuilder action = jsonBuilder().startObject().startObject("index");
|
||||
|
||||
if (localIndex != null) {
|
||||
action.field("_index", localIndex);
|
||||
}
|
||||
|
||||
if (localType != null) {
|
||||
action.field("_type", localType);
|
||||
}
|
||||
|
||||
action.field("_id", Integer.toString(id));
|
||||
action.endObject().endObject();
|
||||
|
||||
|
@ -443,7 +428,7 @@ public class BulkProcessorIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
}
|
||||
|
||||
private MultiGetRequest indexDocs(BulkProcessor processor, int numDocs) throws Exception {
|
||||
return indexDocs(processor, numDocs, "test", null, null, null);
|
||||
return indexDocs(processor, numDocs, "test", null, null);
|
||||
}
|
||||
|
||||
private static void assertResponseItems(List<BulkItemResponse> bulkItemResponses, int numDocs) {
|
||||
|
|
|
@ -108,7 +108,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
}
|
||||
DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync);
|
||||
assertEquals("index", deleteResponse.getIndex());
|
||||
assertEquals("_doc", deleteResponse.getType());
|
||||
assertEquals(docId, deleteResponse.getId());
|
||||
assertEquals(DocWriteResponse.Result.DELETED, deleteResponse.getResult());
|
||||
}
|
||||
|
@ -118,7 +117,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
DeleteRequest deleteRequest = new DeleteRequest("index", docId);
|
||||
DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync);
|
||||
assertEquals("index", deleteResponse.getIndex());
|
||||
assertEquals("_doc", deleteResponse.getType());
|
||||
assertEquals(docId, deleteResponse.getId());
|
||||
assertEquals(DocWriteResponse.Result.NOT_FOUND, deleteResponse.getResult());
|
||||
}
|
||||
|
@ -157,7 +155,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
DeleteRequest deleteRequest = new DeleteRequest("index", docId).versionType(VersionType.EXTERNAL).version(13);
|
||||
DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync);
|
||||
assertEquals("index", deleteResponse.getIndex());
|
||||
assertEquals("_doc", deleteResponse.getType());
|
||||
assertEquals(docId, deleteResponse.getId());
|
||||
assertEquals(DocWriteResponse.Result.DELETED, deleteResponse.getResult());
|
||||
}
|
||||
|
@ -194,7 +191,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
DeleteRequest deleteRequest = new DeleteRequest("index", docId).routing("foo");
|
||||
DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync);
|
||||
assertEquals("index", deleteResponse.getIndex());
|
||||
assertEquals("_doc", deleteResponse.getType());
|
||||
assertEquals(docId, deleteResponse.getId());
|
||||
assertEquals(DocWriteResponse.Result.DELETED, deleteResponse.getResult());
|
||||
}
|
||||
|
@ -440,8 +436,8 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
public void testMultiGetWithIds() throws IOException {
|
||||
BulkRequest bulk = new BulkRequest();
|
||||
bulk.setRefreshPolicy(RefreshPolicy.IMMEDIATE);
|
||||
bulk.add(new IndexRequest("index", "id1").source("{\"field\":\"value1\"}", XContentType.JSON));
|
||||
bulk.add(new IndexRequest("index", "id2").source("{\"field\":\"value2\"}", XContentType.JSON));
|
||||
bulk.add(new IndexRequest("index").id("id1").source("{\"field\":\"value1\"}", XContentType.JSON));
|
||||
bulk.add(new IndexRequest("index").id("id2").source("{\"field\":\"value2\"}", XContentType.JSON));
|
||||
|
||||
MultiGetRequest multiGetRequest = new MultiGetRequest();
|
||||
multiGetRequest.add("index", "id1");
|
||||
|
@ -534,7 +530,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
assertEquals(RestStatus.CREATED, indexResponse.status());
|
||||
assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult());
|
||||
assertEquals("index", indexResponse.getIndex());
|
||||
assertEquals("_doc", indexResponse.getType());
|
||||
assertTrue(Strings.hasLength(indexResponse.getId()));
|
||||
assertEquals(1L, indexResponse.getVersion());
|
||||
assertNotNull(indexResponse.getShardId());
|
||||
|
@ -554,7 +549,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync);
|
||||
assertEquals(RestStatus.CREATED, indexResponse.status());
|
||||
assertEquals("index", indexResponse.getIndex());
|
||||
assertEquals("_doc", indexResponse.getType());
|
||||
assertEquals("id", indexResponse.getId());
|
||||
assertEquals(1L, indexResponse.getVersion());
|
||||
|
||||
|
@ -564,7 +558,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync);
|
||||
assertEquals(RestStatus.OK, indexResponse.status());
|
||||
assertEquals("index", indexResponse.getIndex());
|
||||
assertEquals("_doc", indexResponse.getType());
|
||||
assertEquals("id", indexResponse.getId());
|
||||
assertEquals(2L, indexResponse.getVersion());
|
||||
|
||||
|
@ -622,7 +615,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync);
|
||||
assertEquals(RestStatus.CREATED, indexResponse.status());
|
||||
assertEquals("index", indexResponse.getIndex());
|
||||
assertEquals("_doc", indexResponse.getType());
|
||||
assertEquals("external_version_type", indexResponse.getId());
|
||||
assertEquals(12L, indexResponse.getVersion());
|
||||
}
|
||||
|
@ -634,7 +626,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync);
|
||||
assertEquals(RestStatus.CREATED, indexResponse.status());
|
||||
assertEquals("index", indexResponse.getIndex());
|
||||
assertEquals("_doc", indexResponse.getType());
|
||||
assertEquals("with_create_op_type", indexResponse.getId());
|
||||
|
||||
OpenSearchStatusException exception = expectThrows(
|
||||
|
@ -662,7 +653,7 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
);
|
||||
assertEquals(RestStatus.NOT_FOUND, exception.status());
|
||||
assertEquals(
|
||||
"OpenSearch exception [type=document_missing_exception, reason=[_doc][does_not_exist]: document missing]",
|
||||
"OpenSearch exception [type=document_missing_exception, reason=[does_not_exist]: document missing]",
|
||||
exception.getMessage()
|
||||
);
|
||||
}
|
||||
|
@ -787,7 +778,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync);
|
||||
assertEquals(RestStatus.CREATED, updateResponse.status());
|
||||
assertEquals("index", updateResponse.getIndex());
|
||||
assertEquals("_doc", updateResponse.getType());
|
||||
assertEquals("with_upsert", updateResponse.getId());
|
||||
GetResult getResult = updateResponse.getGetResult();
|
||||
assertEquals(1L, updateResponse.getVersion());
|
||||
|
@ -802,7 +792,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync);
|
||||
assertEquals(RestStatus.CREATED, updateResponse.status());
|
||||
assertEquals("index", updateResponse.getIndex());
|
||||
assertEquals("_doc", updateResponse.getType());
|
||||
assertEquals("with_doc_as_upsert", updateResponse.getId());
|
||||
GetResult getResult = updateResponse.getGetResult();
|
||||
assertEquals(1L, updateResponse.getVersion());
|
||||
|
@ -818,7 +807,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync);
|
||||
assertEquals(RestStatus.CREATED, updateResponse.status());
|
||||
assertEquals("index", updateResponse.getIndex());
|
||||
assertEquals("_doc", updateResponse.getType());
|
||||
assertEquals("with_scripted_upsert", updateResponse.getId());
|
||||
|
||||
GetResult getResult = updateResponse.getGetResult();
|
||||
|
@ -1039,7 +1027,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
indexRequest.source("field", "value");
|
||||
IndexResponse indexResponse = highLevelClient().index(indexRequest, RequestOptions.DEFAULT);
|
||||
assertEquals(expectedIndex, indexResponse.getIndex());
|
||||
assertEquals("_doc", indexResponse.getType());
|
||||
assertEquals("id#1", indexResponse.getId());
|
||||
}
|
||||
{
|
||||
|
@ -1056,7 +1043,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
indexRequest.source("field", "value");
|
||||
IndexResponse indexResponse = highLevelClient().index(indexRequest, RequestOptions.DEFAULT);
|
||||
assertEquals("index", indexResponse.getIndex());
|
||||
assertEquals("_doc", indexResponse.getType());
|
||||
assertEquals(docId, indexResponse.getId());
|
||||
}
|
||||
{
|
||||
|
@ -1079,7 +1065,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
indexRequest.routing(routing);
|
||||
IndexResponse indexResponse = highLevelClient().index(indexRequest, RequestOptions.DEFAULT);
|
||||
assertEquals("index", indexResponse.getIndex());
|
||||
assertEquals("_doc", indexResponse.getType());
|
||||
assertEquals("id", indexResponse.getId());
|
||||
}
|
||||
{
|
||||
|
|
|
@ -348,18 +348,6 @@ public class RequestConvertersTests extends OpenSearchTestCase {
|
|||
assertNull(request.getEntity());
|
||||
}
|
||||
|
||||
public void testDeleteWithType() {
|
||||
String index = randomAlphaOfLengthBetween(3, 10);
|
||||
String type = randomAlphaOfLengthBetween(3, 10);
|
||||
String id = randomAlphaOfLengthBetween(3, 10);
|
||||
DeleteRequest deleteRequest = new DeleteRequest(index, type, id);
|
||||
|
||||
Request request = RequestConverters.delete(deleteRequest);
|
||||
assertEquals(HttpDelete.METHOD_NAME, request.getMethod());
|
||||
assertEquals("/" + index + "/" + type + "/" + id, request.getEndpoint());
|
||||
assertNull(request.getEntity());
|
||||
}
|
||||
|
||||
public void testExists() {
|
||||
getAndExistsTest(RequestConverters::exists, HttpHead.METHOD_NAME);
|
||||
}
|
||||
|
@ -445,9 +433,6 @@ public class RequestConvertersTests extends OpenSearchTestCase {
|
|||
if (randomBoolean()) {
|
||||
reindexRequest.setSourceBatchSize(randomInt(100));
|
||||
}
|
||||
if (randomBoolean()) {
|
||||
reindexRequest.setDestDocType("tweet_and_doc");
|
||||
}
|
||||
if (randomBoolean()) {
|
||||
reindexRequest.setDestOpType("create");
|
||||
}
|
||||
|
@ -752,49 +737,6 @@ public class RequestConvertersTests extends OpenSearchTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void testIndexWithType() throws IOException {
|
||||
String index = randomAlphaOfLengthBetween(3, 10);
|
||||
String type = randomAlphaOfLengthBetween(3, 10);
|
||||
IndexRequest indexRequest = new IndexRequest(index, type);
|
||||
String id = randomBoolean() ? randomAlphaOfLengthBetween(3, 10) : null;
|
||||
indexRequest.id(id);
|
||||
|
||||
String method = HttpPost.METHOD_NAME;
|
||||
if (id != null) {
|
||||
method = HttpPut.METHOD_NAME;
|
||||
if (randomBoolean()) {
|
||||
indexRequest.opType(DocWriteRequest.OpType.CREATE);
|
||||
}
|
||||
}
|
||||
XContentType xContentType = randomFrom(XContentType.values());
|
||||
int nbFields = randomIntBetween(0, 10);
|
||||
try (XContentBuilder builder = XContentBuilder.builder(xContentType.xContent())) {
|
||||
builder.startObject();
|
||||
for (int i = 0; i < nbFields; i++) {
|
||||
builder.field("field_" + i, i);
|
||||
}
|
||||
builder.endObject();
|
||||
indexRequest.source(builder);
|
||||
}
|
||||
|
||||
Request request = RequestConverters.index(indexRequest);
|
||||
if (indexRequest.opType() == DocWriteRequest.OpType.CREATE) {
|
||||
assertEquals("/" + index + "/" + type + "/" + id + "/_create", request.getEndpoint());
|
||||
} else if (id != null) {
|
||||
assertEquals("/" + index + "/" + type + "/" + id, request.getEndpoint());
|
||||
} else {
|
||||
assertEquals("/" + index + "/" + type, request.getEndpoint());
|
||||
}
|
||||
assertEquals(method, request.getMethod());
|
||||
|
||||
HttpEntity entity = request.getEntity();
|
||||
assertTrue(entity instanceof NByteArrayEntity);
|
||||
assertEquals(indexRequest.getContentType().mediaTypeWithoutParameters(), entity.getContentType().getValue());
|
||||
try (XContentParser parser = createParser(xContentType.xContent(), entity.getContent())) {
|
||||
assertEquals(nbFields, parser.map().size());
|
||||
}
|
||||
}
|
||||
|
||||
public void testUpdate() throws IOException {
|
||||
XContentType xContentType = randomFrom(XContentType.values());
|
||||
|
||||
|
@ -903,23 +845,6 @@ public class RequestConvertersTests extends OpenSearchTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void testUpdateWithType() throws IOException {
|
||||
String index = randomAlphaOfLengthBetween(3, 10);
|
||||
String type = randomAlphaOfLengthBetween(3, 10);
|
||||
String id = randomAlphaOfLengthBetween(3, 10);
|
||||
|
||||
UpdateRequest updateRequest = new UpdateRequest(index, type, id);
|
||||
|
||||
XContentType xContentType = XContentType.JSON;
|
||||
BytesReference source = RandomObjects.randomSource(random(), xContentType);
|
||||
updateRequest.doc(new IndexRequest().source(source, xContentType));
|
||||
|
||||
Request request = RequestConverters.update(updateRequest);
|
||||
assertEquals("/" + index + "/" + type + "/" + id + "/_update", request.getEndpoint());
|
||||
assertEquals(HttpPost.METHOD_NAME, request.getMethod());
|
||||
assertToXContentBody(updateRequest, request.getEntity());
|
||||
}
|
||||
|
||||
public void testUpdateWithDifferentContentTypes() {
|
||||
IllegalStateException exception = expectThrows(IllegalStateException.class, () -> {
|
||||
UpdateRequest updateRequest = new UpdateRequest();
|
||||
|
@ -1014,7 +939,6 @@ public class RequestConvertersTests extends OpenSearchTestCase {
|
|||
|
||||
assertEquals(originalRequest.opType(), parsedRequest.opType());
|
||||
assertEquals(originalRequest.index(), parsedRequest.index());
|
||||
assertEquals(originalRequest.type(), parsedRequest.type());
|
||||
assertEquals(originalRequest.id(), parsedRequest.id());
|
||||
assertEquals(originalRequest.routing(), parsedRequest.routing());
|
||||
assertEquals(originalRequest.version(), parsedRequest.version());
|
||||
|
|
|
@ -117,7 +117,7 @@ public class TasksIT extends OpenSearchRestHighLevelClientTestCase {
|
|||
}
|
||||
org.opensearch.tasks.TaskInfo info = taskResponse.getTaskInfo();
|
||||
assertTrue(info.isCancellable());
|
||||
assertEquals("reindex from [source1] to [dest][_doc]", info.getDescription());
|
||||
assertEquals("reindex from [source1] to [dest]", info.getDescription());
|
||||
assertEquals("indices:data/write/reindex", info.getAction());
|
||||
if (taskResponse.isCompleted() == false) {
|
||||
assertBusy(checkTaskCompletionStatus(client(), taskId));
|
||||
|
|
|
@ -60,7 +60,6 @@ public class DateIndexNameProcessorTests extends OpenSearchTestCase {
|
|||
);
|
||||
IngestDocument document = new IngestDocument(
|
||||
"_index",
|
||||
"_type",
|
||||
"_id",
|
||||
null,
|
||||
null,
|
||||
|
@ -83,7 +82,6 @@ public class DateIndexNameProcessorTests extends OpenSearchTestCase {
|
|||
);
|
||||
IngestDocument document = new IngestDocument(
|
||||
"_index",
|
||||
"_type",
|
||||
"_id",
|
||||
null,
|
||||
null,
|
||||
|
@ -104,19 +102,11 @@ public class DateIndexNameProcessorTests extends OpenSearchTestCase {
|
|||
"m",
|
||||
"yyyyMMdd"
|
||||
);
|
||||
IngestDocument document = new IngestDocument(
|
||||
"_index",
|
||||
"_type",
|
||||
"_id",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
Collections.singletonMap("_field", "1000500")
|
||||
);
|
||||
IngestDocument document = new IngestDocument("_index", "_id", null, null, null, Collections.singletonMap("_field", "1000500"));
|
||||
dateProcessor.execute(document);
|
||||
assertThat(document.getSourceAndMetadata().get("_index"), equalTo("<events-{19700101||/m{yyyyMMdd|UTC}}>"));
|
||||
|
||||
document = new IngestDocument("_index", "_type", "_id", null, null, null, Collections.singletonMap("_field", 1000500L));
|
||||
document = new IngestDocument("_index", "_id", null, null, null, Collections.singletonMap("_field", 1000500L));
|
||||
dateProcessor.execute(document);
|
||||
assertThat(document.getSourceAndMetadata().get("_index"), equalTo("<events-{19700101||/m{yyyyMMdd|UTC}}>"));
|
||||
}
|
||||
|
@ -131,15 +121,7 @@ public class DateIndexNameProcessorTests extends OpenSearchTestCase {
|
|||
"m",
|
||||
"yyyyMMdd"
|
||||
);
|
||||
IngestDocument document = new IngestDocument(
|
||||
"_index",
|
||||
"_type",
|
||||
"_id",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
Collections.singletonMap("_field", "1000.5")
|
||||
);
|
||||
IngestDocument document = new IngestDocument("_index", "_id", null, null, null, Collections.singletonMap("_field", "1000.5"));
|
||||
dateProcessor.execute(document);
|
||||
assertThat(document.getSourceAndMetadata().get("_index"), equalTo("<events-{19700101||/m{yyyyMMdd|UTC}}>"));
|
||||
}
|
||||
|
@ -160,7 +142,7 @@ public class DateIndexNameProcessorTests extends OpenSearchTestCase {
|
|||
indexNameFormat
|
||||
);
|
||||
|
||||
IngestDocument document = new IngestDocument("_index", "_type", "_id", null, null, null, Collections.singletonMap("_field", date));
|
||||
IngestDocument document = new IngestDocument("_index", "_id", null, null, null, Collections.singletonMap("_field", date));
|
||||
dateProcessor.execute(document);
|
||||
|
||||
assertThat(
|
||||
|
|
|
@ -55,7 +55,6 @@ public class DissectProcessorTests extends OpenSearchTestCase {
|
|||
public void testMatch() {
|
||||
IngestDocument ingestDocument = new IngestDocument(
|
||||
"_index",
|
||||
"_type",
|
||||
"_id",
|
||||
null,
|
||||
null,
|
||||
|
@ -72,7 +71,6 @@ public class DissectProcessorTests extends OpenSearchTestCase {
|
|||
public void testMatchOverwrite() {
|
||||
IngestDocument ingestDocument = new IngestDocument(
|
||||
"_index",
|
||||
"_type",
|
||||
"_id",
|
||||
null,
|
||||
null,
|
||||
|
@ -90,7 +88,6 @@ public class DissectProcessorTests extends OpenSearchTestCase {
|
|||
public void testAdvancedMatch() {
|
||||
IngestDocument ingestDocument = new IngestDocument(
|
||||
"_index",
|
||||
"_type",
|
||||
"_id",
|
||||
null,
|
||||
null,
|
||||
|
@ -116,7 +113,6 @@ public class DissectProcessorTests extends OpenSearchTestCase {
|
|||
public void testMiss() {
|
||||
IngestDocument ingestDocument = new IngestDocument(
|
||||
"_index",
|
||||
"_type",
|
||||
"_id",
|
||||
null,
|
||||
null,
|
||||
|
|
|
@ -61,15 +61,7 @@ public class ForEachProcessorTests extends OpenSearchTestCase {
|
|||
values.add("foo");
|
||||
values.add("bar");
|
||||
values.add("baz");
|
||||
IngestDocument ingestDocument = new IngestDocument(
|
||||
"_index",
|
||||
"_type",
|
||||
"_id",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
Collections.singletonMap("values", values)
|
||||
);
|
||||
IngestDocument ingestDocument = new IngestDocument("_index", "_id", null, null, null, Collections.singletonMap("values", values));
|
||||
|
||||
ForEachProcessor processor = new ForEachProcessor("_tag", null, "values", new AsyncUpperCaseProcessor("_ingest._value"), false);
|
||||
processor.execute(ingestDocument, (result, e) -> {});
|
||||
|
@ -87,7 +79,6 @@ public class ForEachProcessorTests extends OpenSearchTestCase {
|
|||
public void testExecuteWithFailure() throws Exception {
|
||||
IngestDocument ingestDocument = new IngestDocument(
|
||||
"_index",
|
||||
"_type",
|
||||
"_id",
|
||||
null,
|
||||
null,
|
||||
|
@ -132,15 +123,7 @@ public class ForEachProcessorTests extends OpenSearchTestCase {
|
|||
List<Map<String, Object>> values = new ArrayList<>();
|
||||
values.add(new HashMap<>());
|
||||
values.add(new HashMap<>());
|
||||
IngestDocument ingestDocument = new IngestDocument(
|
||||
"_index",
|
||||
"_type",
|
||||
"_id",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
Collections.singletonMap("values", values)
|
||||
);
|
||||
IngestDocument ingestDocument = new IngestDocument("_index", "_id", null, null, null, Collections.singletonMap("values", values));
|
||||
|
||||
TestProcessor innerProcessor = new TestProcessor(id -> {
|
||||
id.setFieldValue("_ingest._value.index", id.getSourceAndMetadata().get("_index"));
|
||||
|
@ -152,10 +135,8 @@ public class ForEachProcessorTests extends OpenSearchTestCase {
|
|||
|
||||
assertThat(innerProcessor.getInvokedCounter(), equalTo(2));
|
||||
assertThat(ingestDocument.getFieldValue("values.0.index", String.class), equalTo("_index"));
|
||||
assertThat(ingestDocument.getFieldValue("values.0.type", String.class), equalTo("_type"));
|
||||
assertThat(ingestDocument.getFieldValue("values.0.id", String.class), equalTo("_id"));
|
||||
assertThat(ingestDocument.getFieldValue("values.1.index", String.class), equalTo("_index"));
|
||||
assertThat(ingestDocument.getFieldValue("values.1.type", String.class), equalTo("_type"));
|
||||
assertThat(ingestDocument.getFieldValue("values.1.id", String.class), equalTo("_id"));
|
||||
}
|
||||
|
||||
|
@ -170,7 +151,7 @@ public class ForEachProcessorTests extends OpenSearchTestCase {
|
|||
document.put("values", values);
|
||||
document.put("flat_values", new ArrayList<>());
|
||||
document.put("other", "value");
|
||||
IngestDocument ingestDocument = new IngestDocument("_index", "_type", "_id", null, null, null, document);
|
||||
IngestDocument ingestDocument = new IngestDocument("_index", "_id", null, null, null, document);
|
||||
|
||||
ForEachProcessor processor = new ForEachProcessor(
|
||||
"_tag",
|
||||
|
@ -220,15 +201,7 @@ public class ForEachProcessorTests extends OpenSearchTestCase {
|
|||
int numValues = randomIntBetween(1, 10000);
|
||||
List<String> values = IntStream.range(0, numValues).mapToObj(i -> "").collect(Collectors.toList());
|
||||
|
||||
IngestDocument ingestDocument = new IngestDocument(
|
||||
"_index",
|
||||
"_type",
|
||||
"_id",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
Collections.singletonMap("values", values)
|
||||
);
|
||||
IngestDocument ingestDocument = new IngestDocument("_index", "_id", null, null, null, Collections.singletonMap("values", values));
|
||||
|
||||
ForEachProcessor processor = new ForEachProcessor("_tag", null, "values", innerProcessor, false);
|
||||
processor.execute(ingestDocument, (result, e) -> {});
|
||||
|
@ -244,15 +217,7 @@ public class ForEachProcessorTests extends OpenSearchTestCase {
|
|||
values.add("string");
|
||||
values.add(1);
|
||||
values.add(null);
|
||||
IngestDocument ingestDocument = new IngestDocument(
|
||||
"_index",
|
||||
"_type",
|
||||
"_id",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
Collections.singletonMap("values", values)
|
||||
);
|
||||
IngestDocument ingestDocument = new IngestDocument("_index", "_id", null, null, null, Collections.singletonMap("values", values));
|
||||
|
||||
TemplateScript.Factory template = new TestTemplateService.MockTemplateScript.Factory("errors");
|
||||
|
||||
|
@ -290,7 +255,7 @@ public class ForEachProcessorTests extends OpenSearchTestCase {
|
|||
Map<String, Object> source = new HashMap<>();
|
||||
source.put("_value", "new_value");
|
||||
source.put("values", values);
|
||||
IngestDocument ingestDocument = new IngestDocument("_index", "_type", "_id", null, null, null, source);
|
||||
IngestDocument ingestDocument = new IngestDocument("_index", "_id", null, null, null, source);
|
||||
|
||||
TestProcessor processor = new TestProcessor(
|
||||
doc -> doc.setFieldValue("_ingest._value", doc.getFieldValue("_source._value", String.class))
|
||||
|
@ -320,15 +285,7 @@ public class ForEachProcessorTests extends OpenSearchTestCase {
|
|||
value.put("values2", innerValues);
|
||||
values.add(value);
|
||||
|
||||
IngestDocument ingestDocument = new IngestDocument(
|
||||
"_index",
|
||||
"_type",
|
||||
"_id",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
Collections.singletonMap("values1", values)
|
||||
);
|
||||
IngestDocument ingestDocument = new IngestDocument("_index", "_id", null, null, null, Collections.singletonMap("values1", values));
|
||||
|
||||
TestProcessor testProcessor = new TestProcessor(
|
||||
doc -> doc.setFieldValue("_ingest._value", doc.getFieldValue("_ingest._value", String.class).toUpperCase(Locale.ENGLISH))
|
||||
|
@ -352,7 +309,7 @@ public class ForEachProcessorTests extends OpenSearchTestCase {
|
|||
}
|
||||
|
||||
public void testIgnoreMissing() throws Exception {
|
||||
IngestDocument originalIngestDocument = new IngestDocument("_index", "_type", "_id", null, null, null, Collections.emptyMap());
|
||||
IngestDocument originalIngestDocument = new IngestDocument("_index", "_id", null, null, null, Collections.emptyMap());
|
||||
IngestDocument ingestDocument = new IngestDocument(originalIngestDocument);
|
||||
TestProcessor testProcessor = new TestProcessor(doc -> {});
|
||||
ForEachProcessor processor = new ForEachProcessor("_tag", null, "_ingest._value", testProcessor, true);
|
||||
|
@ -363,7 +320,7 @@ public class ForEachProcessorTests extends OpenSearchTestCase {
|
|||
|
||||
public void testAppendingToTheSameField() {
|
||||
Map<String, Object> source = Collections.singletonMap("field", Arrays.asList("a", "b"));
|
||||
IngestDocument originalIngestDocument = new IngestDocument("_index", "_type", "_id", null, null, null, source);
|
||||
IngestDocument originalIngestDocument = new IngestDocument("_index", "_id", null, null, null, source);
|
||||
IngestDocument ingestDocument = new IngestDocument(originalIngestDocument);
|
||||
TestProcessor testProcessor = new TestProcessor(id -> id.appendFieldValue("field", "a"));
|
||||
ForEachProcessor processor = new ForEachProcessor("_tag", null, "field", testProcessor, true);
|
||||
|
@ -375,7 +332,7 @@ public class ForEachProcessorTests extends OpenSearchTestCase {
|
|||
|
||||
public void testRemovingFromTheSameField() {
|
||||
Map<String, Object> source = Collections.singletonMap("field", Arrays.asList("a", "b"));
|
||||
IngestDocument originalIngestDocument = new IngestDocument("_index", "_id", "_type", null, null, null, source);
|
||||
IngestDocument originalIngestDocument = new IngestDocument("_index", "_id", null, null, null, source);
|
||||
IngestDocument ingestDocument = new IngestDocument(originalIngestDocument);
|
||||
TestProcessor testProcessor = new TestProcessor(id -> id.removeField("field.0"));
|
||||
ForEachProcessor processor = new ForEachProcessor("_tag", null, "field", testProcessor, true);
|
||||
|
|
|
@ -167,7 +167,7 @@ public class GeoIpProcessorNonIngestNodeIT extends OpenSearchIntegTestCase {
|
|||
internalCluster().getInstance(IngestService.class, ingestNode);
|
||||
// the geo-IP database should not be loaded yet as we have no indexed any documents using a pipeline that has a geo-IP processor
|
||||
assertDatabaseLoadStatus(ingestNode, false);
|
||||
final IndexRequest indexRequest = new IndexRequest("index", "_doc");
|
||||
final IndexRequest indexRequest = new IndexRequest("index");
|
||||
indexRequest.setPipeline("geoip");
|
||||
indexRequest.source(Collections.singletonMap("ip", "1.1.1.1"));
|
||||
final IndexResponse indexResponse = client().index(indexRequest).actionGet();
|
||||
|
|
|
@ -286,7 +286,7 @@ public class GeoIpProcessorFactoryTests extends OpenSearchTestCase {
|
|||
}
|
||||
|
||||
final Map<String, Object> field = Collections.singletonMap("_field", "1.1.1.1");
|
||||
final IngestDocument document = new IngestDocument("index", "type", "id", "routing", 1L, VersionType.EXTERNAL, field);
|
||||
final IngestDocument document = new IngestDocument("index", "id", "routing", 1L, VersionType.EXTERNAL, field);
|
||||
|
||||
Map<String, Object> config = new HashMap<>();
|
||||
config.put("field", "_field");
|
||||
|
@ -343,7 +343,7 @@ public class GeoIpProcessorFactoryTests extends OpenSearchTestCase {
|
|||
}
|
||||
|
||||
final Map<String, Object> field = Collections.singletonMap("_field", "1.1.1.1");
|
||||
final IngestDocument document = new IngestDocument("index", "type", "id", "routing", 1L, VersionType.EXTERNAL, field);
|
||||
final IngestDocument document = new IngestDocument("index", "id", "routing", 1L, VersionType.EXTERNAL, field);
|
||||
|
||||
Map<String, Object> config = new HashMap<>();
|
||||
config.put("field", "_field");
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
- match: { _index: test_1 }
|
||||
- match: { _id: "1" }
|
||||
- match: { _type: _doc }
|
||||
- match: { _version: 2 }
|
||||
|
||||
- do:
|
||||
|
@ -43,7 +42,6 @@
|
|||
|
||||
- match: { _index: test_1 }
|
||||
- match: { _id: "1" }
|
||||
- match: { _type: _doc }
|
||||
- match: { _version: 3 }
|
||||
|
||||
- do:
|
||||
|
@ -65,7 +63,6 @@
|
|||
|
||||
- match: { _index: test_1 }
|
||||
- match: { _id: "1" }
|
||||
- match: { _type: _doc }
|
||||
- match: { _version: 4 }
|
||||
|
||||
- do:
|
||||
|
@ -89,7 +86,6 @@
|
|||
|
||||
- match: { _index: test_1 }
|
||||
- match: { _id: "1" }
|
||||
- match: { _type: _doc }
|
||||
- match: { _version: 5 }
|
||||
|
||||
- do:
|
||||
|
|
|
@ -19,7 +19,6 @@ setup:
|
|||
- do:
|
||||
index:
|
||||
index: test
|
||||
type: _doc
|
||||
id: 1
|
||||
body:
|
||||
a_field: "quick brown fox jump lazy dog"
|
||||
|
@ -28,7 +27,6 @@ setup:
|
|||
- do:
|
||||
index:
|
||||
index: test
|
||||
type: _doc
|
||||
id: 2
|
||||
body:
|
||||
a_field: "xylophone xylophone xylophone"
|
||||
|
|
|
@ -22,7 +22,6 @@ setup:
|
|||
- do:
|
||||
index:
|
||||
index: test
|
||||
type: _doc
|
||||
id: 1
|
||||
body:
|
||||
a_field: "quick brown fox jump lazy dog"
|
||||
|
|
|
@ -311,7 +311,7 @@ public class ReindexDocumentationIT extends OpenSearchIntegTestCase {
|
|||
assertThat(ALLOWED_OPERATIONS.drainPermits(), equalTo(0));
|
||||
|
||||
ReindexRequestBuilder builder = new ReindexRequestBuilder(client, ReindexAction.INSTANCE).source(INDEX_NAME)
|
||||
.destination("target_index", "_doc");
|
||||
.destination("target_index");
|
||||
// Scroll by 1 so that cancellation is easier to control
|
||||
builder.source().setSize(1);
|
||||
|
||||
|
|
|
@ -341,15 +341,7 @@ public class AsyncBulkByScrollActionTests extends OpenSearchTestCase {
|
|||
}
|
||||
final int seqNo = randomInt(20);
|
||||
final int primaryTerm = randomIntBetween(1, 16);
|
||||
final IndexResponse response = new IndexResponse(
|
||||
shardId,
|
||||
"type",
|
||||
"id" + i,
|
||||
seqNo,
|
||||
primaryTerm,
|
||||
randomInt(),
|
||||
createdResponse
|
||||
);
|
||||
final IndexResponse response = new IndexResponse(shardId, "id" + i, seqNo, primaryTerm, randomInt(), createdResponse);
|
||||
responses[i] = new BulkItemResponse(i, opType, response);
|
||||
}
|
||||
assertExactlyOnce(onSuccess -> new DummyAsyncBulkByScrollAction().onBulkResponse(new BulkResponse(responses, 0), onSuccess));
|
||||
|
@ -596,7 +588,7 @@ public class AsyncBulkByScrollActionTests extends OpenSearchTestCase {
|
|||
DummyAsyncBulkByScrollAction action = new DummyActionWithoutBackoff();
|
||||
BulkRequest request = new BulkRequest();
|
||||
for (int i = 0; i < size + 1; i++) {
|
||||
request.add(new IndexRequest("index", "type", "id" + i));
|
||||
request.add(new IndexRequest("index").id("id" + i));
|
||||
}
|
||||
if (failWithRejection) {
|
||||
action.sendBulkRequest(request, Assert::fail);
|
||||
|
@ -945,7 +937,6 @@ public class AsyncBulkByScrollActionTests extends OpenSearchTestCase {
|
|||
IndexRequest index = (IndexRequest) item;
|
||||
response = new IndexResponse(
|
||||
shardId,
|
||||
index.type(),
|
||||
index.id() == null ? "dummy_id" : index.id(),
|
||||
randomInt(20),
|
||||
randomIntBetween(1, 16),
|
||||
|
@ -956,7 +947,6 @@ public class AsyncBulkByScrollActionTests extends OpenSearchTestCase {
|
|||
UpdateRequest update = (UpdateRequest) item;
|
||||
response = new UpdateResponse(
|
||||
shardId,
|
||||
update.type(),
|
||||
update.id(),
|
||||
randomNonNegativeLong(),
|
||||
randomIntBetween(1, Integer.MAX_VALUE),
|
||||
|
@ -967,7 +957,6 @@ public class AsyncBulkByScrollActionTests extends OpenSearchTestCase {
|
|||
DeleteRequest delete = (DeleteRequest) item;
|
||||
response = new DeleteResponse(
|
||||
shardId,
|
||||
delete.type(),
|
||||
delete.id(),
|
||||
randomInt(20),
|
||||
randomIntBetween(1, 16),
|
||||
|
|
|
@ -45,7 +45,6 @@ import org.opensearch.common.xcontent.XContentType;
|
|||
import org.opensearch.index.IndexModule;
|
||||
import org.opensearch.index.engine.Engine;
|
||||
import org.opensearch.index.engine.Engine.Operation.Origin;
|
||||
import org.opensearch.index.mapper.MapperService;
|
||||
import org.opensearch.index.query.QueryBuilders;
|
||||
import org.opensearch.index.shard.IndexingOperationListener;
|
||||
import org.opensearch.index.shard.ShardId;
|
||||
|
@ -116,7 +115,7 @@ public class CancelTests extends ReindexTestCase {
|
|||
false,
|
||||
true,
|
||||
IntStream.range(0, numDocs)
|
||||
.mapToObj(i -> client().prepareIndex(INDEX, MapperService.SINGLE_MAPPING_NAME, String.valueOf(i)).setSource("n", i))
|
||||
.mapToObj(i -> client().prepareIndex().setIndex(INDEX).setId(String.valueOf(i)).setSource("n", i))
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
|
||||
|
@ -247,17 +246,12 @@ public class CancelTests extends ReindexTestCase {
|
|||
}
|
||||
|
||||
public void testReindexCancel() throws Exception {
|
||||
testCancel(
|
||||
ReindexAction.NAME,
|
||||
reindex().source(INDEX).destination("dest", MapperService.SINGLE_MAPPING_NAME),
|
||||
(response, total, modified) -> {
|
||||
testCancel(ReindexAction.NAME, reindex().source(INDEX).destination("dest"), (response, total, modified) -> {
|
||||
assertThat(response, matcher().created(modified).reasonCancelled(equalTo("by user request")));
|
||||
|
||||
refresh("dest");
|
||||
assertHitCount(client().prepareSearch("dest").setSize(0).get(), modified);
|
||||
},
|
||||
equalTo("reindex from [" + INDEX + "] to [dest][" + MapperService.SINGLE_MAPPING_NAME + "]")
|
||||
);
|
||||
}, equalTo("reindex from [" + INDEX + "] to [dest]"));
|
||||
}
|
||||
|
||||
public void testUpdateByQueryCancel() throws Exception {
|
||||
|
@ -294,16 +288,13 @@ public class CancelTests extends ReindexTestCase {
|
|||
public void testReindexCancelWithWorkers() throws Exception {
|
||||
testCancel(
|
||||
ReindexAction.NAME,
|
||||
reindex().source(INDEX)
|
||||
.filter(QueryBuilders.matchAllQuery())
|
||||
.destination("dest", MapperService.SINGLE_MAPPING_NAME)
|
||||
.setSlices(5),
|
||||
reindex().source(INDEX).filter(QueryBuilders.matchAllQuery()).destination("dest").setSlices(5),
|
||||
(response, total, modified) -> {
|
||||
assertThat(response, matcher().created(modified).reasonCancelled(equalTo("by user request")).slices(hasSize(5)));
|
||||
refresh("dest");
|
||||
assertHitCount(client().prepareSearch("dest").setSize(0).get(), modified);
|
||||
},
|
||||
equalTo("reindex from [" + INDEX + "] to [dest][" + MapperService.SINGLE_MAPPING_NAME + "]")
|
||||
equalTo("reindex from [" + INDEX + "] to [dest]")
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -59,23 +59,23 @@ public class ReindexBasicTests extends ReindexTestCase {
|
|||
assertHitCount(client().prepareSearch("source").setSize(0).get(), 4);
|
||||
|
||||
// Copy all the docs
|
||||
ReindexRequestBuilder copy = reindex().source("source").destination("dest", "type").refresh(true);
|
||||
ReindexRequestBuilder copy = reindex().source("source").destination("dest").refresh(true);
|
||||
assertThat(copy.get(), matcher().created(4));
|
||||
assertHitCount(client().prepareSearch("dest").setSize(0).get(), 4);
|
||||
|
||||
// Now none of them
|
||||
createIndex("none");
|
||||
copy = reindex().source("source").destination("none", "type").filter(termQuery("foo", "no_match")).refresh(true);
|
||||
copy = reindex().source("source").destination("none").filter(termQuery("foo", "no_match")).refresh(true);
|
||||
assertThat(copy.get(), matcher().created(0));
|
||||
assertHitCount(client().prepareSearch("none").setSize(0).get(), 0);
|
||||
|
||||
// Now half of them
|
||||
copy = reindex().source("source").destination("dest_half", "type").filter(termQuery("foo", "a")).refresh(true);
|
||||
copy = reindex().source("source").destination("dest_half").filter(termQuery("foo", "a")).refresh(true);
|
||||
assertThat(copy.get(), matcher().created(2));
|
||||
assertHitCount(client().prepareSearch("dest_half").setSize(0).get(), 2);
|
||||
|
||||
// Limit with maxDocs
|
||||
copy = reindex().source("source").destination("dest_size_one", "type").maxDocs(1).refresh(true);
|
||||
copy = reindex().source("source").destination("dest_size_one").maxDocs(1).refresh(true);
|
||||
assertThat(copy.get(), matcher().created(1));
|
||||
assertHitCount(client().prepareSearch("dest_size_one").setSize(0).get(), 1);
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public class ReindexBasicTests extends ReindexTestCase {
|
|||
assertHitCount(client().prepareSearch("source").setSize(0).get(), max);
|
||||
|
||||
// Copy all the docs
|
||||
ReindexRequestBuilder copy = reindex().source("source").destination("dest", "type").refresh(true);
|
||||
ReindexRequestBuilder copy = reindex().source("source").destination("dest").refresh(true);
|
||||
// Use a small batch size so we have to use more than one batch
|
||||
copy.source().setSize(5);
|
||||
assertThat(copy.get(), matcher().created(max).batches(max, 5));
|
||||
|
@ -99,7 +99,7 @@ public class ReindexBasicTests extends ReindexTestCase {
|
|||
|
||||
// Copy some of the docs
|
||||
int half = max / 2;
|
||||
copy = reindex().source("source").destination("dest_half", "type").refresh(true);
|
||||
copy = reindex().source("source").destination("dest_half").refresh(true);
|
||||
// Use a small batch size so we have to use more than one batch
|
||||
copy.source().setSize(5);
|
||||
copy.maxDocs(half);
|
||||
|
@ -121,7 +121,7 @@ public class ReindexBasicTests extends ReindexTestCase {
|
|||
int expectedSlices = expectedSliceStatuses(slices, "source");
|
||||
|
||||
// Copy all the docs
|
||||
ReindexRequestBuilder copy = reindex().source("source").destination("dest", "type").refresh(true).setSlices(slices);
|
||||
ReindexRequestBuilder copy = reindex().source("source").destination("dest").refresh(true).setSlices(slices);
|
||||
// Use a small batch size so we have to use more than one batch
|
||||
copy.source().setSize(5);
|
||||
assertThat(copy.get(), matcher().created(max).batches(greaterThanOrEqualTo(max / 5)).slices(hasSize(expectedSlices)));
|
||||
|
@ -129,7 +129,7 @@ public class ReindexBasicTests extends ReindexTestCase {
|
|||
|
||||
// Copy some of the docs
|
||||
int half = max / 2;
|
||||
copy = reindex().source("source").destination("dest_half", "type").refresh(true).setSlices(slices);
|
||||
copy = reindex().source("source").destination("dest_half").refresh(true).setSlices(slices);
|
||||
// Use a small batch size so we have to use more than one batch
|
||||
copy.source().setSize(5);
|
||||
copy.maxDocs(half);
|
||||
|
@ -162,7 +162,7 @@ public class ReindexBasicTests extends ReindexTestCase {
|
|||
int expectedSlices = expectedSliceStatuses(slices, docs.keySet());
|
||||
|
||||
String[] sourceIndexNames = docs.keySet().toArray(new String[docs.size()]);
|
||||
ReindexRequestBuilder request = reindex().source(sourceIndexNames).destination("dest", "type").refresh(true).setSlices(slices);
|
||||
ReindexRequestBuilder request = reindex().source(sourceIndexNames).destination("dest").refresh(true).setSlices(slices);
|
||||
|
||||
BulkByScrollResponse response = request.get();
|
||||
assertThat(response, matcher().created(allDocs.size()).slices(hasSize(expectedSlices)));
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.opensearch.common.io.stream.NamedWriteableRegistry;
|
|||
import org.opensearch.common.xcontent.XContentBuilder;
|
||||
import org.opensearch.common.xcontent.XContentType;
|
||||
import org.opensearch.common.xcontent.json.JsonXContent;
|
||||
import org.opensearch.rest.RestRequest.Method;
|
||||
import org.opensearch.test.rest.FakeRestRequest;
|
||||
import org.opensearch.test.rest.RestActionTestCase;
|
||||
import org.junit.Before;
|
||||
|
@ -101,28 +100,4 @@ public class RestReindexActionTests extends RestActionTestCase {
|
|||
assertEquals("10m", request.getScrollTime().toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* test deprecation is logged if a type is used in the destination index request inside reindex
|
||||
*/
|
||||
public void testTypeInDestination() throws IOException {
|
||||
FakeRestRequest.Builder requestBuilder = new FakeRestRequest.Builder(xContentRegistry()).withMethod(Method.POST)
|
||||
.withPath("/_reindex");
|
||||
XContentBuilder b = JsonXContent.contentBuilder().startObject();
|
||||
{
|
||||
b.startObject("dest");
|
||||
{
|
||||
b.field("type", (randomBoolean() ? "_doc" : randomAlphaOfLength(4)));
|
||||
}
|
||||
b.endObject();
|
||||
}
|
||||
b.endObject();
|
||||
requestBuilder.withContent(new BytesArray(BytesReference.bytes(b).toBytesRef()), XContentType.JSON);
|
||||
|
||||
// We're not actually testing anything to do with the client, but need to set this so it doesn't fail the test for being unset.
|
||||
verifyingClient.setExecuteLocallyVerifier((arg1, arg2) -> null);
|
||||
|
||||
dispatchRequest(requestBuilder.build());
|
||||
assertWarnings(ReindexRequest.TYPES_DEPRECATION_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -203,7 +203,6 @@
|
|||
- do:
|
||||
index:
|
||||
index: test
|
||||
type: _doc
|
||||
id: 1
|
||||
body: { "text": "test" }
|
||||
- do:
|
||||
|
@ -212,7 +211,6 @@
|
|||
- do:
|
||||
index:
|
||||
index: test
|
||||
type: _doc
|
||||
id: 1
|
||||
body: { "text": "test2" }
|
||||
|
||||
|
|
|
@ -162,7 +162,6 @@
|
|||
- do:
|
||||
index:
|
||||
index: test
|
||||
type: _doc
|
||||
id: 1
|
||||
body: { "text": "test" }
|
||||
- do:
|
||||
|
@ -171,7 +170,6 @@
|
|||
- do:
|
||||
index:
|
||||
index: test
|
||||
type: _doc
|
||||
id: 1
|
||||
body: { "text": "test2" }
|
||||
|
||||
|
|
|
@ -198,12 +198,12 @@ public class ServerUtils {
|
|||
|
||||
public static void runOpenSearchTests() throws Exception {
|
||||
makeRequest(
|
||||
Request.Post("http://localhost:9200/library/book/1?refresh=true&pretty")
|
||||
Request.Post("http://localhost:9200/library/_doc/1?refresh=true&pretty")
|
||||
.bodyString("{ \"title\": \"Book #1\", \"pages\": 123 }", ContentType.APPLICATION_JSON)
|
||||
);
|
||||
|
||||
makeRequest(
|
||||
Request.Post("http://localhost:9200/library/book/2?refresh=true&pretty")
|
||||
Request.Post("http://localhost:9200/library/_doc/2?refresh=true&pretty")
|
||||
.bodyString("{ \"title\": \"Book #2\", \"pages\": 456 }", ContentType.APPLICATION_JSON)
|
||||
);
|
||||
|
||||
|
|
|
@ -48,9 +48,6 @@ import org.opensearch.common.util.concurrent.AbstractRunnable;
|
|||
import org.opensearch.common.xcontent.support.XContentMapValues;
|
||||
import org.opensearch.index.IndexSettings;
|
||||
import org.opensearch.rest.RestStatus;
|
||||
import org.opensearch.rest.action.document.RestGetAction;
|
||||
import org.opensearch.rest.action.document.RestIndexAction;
|
||||
import org.opensearch.rest.action.document.RestUpdateAction;
|
||||
import org.opensearch.test.rest.yaml.ObjectPath;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.Matchers;
|
||||
|
@ -67,7 +64,7 @@ import java.util.concurrent.Future;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static com.carrotsearch.randomizedtesting.RandomizedTest.randomAsciiOfLength;
|
||||
import static com.carrotsearch.randomizedtesting.RandomizedTest.randomAsciiLettersOfLength;
|
||||
import static org.opensearch.cluster.routing.UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING;
|
||||
import static org.opensearch.cluster.routing.allocation.decider.EnableAllocationDecider.INDEX_ROUTING_ALLOCATION_ENABLE_SETTING;
|
||||
import static org.opensearch.cluster.routing.allocation.decider.MaxRetryAllocationDecider.SETTING_ALLOCATION_MAX_RETRY;
|
||||
|
@ -124,7 +121,7 @@ public class RecoveryIT extends AbstractRollingTestCase {
|
|||
for (int i = 0; i < numDocs; i++) {
|
||||
final int id = idStart + i;
|
||||
Request indexDoc = new Request("PUT", index + "/_doc/" + id);
|
||||
indexDoc.setJsonEntity("{\"test\": \"test_" + randomAsciiOfLength(2) + "\"}");
|
||||
indexDoc.setJsonEntity("{\"test\": \"test_" + randomAsciiLettersOfLength(2) + "\"}");
|
||||
client().performRequest(indexDoc);
|
||||
}
|
||||
return numDocs;
|
||||
|
|
|
@ -46,7 +46,7 @@ public class IngestDocumentMustacheIT extends AbstractScriptTestCase {
|
|||
public void testAccessMetadataViaTemplate() {
|
||||
Map<String, Object> document = new HashMap<>();
|
||||
document.put("foo", "bar");
|
||||
IngestDocument ingestDocument = new IngestDocument("index", "type", "id", null, null, null, document);
|
||||
IngestDocument ingestDocument = new IngestDocument("index", "id", null, null, null, document);
|
||||
ingestDocument.setFieldValue(compile("field1"), ValueSource.wrap("1 {{foo}}", scriptService));
|
||||
assertThat(ingestDocument.getFieldValue("field1", String.class), equalTo("1 bar"));
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class IngestDocumentMustacheIT extends AbstractScriptTestCase {
|
|||
innerObject.put("baz", "hello baz");
|
||||
innerObject.put("qux", Collections.singletonMap("fubar", "hello qux and fubar"));
|
||||
document.put("foo", innerObject);
|
||||
IngestDocument ingestDocument = new IngestDocument("index", "type", "id", null, null, null, document);
|
||||
IngestDocument ingestDocument = new IngestDocument("index", "id", null, null, null, document);
|
||||
ingestDocument.setFieldValue(compile("field1"),
|
||||
ValueSource.wrap("1 {{foo.bar}} {{foo.baz}} {{foo.qux.fubar}}", scriptService));
|
||||
assertThat(ingestDocument.getFieldValue("field1", String.class), equalTo("1 hello bar hello baz hello qux and fubar"));
|
||||
|
@ -80,7 +80,7 @@ public class IngestDocumentMustacheIT extends AbstractScriptTestCase {
|
|||
list.add(value);
|
||||
list.add(null);
|
||||
document.put("list2", list);
|
||||
IngestDocument ingestDocument = new IngestDocument("index", "type", "id", null, null, null, document);
|
||||
IngestDocument ingestDocument = new IngestDocument("index", "id", null, null, null, document);
|
||||
ingestDocument.setFieldValue(compile("field1"), ValueSource.wrap("1 {{list1.0}} {{list2.0}}", scriptService));
|
||||
assertThat(ingestDocument.getFieldValue("field1", String.class), equalTo("1 foo {field=value}"));
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public class IngestDocumentMustacheIT extends AbstractScriptTestCase {
|
|||
Map<String, Object> ingestMap = new HashMap<>();
|
||||
ingestMap.put("timestamp", "bogus_timestamp");
|
||||
document.put("_ingest", ingestMap);
|
||||
IngestDocument ingestDocument = new IngestDocument("index", "type", "id", null, null, null, document);
|
||||
IngestDocument ingestDocument = new IngestDocument("index", "id", null, null, null, document);
|
||||
ingestDocument.setFieldValue(compile("ingest_timestamp"),
|
||||
ValueSource.wrap("{{_ingest.timestamp}} and {{_source._ingest.timestamp}}", scriptService));
|
||||
assertThat(ingestDocument.getFieldValue("ingest_timestamp", String.class),
|
||||
|
|
|
@ -77,7 +77,7 @@ public class ValueSourceMustacheIT extends AbstractScriptTestCase {
|
|||
}
|
||||
|
||||
public void testAccessSourceViaTemplate() {
|
||||
IngestDocument ingestDocument = new IngestDocument("marvel", "type", "id", null, null, null, new HashMap<>());
|
||||
IngestDocument ingestDocument = new IngestDocument("marvel", "id", null, null, null, new HashMap<>());
|
||||
assertThat(ingestDocument.hasField("marvel"), is(false));
|
||||
ingestDocument.setFieldValue(compile("{{_index}}"), ValueSource.wrap("{{_index}}", scriptService));
|
||||
assertThat(ingestDocument.getFieldValue("marvel", String.class), equalTo("marvel"));
|
||||
|
|
|
@ -295,7 +295,6 @@
|
|||
"docs": [
|
||||
{
|
||||
"_index": "index",
|
||||
"_type": "type",
|
||||
"_id": "id",
|
||||
"_source": {
|
||||
"foo": "bar"
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
- do:
|
||||
index:
|
||||
index: twitter
|
||||
type: _doc
|
||||
id: 1
|
||||
body: { "user": "foobar" }
|
||||
- do:
|
||||
|
|
|
@ -35,53 +35,6 @@
|
|||
"description":"The name of the index"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"path":"/{index}/{type}",
|
||||
"methods":[
|
||||
"POST"
|
||||
],
|
||||
"parts":{
|
||||
"index":{
|
||||
"type":"string",
|
||||
"description":"The name of the index"
|
||||
},
|
||||
"type":{
|
||||
"type":"string",
|
||||
"description":"The type of the document",
|
||||
"deprecated":true
|
||||
}
|
||||
},
|
||||
"deprecated":{
|
||||
"version":"7.0.0",
|
||||
"description":"Specifying types in urls has been deprecated"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path":"/{index}/{type}/{id}",
|
||||
"methods":[
|
||||
"PUT",
|
||||
"POST"
|
||||
],
|
||||
"parts":{
|
||||
"id":{
|
||||
"type":"string",
|
||||
"description":"Document ID"
|
||||
},
|
||||
"index":{
|
||||
"type":"string",
|
||||
"description":"The name of the index"
|
||||
},
|
||||
"type":{
|
||||
"type":"string",
|
||||
"description":"The type of the document",
|
||||
"deprecated":true
|
||||
}
|
||||
},
|
||||
"deprecated":{
|
||||
"version":"7.0.0",
|
||||
"description":"Specifying types in urls has been deprecated"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
---
|
||||
"External version":
|
||||
|
||||
- do:
|
||||
catch: bad_request
|
||||
create:
|
||||
index: test
|
||||
id: 1
|
||||
body: { foo: bar }
|
||||
version_type: external
|
||||
version: 0
|
||||
|
||||
- match: { status: 400 }
|
||||
- match: { error.type: action_request_validation_exception }
|
||||
- match: { error.reason: "Validation Failed: 1: create operations only support internal versioning. use index instead;" }
|
||||
|
||||
- do:
|
||||
catch: bad_request
|
||||
create:
|
||||
index: test
|
||||
id: 2
|
||||
body: { foo: bar }
|
||||
version_type: external
|
||||
version: 5
|
||||
|
||||
- match: { status: 400 }
|
||||
- match: { error.type: action_request_validation_exception }
|
||||
- match: { error.reason: "Validation Failed: 1: create operations only support internal versioning. use index instead;" }
|
|
@ -29,7 +29,6 @@
|
|||
id: 1
|
||||
|
||||
- match: { _index: foobar }
|
||||
- match: { _type: _doc }
|
||||
- match: { _id: "1"}
|
||||
- match: { _version: 2}
|
||||
- match: { _shards.total: 1}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
one: 3
|
||||
|
||||
- match: { _index: test_1 }
|
||||
- match: { _type: _doc }
|
||||
- match: { _id: "1" }
|
||||
- match: { _version: 2 }
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
foo: baz
|
||||
|
||||
- match: { _index: foobar }
|
||||
- match: { _type: _doc }
|
||||
- match: { _id: "1"}
|
||||
- match: { _version: 2}
|
||||
- match: { _shards.total: 1}
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
one: 3
|
||||
|
||||
- match: { _index: test_1 }
|
||||
- match: { _type: _doc }
|
||||
- match: { _id: "1" }
|
||||
- match: { _version: 2 }
|
||||
|
||||
|
|
|
@ -234,11 +234,7 @@ public class IndicesRequestIT extends OpenSearchIntegTestCase {
|
|||
String[] indexShardActions = new String[] { BulkAction.NAME + "[s][p]", BulkAction.NAME + "[s][r]" };
|
||||
interceptTransportActions(indexShardActions);
|
||||
|
||||
IndexRequest indexRequest = new IndexRequest(randomIndexOrAlias(), "type", "id").source(
|
||||
Requests.INDEX_CONTENT_TYPE,
|
||||
"field",
|
||||
"value"
|
||||
);
|
||||
IndexRequest indexRequest = new IndexRequest(randomIndexOrAlias()).id("id").source(Requests.INDEX_CONTENT_TYPE, "field", "value");
|
||||
internalCluster().coordOnlyNodeClient().index(indexRequest).actionGet();
|
||||
|
||||
clearInterceptedActions();
|
||||
|
@ -249,7 +245,7 @@ public class IndicesRequestIT extends OpenSearchIntegTestCase {
|
|||
String[] deleteShardActions = new String[] { BulkAction.NAME + "[s][p]", BulkAction.NAME + "[s][r]" };
|
||||
interceptTransportActions(deleteShardActions);
|
||||
|
||||
DeleteRequest deleteRequest = new DeleteRequest(randomIndexOrAlias(), "type", "id");
|
||||
DeleteRequest deleteRequest = new DeleteRequest(randomIndexOrAlias()).id("id");
|
||||
internalCluster().coordOnlyNodeClient().delete(deleteRequest).actionGet();
|
||||
|
||||
clearInterceptedActions();
|
||||
|
@ -263,7 +259,7 @@ public class IndicesRequestIT extends OpenSearchIntegTestCase {
|
|||
|
||||
String indexOrAlias = randomIndexOrAlias();
|
||||
client().prepareIndex(indexOrAlias, "type", "id").setSource("field", "value").get();
|
||||
UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "type", "id").doc(Requests.INDEX_CONTENT_TYPE, "field1", "value1");
|
||||
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());
|
||||
|
||||
|
@ -277,7 +273,7 @@ public class IndicesRequestIT extends OpenSearchIntegTestCase {
|
|||
interceptTransportActions(updateShardActions);
|
||||
|
||||
String indexOrAlias = randomIndexOrAlias();
|
||||
UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "type", "id").upsert(Requests.INDEX_CONTENT_TYPE, "field", "value")
|
||||
UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "id").upsert(Requests.INDEX_CONTENT_TYPE, "field", "value")
|
||||
.doc(Requests.INDEX_CONTENT_TYPE, "field1", "value1");
|
||||
UpdateResponse updateResponse = internalCluster().coordOnlyNodeClient().update(updateRequest).actionGet();
|
||||
assertEquals(DocWriteResponse.Result.CREATED, updateResponse.getResult());
|
||||
|
@ -293,7 +289,7 @@ public class IndicesRequestIT extends OpenSearchIntegTestCase {
|
|||
|
||||
String indexOrAlias = randomIndexOrAlias();
|
||||
client().prepareIndex(indexOrAlias, "type", "id").setSource("field", "value").get();
|
||||
UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "type", "id").script(
|
||||
UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "id").script(
|
||||
new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "ctx.op='delete'", Collections.emptyMap())
|
||||
);
|
||||
UpdateResponse updateResponse = internalCluster().coordOnlyNodeClient().update(updateRequest).actionGet();
|
||||
|
@ -312,19 +308,19 @@ public class IndicesRequestIT extends OpenSearchIntegTestCase {
|
|||
int numIndexRequests = iterations(1, 10);
|
||||
for (int i = 0; i < numIndexRequests; i++) {
|
||||
String indexOrAlias = randomIndexOrAlias();
|
||||
bulkRequest.add(new IndexRequest(indexOrAlias, "type", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value"));
|
||||
bulkRequest.add(new IndexRequest(indexOrAlias).id("id").source(Requests.INDEX_CONTENT_TYPE, "field", "value"));
|
||||
indices.add(indexOrAlias);
|
||||
}
|
||||
int numDeleteRequests = iterations(1, 10);
|
||||
for (int i = 0; i < numDeleteRequests; i++) {
|
||||
String indexOrAlias = randomIndexOrAlias();
|
||||
bulkRequest.add(new DeleteRequest(indexOrAlias, "type", "id"));
|
||||
bulkRequest.add(new DeleteRequest(indexOrAlias).id("id"));
|
||||
indices.add(indexOrAlias);
|
||||
}
|
||||
int numUpdateRequests = iterations(1, 10);
|
||||
for (int i = 0; i < numUpdateRequests; i++) {
|
||||
String indexOrAlias = randomIndexOrAlias();
|
||||
bulkRequest.add(new UpdateRequest(indexOrAlias, "type", "id").doc(Requests.INDEX_CONTENT_TYPE, "field1", "value1"));
|
||||
bulkRequest.add(new UpdateRequest(indexOrAlias, "id").doc(Requests.INDEX_CONTENT_TYPE, "field1", "value1"));
|
||||
indices.add(indexOrAlias);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public class ListenerActionIT extends OpenSearchIntegTestCase {
|
|||
final AtomicReference<String> threadName = new AtomicReference<>();
|
||||
Client client = client();
|
||||
|
||||
IndexRequest request = new IndexRequest("test", "type", "1");
|
||||
IndexRequest request = new IndexRequest("test").id("1");
|
||||
if (randomBoolean()) {
|
||||
// set the source, without it, we will have a verification failure
|
||||
request.source(Requests.INDEX_CONTENT_TYPE, "field1", "value1");
|
||||
|
|
|
@ -240,10 +240,8 @@ public class ShrinkIndexIT extends OpenSearchIntegTestCase {
|
|||
final String s = Integer.toString(id);
|
||||
final int hash = Math.floorMod(Murmur3HashFunction.hash(s), numberOfShards);
|
||||
if (hash == shardId) {
|
||||
final IndexRequest request = new IndexRequest("source", "type", s).source(
|
||||
"{ \"f\": \"" + s + "\"}",
|
||||
XContentType.JSON
|
||||
);
|
||||
final IndexRequest request = new IndexRequest("source").id(s)
|
||||
.source("{ \"f\": \"" + s + "\"}", XContentType.JSON);
|
||||
client().index(request).get();
|
||||
break;
|
||||
} else {
|
||||
|
|
|
@ -345,10 +345,8 @@ public class SplitIndexIT extends OpenSearchIntegTestCase {
|
|||
final String s = Integer.toString(id);
|
||||
final int hash = Math.floorMod(Murmur3HashFunction.hash(s), numberOfShards);
|
||||
if (hash == shardId) {
|
||||
final IndexRequest request = new IndexRequest("source", "type", s).source(
|
||||
"{ \"f\": \"" + s + "\"}",
|
||||
XContentType.JSON
|
||||
);
|
||||
final IndexRequest request = new IndexRequest("source").id(s)
|
||||
.source("{ \"f\": \"" + s + "\"}", XContentType.JSON);
|
||||
client().index(request).get();
|
||||
break;
|
||||
} else {
|
||||
|
|
|
@ -116,7 +116,7 @@ public class BulkIntegrationIT extends OpenSearchIntegTestCase {
|
|||
.setSettings(twoShardsSettings)
|
||||
.get();
|
||||
|
||||
IndexRequest indexRequestWithAlias = new IndexRequest("alias1", "type", "id");
|
||||
IndexRequest indexRequestWithAlias = new IndexRequest("alias1").id("id");
|
||||
if (randomBoolean()) {
|
||||
indexRequestWithAlias.routing("1");
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ public class BulkIntegrationIT extends OpenSearchIntegTestCase {
|
|||
|
||||
// allowing the auto-generated timestamp to externally be set would allow making the index inconsistent with duplicate docs
|
||||
public void testExternallySetAutoGeneratedTimestamp() {
|
||||
IndexRequest indexRequest = new IndexRequest("index1", "_doc").source(Collections.singletonMap("foo", "baz"));
|
||||
IndexRequest indexRequest = new IndexRequest("index1").source(Collections.singletonMap("foo", "baz"));
|
||||
indexRequest.process(Version.CURRENT, null, null); // sets the timestamp
|
||||
if (randomBoolean()) {
|
||||
indexRequest.id("test");
|
||||
|
|
|
@ -248,17 +248,14 @@ public class BulkProcessorIT extends OpenSearchIntegTestCase {
|
|||
if (randomBoolean()) {
|
||||
testDocs++;
|
||||
processor.add(
|
||||
new IndexRequest("test", "test", Integer.toString(testDocs)).source(Requests.INDEX_CONTENT_TYPE, "field", "value")
|
||||
new IndexRequest("test").id(Integer.toString(testDocs)).source(Requests.INDEX_CONTENT_TYPE, "field", "value")
|
||||
);
|
||||
multiGetRequestBuilder.add("test", Integer.toString(testDocs));
|
||||
} else {
|
||||
testReadOnlyDocs++;
|
||||
processor.add(
|
||||
new IndexRequest("test-ro", "test", Integer.toString(testReadOnlyDocs)).source(
|
||||
Requests.INDEX_CONTENT_TYPE,
|
||||
"field",
|
||||
"value"
|
||||
)
|
||||
new IndexRequest("test-ro").id(Integer.toString(testReadOnlyDocs))
|
||||
.source(Requests.INDEX_CONTENT_TYPE, "field", "value")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -297,11 +294,8 @@ public class BulkProcessorIT extends OpenSearchIntegTestCase {
|
|||
MultiGetRequestBuilder multiGetRequestBuilder = client.prepareMultiGet();
|
||||
for (int i = 1; i <= numDocs; i++) {
|
||||
processor.add(
|
||||
new IndexRequest("test", "test", Integer.toString(i)).source(
|
||||
Requests.INDEX_CONTENT_TYPE,
|
||||
"field",
|
||||
randomRealisticUnicodeOfLengthBetween(1, 30)
|
||||
)
|
||||
new IndexRequest("test").id(Integer.toString(i))
|
||||
.source(Requests.INDEX_CONTENT_TYPE, "field", randomRealisticUnicodeOfLengthBetween(1, 30))
|
||||
);
|
||||
multiGetRequestBuilder.add("test", Integer.toString(i));
|
||||
}
|
||||
|
|
|
@ -656,21 +656,21 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
|
|||
// issue 6630
|
||||
public void testThatFailedUpdateRequestReturnsCorrectType() throws Exception {
|
||||
BulkResponse indexBulkItemResponse = client().prepareBulk()
|
||||
.add(new IndexRequest("test", "type", "3").source("{ \"title\" : \"Great Title of doc 3\" }", XContentType.JSON))
|
||||
.add(new IndexRequest("test", "type", "4").source("{ \"title\" : \"Great Title of doc 4\" }", XContentType.JSON))
|
||||
.add(new IndexRequest("test", "type", "5").source("{ \"title\" : \"Great Title of doc 5\" }", XContentType.JSON))
|
||||
.add(new IndexRequest("test", "type", "6").source("{ \"title\" : \"Great Title of doc 6\" }", XContentType.JSON))
|
||||
.add(new IndexRequest("test").id("3").source("{ \"title\" : \"Great Title of doc 3\" }", XContentType.JSON))
|
||||
.add(new IndexRequest("test").id("4").source("{ \"title\" : \"Great Title of doc 4\" }", XContentType.JSON))
|
||||
.add(new IndexRequest("test").id("5").source("{ \"title\" : \"Great Title of doc 5\" }", XContentType.JSON))
|
||||
.add(new IndexRequest("test").id("6").source("{ \"title\" : \"Great Title of doc 6\" }", XContentType.JSON))
|
||||
.setRefreshPolicy(RefreshPolicy.IMMEDIATE)
|
||||
.get();
|
||||
assertNoFailures(indexBulkItemResponse);
|
||||
|
||||
BulkResponse bulkItemResponse = client().prepareBulk()
|
||||
.add(new IndexRequest("test", "type", "1").source("{ \"title\" : \"Great Title of doc 1\" }", XContentType.JSON))
|
||||
.add(new IndexRequest("test", "type", "2").source("{ \"title\" : \"Great Title of doc 2\" }", XContentType.JSON))
|
||||
.add(new UpdateRequest("test", "type", "3").doc("{ \"date\" : \"2014-01-30T23:59:57\"}", XContentType.JSON))
|
||||
.add(new UpdateRequest("test", "type", "4").doc("{ \"date\" : \"2014-13-30T23:59:57\"}", XContentType.JSON))
|
||||
.add(new DeleteRequest("test", "type", "5"))
|
||||
.add(new DeleteRequest("test", "type", "6"))
|
||||
.add(new IndexRequest("test").id("1").source("{ \"title\" : \"Great Title of doc 1\" }", XContentType.JSON))
|
||||
.add(new IndexRequest("test").id("2").source("{ \"title\" : \"Great Title of doc 2\" }", XContentType.JSON))
|
||||
.add(new UpdateRequest("test", "3").doc("{ \"date\" : \"2014-01-30T23:59:57\"}", XContentType.JSON))
|
||||
.add(new UpdateRequest("test", "4").doc("{ \"date\" : \"2014-13-30T23:59:57\"}", XContentType.JSON))
|
||||
.add(new DeleteRequest("test", "5"))
|
||||
.add(new DeleteRequest("test", "6"))
|
||||
.get();
|
||||
|
||||
assertNoFailures(indexBulkItemResponse);
|
||||
|
@ -691,11 +691,11 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
|
|||
public void testThatMissingIndexDoesNotAbortFullBulkRequest() throws Exception {
|
||||
createIndex("bulkindex1", "bulkindex2");
|
||||
BulkRequest bulkRequest = new BulkRequest();
|
||||
bulkRequest.add(new IndexRequest("bulkindex1", "index1_type", "1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo1"))
|
||||
.add(new IndexRequest("bulkindex2", "index2_type", "1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo2"))
|
||||
.add(new IndexRequest("bulkindex2", "index2_type").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo2"))
|
||||
.add(new UpdateRequest("bulkindex2", "index2_type", "2").doc(Requests.INDEX_CONTENT_TYPE, "foo", "bar"))
|
||||
.add(new DeleteRequest("bulkindex2", "index2_type", "3"))
|
||||
bulkRequest.add(new IndexRequest("bulkindex1").id("1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo1"))
|
||||
.add(new IndexRequest("bulkindex2").id("1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo2"))
|
||||
.add(new IndexRequest("bulkindex2").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo2"))
|
||||
.add(new UpdateRequest("bulkindex2", "2").doc(Requests.INDEX_CONTENT_TYPE, "foo", "bar"))
|
||||
.add(new DeleteRequest("bulkindex2", "3"))
|
||||
.setRefreshPolicy(RefreshPolicy.IMMEDIATE);
|
||||
|
||||
client().bulk(bulkRequest).get();
|
||||
|
@ -705,11 +705,11 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
|
|||
assertBusy(() -> assertAcked(client().admin().indices().prepareClose("bulkindex2")));
|
||||
|
||||
BulkRequest bulkRequest2 = new BulkRequest();
|
||||
bulkRequest2.add(new IndexRequest("bulkindex1", "index1_type", "1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo1"))
|
||||
.add(new IndexRequest("bulkindex2", "index2_type", "1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo2"))
|
||||
.add(new IndexRequest("bulkindex2", "index2_type").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo2"))
|
||||
.add(new UpdateRequest("bulkindex2", "index2_type", "2").doc(Requests.INDEX_CONTENT_TYPE, "foo", "bar"))
|
||||
.add(new DeleteRequest("bulkindex2", "index2_type", "3"))
|
||||
bulkRequest2.add(new IndexRequest("bulkindex1").id("1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo1"))
|
||||
.add(new IndexRequest("bulkindex2").id("1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo2"))
|
||||
.add(new IndexRequest("bulkindex2").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo2"))
|
||||
.add(new UpdateRequest("bulkindex2", "2").doc(Requests.INDEX_CONTENT_TYPE, "foo", "bar"))
|
||||
.add(new DeleteRequest("bulkindex2", "3"))
|
||||
.setRefreshPolicy(RefreshPolicy.IMMEDIATE);
|
||||
|
||||
BulkResponse bulkResponse = client().bulk(bulkRequest2).get();
|
||||
|
@ -725,9 +725,9 @@ public class BulkWithUpdatesIT extends OpenSearchIntegTestCase {
|
|||
assertBusy(() -> assertAcked(client().admin().indices().prepareClose("bulkindex1")));
|
||||
|
||||
BulkRequest bulkRequest = new BulkRequest().setRefreshPolicy(RefreshPolicy.IMMEDIATE);
|
||||
bulkRequest.add(new IndexRequest("bulkindex1", "index1_type", "1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo1"))
|
||||
.add(new UpdateRequest("bulkindex1", "index1_type", "1").doc(Requests.INDEX_CONTENT_TYPE, "foo", "bar"))
|
||||
.add(new DeleteRequest("bulkindex1", "index1_type", "1"));
|
||||
bulkRequest.add(new IndexRequest("bulkindex1").id("1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo1"))
|
||||
.add(new UpdateRequest("bulkindex1", "1").doc(Requests.INDEX_CONTENT_TYPE, "foo", "bar"))
|
||||
.add(new DeleteRequest("bulkindex1", "1"));
|
||||
|
||||
BulkResponse bulkResponse = client().bulk(bulkRequest).get();
|
||||
assertThat(bulkResponse.hasFailures(), is(true));
|
||||
|
|
|
@ -117,7 +117,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
|
|||
logger.info("--> indexing against [alias1], should fail now");
|
||||
IllegalArgumentException exception = expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> client().index(indexRequest("alias1").type("type1").id("1").source(source("2", "test"), XContentType.JSON)).actionGet()
|
||||
() -> client().index(indexRequest("alias1").id("1").source(source("2", "test"), XContentType.JSON)).actionGet()
|
||||
);
|
||||
assertThat(
|
||||
exception.getMessage(),
|
||||
|
@ -134,9 +134,8 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
|
|||
});
|
||||
|
||||
logger.info("--> indexing against [alias1], should work now");
|
||||
IndexResponse indexResponse = client().index(
|
||||
indexRequest("alias1").type("type1").id("1").source(source("1", "test"), XContentType.JSON)
|
||||
).actionGet();
|
||||
IndexResponse indexResponse = client().index(indexRequest("alias1").id("1").source(source("1", "test"), XContentType.JSON))
|
||||
.actionGet();
|
||||
assertThat(indexResponse.getIndex(), equalTo("test"));
|
||||
|
||||
logger.info("--> creating index [test_x]");
|
||||
|
@ -152,7 +151,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
|
|||
logger.info("--> indexing against [alias1], should fail now");
|
||||
exception = expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> client().index(indexRequest("alias1").type("type1").id("1").source(source("2", "test"), XContentType.JSON)).actionGet()
|
||||
() -> client().index(indexRequest("alias1").id("1").source(source("2", "test"), XContentType.JSON)).actionGet()
|
||||
);
|
||||
assertThat(
|
||||
exception.getMessage(),
|
||||
|
@ -164,10 +163,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
|
|||
);
|
||||
|
||||
logger.info("--> deleting against [alias1], should fail now");
|
||||
exception = expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> client().delete(deleteRequest("alias1").type("type1").id("1")).actionGet()
|
||||
);
|
||||
exception = expectThrows(IllegalArgumentException.class, () -> client().delete(deleteRequest("alias1").id("1")).actionGet());
|
||||
assertThat(
|
||||
exception.getMessage(),
|
||||
equalTo(
|
||||
|
@ -183,8 +179,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
|
|||
});
|
||||
|
||||
logger.info("--> indexing against [alias1], should work now");
|
||||
indexResponse = client().index(indexRequest("alias1").type("type1").id("1").source(source("1", "test"), XContentType.JSON))
|
||||
.actionGet();
|
||||
indexResponse = client().index(indexRequest("alias1").id("1").source(source("1", "test"), XContentType.JSON)).actionGet();
|
||||
assertThat(indexResponse.getIndex(), equalTo("test"));
|
||||
|
||||
assertAliasesVersionIncreases("test_x", () -> {
|
||||
|
@ -193,12 +188,11 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
|
|||
});
|
||||
|
||||
logger.info("--> indexing against [alias1], should work now");
|
||||
indexResponse = client().index(indexRequest("alias1").type("type1").id("1").source(source("1", "test"), XContentType.JSON))
|
||||
.actionGet();
|
||||
indexResponse = client().index(indexRequest("alias1").id("1").source(source("1", "test"), XContentType.JSON)).actionGet();
|
||||
assertThat(indexResponse.getIndex(), equalTo("test_x"));
|
||||
|
||||
logger.info("--> deleting against [alias1], should fail now");
|
||||
DeleteResponse deleteResponse = client().delete(deleteRequest("alias1").type("type1").id("1")).actionGet();
|
||||
DeleteResponse deleteResponse = client().delete(deleteRequest("alias1").id("1")).actionGet();
|
||||
assertThat(deleteResponse.getIndex(), equalTo("test_x"));
|
||||
|
||||
assertAliasesVersionIncreases("test_x", () -> {
|
||||
|
@ -207,8 +201,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
|
|||
});
|
||||
|
||||
logger.info("--> indexing against [alias1], should work against [test_x]");
|
||||
indexResponse = client().index(indexRequest("alias1").type("type1").id("1").source(source("1", "test"), XContentType.JSON))
|
||||
.actionGet();
|
||||
indexResponse = client().index(indexRequest("alias1").id("1").source(source("1", "test"), XContentType.JSON)).actionGet();
|
||||
assertThat(indexResponse.getIndex(), equalTo("test_x"));
|
||||
}
|
||||
|
||||
|
@ -290,28 +283,16 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
|
|||
|
||||
logger.info("--> indexing against [test]");
|
||||
client().index(
|
||||
indexRequest("test").type("type1")
|
||||
.id("1")
|
||||
.source(source("1", "foo test"), XContentType.JSON)
|
||||
.setRefreshPolicy(RefreshPolicy.IMMEDIATE)
|
||||
indexRequest("test").id("1").source(source("1", "foo test"), XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE)
|
||||
).actionGet();
|
||||
client().index(
|
||||
indexRequest("test").type("type1")
|
||||
.id("2")
|
||||
.source(source("2", "bar test"), XContentType.JSON)
|
||||
.setRefreshPolicy(RefreshPolicy.IMMEDIATE)
|
||||
indexRequest("test").id("2").source(source("2", "bar test"), XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE)
|
||||
).actionGet();
|
||||
client().index(
|
||||
indexRequest("test").type("type1")
|
||||
.id("3")
|
||||
.source(source("3", "baz test"), XContentType.JSON)
|
||||
.setRefreshPolicy(RefreshPolicy.IMMEDIATE)
|
||||
indexRequest("test").id("3").source(source("3", "baz test"), XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE)
|
||||
).actionGet();
|
||||
client().index(
|
||||
indexRequest("test").type("type1")
|
||||
.id("4")
|
||||
.source(source("4", "something else"), XContentType.JSON)
|
||||
.setRefreshPolicy(RefreshPolicy.IMMEDIATE)
|
||||
indexRequest("test").id("4").source(source("4", "something else"), XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE)
|
||||
).actionGet();
|
||||
|
||||
logger.info("--> checking single filtering alias search");
|
||||
|
@ -408,16 +389,16 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
|
|||
);
|
||||
|
||||
logger.info("--> indexing against [test1]");
|
||||
client().index(indexRequest("test1").type("type1").id("1").source(source("1", "foo test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test1").type("type1").id("2").source(source("2", "bar test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test1").type("type1").id("3").source(source("3", "baz test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test1").type("type1").id("4").source(source("4", "something else"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test1").id("1").source(source("1", "foo test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test1").id("2").source(source("2", "bar test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test1").id("3").source(source("3", "baz test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test1").id("4").source(source("4", "something else"), XContentType.JSON)).get();
|
||||
|
||||
logger.info("--> indexing against [test2]");
|
||||
client().index(indexRequest("test2").type("type1").id("5").source(source("5", "foo test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test2").type("type1").id("6").source(source("6", "bar test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test2").type("type1").id("7").source(source("7", "baz test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test2").type("type1").id("8").source(source("8", "something else"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test2").id("5").source(source("5", "foo test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test2").id("6").source(source("6", "bar test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test2").id("7").source(source("7", "baz test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test2").id("8").source(source("8", "something else"), XContentType.JSON)).get();
|
||||
|
||||
refresh();
|
||||
|
||||
|
@ -524,17 +505,17 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
|
|||
);
|
||||
|
||||
logger.info("--> indexing against [test1]");
|
||||
client().index(indexRequest("test1").type("type1").id("11").source(source("11", "foo test1"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test1").type("type1").id("12").source(source("12", "bar test1"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test1").type("type1").id("13").source(source("13", "baz test1"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test1").id("11").source(source("11", "foo test1"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test1").id("12").source(source("12", "bar test1"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test1").id("13").source(source("13", "baz test1"), XContentType.JSON)).get();
|
||||
|
||||
client().index(indexRequest("test2").type("type1").id("21").source(source("21", "foo test2"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test2").type("type1").id("22").source(source("22", "bar test2"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test2").type("type1").id("23").source(source("23", "baz test2"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test2").id("21").source(source("21", "foo test2"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test2").id("22").source(source("22", "bar test2"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test2").id("23").source(source("23", "baz test2"), XContentType.JSON)).get();
|
||||
|
||||
client().index(indexRequest("test3").type("type1").id("31").source(source("31", "foo test3"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test3").type("type1").id("32").source(source("32", "bar test3"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test3").type("type1").id("33").source(source("33", "baz test3"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test3").id("31").source(source("31", "foo test3"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test3").id("32").source(source("32", "bar test3"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test3").id("33").source(source("33", "baz test3"), XContentType.JSON)).get();
|
||||
|
||||
refresh();
|
||||
|
||||
|
@ -647,16 +628,16 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
|
|||
);
|
||||
|
||||
logger.info("--> indexing against [test1]");
|
||||
client().index(indexRequest("test1").type("type1").id("1").source(source("1", "foo test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test1").type("type1").id("2").source(source("2", "bar test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test1").type("type1").id("3").source(source("3", "baz test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test1").type("type1").id("4").source(source("4", "something else"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test1").id("1").source(source("1", "foo test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test1").id("2").source(source("2", "bar test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test1").id("3").source(source("3", "baz test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test1").id("4").source(source("4", "something else"), XContentType.JSON)).get();
|
||||
|
||||
logger.info("--> indexing against [test2]");
|
||||
client().index(indexRequest("test2").type("type1").id("5").source(source("5", "foo test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test2").type("type1").id("6").source(source("6", "bar test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test2").type("type1").id("7").source(source("7", "baz test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test2").type("type1").id("8").source(source("8", "something else"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test2").id("5").source(source("5", "foo test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test2").id("6").source(source("6", "bar test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test2").id("7").source(source("7", "baz test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest("test2").id("8").source(source("8", "something else"), XContentType.JSON)).get();
|
||||
|
||||
refresh();
|
||||
|
||||
|
@ -744,7 +725,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
|
|||
for (int i = 0; i < 10; i++) {
|
||||
final String aliasName = "alias" + i;
|
||||
assertAliasesVersionIncreases("test", () -> assertAcked(admin().indices().prepareAliases().addAlias("test", aliasName)));
|
||||
client().index(indexRequest(aliasName).type("type1").id("1").source(source("1", "test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest(aliasName).id("1").source(source("1", "test"), XContentType.JSON)).get();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -765,7 +746,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
|
|||
for (int i = 0; i < 10; i++) {
|
||||
final String aliasName = "alias" + i;
|
||||
assertAliasesVersionIncreases("test", () -> assertAcked(admin().indices().prepareAliases().addAlias("test", aliasName)));
|
||||
client().index(indexRequest(aliasName).type("type1").id("1").source(source("1", "test"), XContentType.JSON)).get();
|
||||
client().index(indexRequest(aliasName).id("1").source(source("1", "test"), XContentType.JSON)).get();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -787,8 +768,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
|
|||
"test",
|
||||
() -> assertAcked(admin().indices().prepareAliases().addAlias("test", aliasName))
|
||||
);
|
||||
client().index(indexRequest(aliasName).type("type1").id("1").source(source("1", "test"), XContentType.JSON))
|
||||
.actionGet();
|
||||
client().index(indexRequest(aliasName).id("1").source(source("1", "test"), XContentType.JSON)).actionGet();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ import org.opensearch.test.OpenSearchIntegTestCase;
|
|||
import java.io.IOException;
|
||||
|
||||
import static org.opensearch.client.Requests.indexRequest;
|
||||
import static org.opensearch.index.query.QueryBuilders.termQuery;
|
||||
import static org.opensearch.index.query.QueryBuilders.matchAllQuery;
|
||||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
|
@ -57,16 +57,16 @@ public class BroadcastActionsIT extends OpenSearchIntegTestCase {
|
|||
NumShards numShards = getNumShards("test");
|
||||
|
||||
logger.info("Running Cluster Health");
|
||||
client().index(indexRequest("test").type("type1").id("1").source(source("1", "test"))).actionGet();
|
||||
client().index(indexRequest("test").id("1").source(source("1", "test"))).actionGet();
|
||||
flush();
|
||||
client().index(indexRequest("test").type("type1").id("2").source(source("2", "test"))).actionGet();
|
||||
client().index(indexRequest("test").id("2").source(source("2", "test"))).actionGet();
|
||||
refresh();
|
||||
|
||||
logger.info("Count");
|
||||
// check count
|
||||
for (int i = 0; i < 5; i++) {
|
||||
// test successful
|
||||
SearchResponse countResponse = client().prepareSearch("test").setSize(0).setQuery(termQuery("_type", "type1")).get();
|
||||
SearchResponse countResponse = client().prepareSearch("test").setSize(0).setQuery(matchAllQuery()).get();
|
||||
assertThat(countResponse.getHits().getTotalHits().value, equalTo(2L));
|
||||
assertThat(countResponse.getTotalShards(), equalTo(numShards.numPrimaries));
|
||||
assertThat(countResponse.getSuccessfulShards(), equalTo(numShards.numPrimaries));
|
||||
|
|
|
@ -90,7 +90,6 @@ public class DocumentActionsIT extends OpenSearchIntegTestCase {
|
|||
.get();
|
||||
assertThat(indexResponse.getIndex(), equalTo(getConcreteIndexName()));
|
||||
assertThat(indexResponse.getId(), equalTo("1"));
|
||||
assertThat(indexResponse.getType(), equalTo("type1"));
|
||||
logger.info("Refreshing");
|
||||
RefreshResponse refreshResponse = refresh();
|
||||
assertThat(refreshResponse.getSuccessfulShards(), equalTo(numShards.totalNumShards));
|
||||
|
@ -145,7 +144,6 @@ public class DocumentActionsIT extends OpenSearchIntegTestCase {
|
|||
DeleteResponse deleteResponse = client().prepareDelete("test", "type1", "1").execute().actionGet();
|
||||
assertThat(deleteResponse.getIndex(), equalTo(getConcreteIndexName()));
|
||||
assertThat(deleteResponse.getId(), equalTo("1"));
|
||||
assertThat(deleteResponse.getType(), equalTo("type1"));
|
||||
logger.info("Refreshing");
|
||||
client().admin().indices().refresh(refreshRequest("test")).actionGet();
|
||||
|
||||
|
@ -156,9 +154,9 @@ public class DocumentActionsIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
logger.info("Index [type1/1]");
|
||||
client().index(indexRequest("test").type("type1").id("1").source(source("1", "test"))).actionGet();
|
||||
client().index(indexRequest("test").id("1").source(source("1", "test"))).actionGet();
|
||||
logger.info("Index [type1/2]");
|
||||
client().index(indexRequest("test").type("type1").id("2").source(source("2", "test2"))).actionGet();
|
||||
client().index(indexRequest("test").id("2").source(source("2", "test2"))).actionGet();
|
||||
|
||||
logger.info("Flushing");
|
||||
FlushResponse flushResult = client().admin().indices().prepareFlush("test").execute().actionGet();
|
||||
|
|
|
@ -71,7 +71,6 @@ public class InternalEngineMergeIT extends OpenSearchIntegTestCase {
|
|||
for (int j = 0; j < numDocs; ++j) {
|
||||
request.add(
|
||||
Requests.indexRequest("test")
|
||||
.type("type1")
|
||||
.id(Long.toString(id++))
|
||||
.source(jsonBuilder().startObject().field("l", randomLong()).endObject())
|
||||
);
|
||||
|
|
|
@ -93,10 +93,10 @@ public class DynamicMappingIT extends OpenSearchIntegTestCase {
|
|||
assertTrue(bulkResponse.hasFailures());
|
||||
}
|
||||
|
||||
private static void assertMappingsHaveField(GetMappingsResponse mappings, String index, String type, String field) throws IOException {
|
||||
private static void assertMappingsHaveField(GetMappingsResponse mappings, String index, String field) throws IOException {
|
||||
ImmutableOpenMap<String, MappingMetadata> indexMappings = mappings.getMappings().get("index");
|
||||
assertNotNull(indexMappings);
|
||||
MappingMetadata typeMappings = indexMappings.get(type);
|
||||
MappingMetadata typeMappings = indexMappings.get(MapperService.SINGLE_MAPPING_NAME);
|
||||
assertNotNull(typeMappings);
|
||||
Map<String, Object> typeMappingsMap = typeMappings.getSourceAsMap();
|
||||
Map<String, Object> properties = (Map<String, Object>) typeMappingsMap.get("properties");
|
||||
|
@ -134,9 +134,9 @@ public class DynamicMappingIT extends OpenSearchIntegTestCase {
|
|||
throw error.get();
|
||||
}
|
||||
Thread.sleep(2000);
|
||||
GetMappingsResponse mappings = client().admin().indices().prepareGetMappings("index").setTypes("type").get();
|
||||
GetMappingsResponse mappings = client().admin().indices().prepareGetMappings("index").get();
|
||||
for (int i = 0; i < indexThreads.length; ++i) {
|
||||
assertMappingsHaveField(mappings, "index", "type", "field" + i);
|
||||
assertMappingsHaveField(mappings, "index", "field" + i);
|
||||
}
|
||||
for (int i = 0; i < indexThreads.length; ++i) {
|
||||
assertTrue(client().prepareGet("index", Integer.toString(i)).get().isExists());
|
||||
|
|
|
@ -130,7 +130,7 @@ public class UpdateMappingIntegrationIT extends OpenSearchIntegTestCase {
|
|||
for (int rec = 0; rec < recCount; rec++) {
|
||||
String type = "type";
|
||||
String fieldName = "field_" + type + "_" + rec;
|
||||
assertConcreteMappingsOnAll("test", type, fieldName);
|
||||
assertConcreteMappingsOnAll("test", fieldName);
|
||||
}
|
||||
|
||||
client().admin()
|
||||
|
@ -377,7 +377,7 @@ public class UpdateMappingIntegrationIT extends OpenSearchIntegTestCase {
|
|||
* Waits until mappings for the provided fields exist on all nodes. Note, this waits for the current
|
||||
* started shards and checks for concrete mappings.
|
||||
*/
|
||||
private void assertConcreteMappingsOnAll(final String index, final String type, final String... fieldNames) {
|
||||
private void assertConcreteMappingsOnAll(final String index, final String... fieldNames) {
|
||||
Set<String> nodes = internalCluster().nodesInclude(index);
|
||||
assertThat(nodes, Matchers.not(Matchers.emptyIterable()));
|
||||
for (String node : nodes) {
|
||||
|
@ -390,17 +390,17 @@ public class UpdateMappingIntegrationIT extends OpenSearchIntegTestCase {
|
|||
assertNotNull("field " + fieldName + " doesn't exists on " + node, fieldType);
|
||||
}
|
||||
}
|
||||
assertMappingOnMaster(index, type, fieldNames);
|
||||
assertMappingOnMaster(index, fieldNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for the given mapping type to exists on the master node.
|
||||
*/
|
||||
private void assertMappingOnMaster(final String index, final String type, final String... fieldNames) {
|
||||
GetMappingsResponse response = client().admin().indices().prepareGetMappings(index).setTypes(type).get();
|
||||
private void assertMappingOnMaster(final String index, final String... fieldNames) {
|
||||
GetMappingsResponse response = client().admin().indices().prepareGetMappings(index).get();
|
||||
ImmutableOpenMap<String, MappingMetadata> mappings = response.getMappings().get(index);
|
||||
assertThat(mappings, notNullValue());
|
||||
MappingMetadata mappingMetadata = mappings.get(type);
|
||||
MappingMetadata mappingMetadata = mappings.get(MapperService.SINGLE_MAPPING_NAME);
|
||||
assertThat(mappingMetadata, notNullValue());
|
||||
|
||||
Map<String, Object> mappingSource = mappingMetadata.getSourceAsMap();
|
||||
|
|
|
@ -403,7 +403,7 @@ public class CircuitBreakerServiceIT extends OpenSearchIntegTestCase {
|
|||
int numRequests = inFlightRequestsLimit.bytesAsInt();
|
||||
BulkRequest bulkRequest = new BulkRequest();
|
||||
for (int i = 0; i < numRequests; i++) {
|
||||
IndexRequest indexRequest = new IndexRequest("index", "type", Integer.toString(i));
|
||||
IndexRequest indexRequest = new IndexRequest("index").id(Integer.toString(i));
|
||||
indexRequest.source(Requests.INDEX_CONTENT_TYPE, "field", "value", "num", i);
|
||||
bulkRequest.add(indexRequest);
|
||||
}
|
||||
|
|
|
@ -839,7 +839,7 @@ public class SimpleIndexTemplateIT extends OpenSearchIntegTestCase {
|
|||
.get();
|
||||
|
||||
client().prepareIndex("a1", "test", "test").setSource("{}", XContentType.JSON).get();
|
||||
BulkResponse response = client().prepareBulk().add(new IndexRequest("a2", "test", "test").source("{}", 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));
|
||||
assertThat(response.getItems()[0].getIndex(), equalTo("a2"));
|
||||
|
@ -856,7 +856,7 @@ public class SimpleIndexTemplateIT extends OpenSearchIntegTestCase {
|
|||
// an index that doesn't exist yet will succeed
|
||||
client().prepareIndex("b1", "test", "test").setSource("{}", XContentType.JSON).get();
|
||||
|
||||
response = client().prepareBulk().add(new IndexRequest("b2", "test", "test").source("{}", XContentType.JSON)).get();
|
||||
response = client().prepareBulk().add(new IndexRequest("b2").id("test").source("{}", XContentType.JSON)).get();
|
||||
assertThat(response.hasFailures(), is(false));
|
||||
assertThat(response.getItems()[0].isFailed(), equalTo(false));
|
||||
assertThat(response.getItems()[0].getId(), equalTo("test"));
|
||||
|
|
|
@ -138,7 +138,7 @@ public class IngestClientIT extends OpenSearchIntegTestCase {
|
|||
source.put("foo", "bar");
|
||||
source.put("fail", false);
|
||||
source.put("processed", true);
|
||||
IngestDocument ingestDocument = new IngestDocument("index", "type", "id", null, null, null, source);
|
||||
IngestDocument ingestDocument = new IngestDocument("index", "id", null, null, null, source);
|
||||
assertThat(simulateDocumentBaseResult.getIngestDocument().getSourceAndMetadata(), equalTo(ingestDocument.getSourceAndMetadata()));
|
||||
assertThat(simulateDocumentBaseResult.getFailure(), nullValue());
|
||||
|
||||
|
@ -167,7 +167,7 @@ public class IngestClientIT extends OpenSearchIntegTestCase {
|
|||
int numRequests = scaledRandomIntBetween(32, 128);
|
||||
BulkRequest bulkRequest = new BulkRequest();
|
||||
for (int i = 0; i < numRequests; i++) {
|
||||
IndexRequest indexRequest = new IndexRequest("index", "type", Integer.toString(i)).setPipeline("_id");
|
||||
IndexRequest indexRequest = new IndexRequest("index").id(Integer.toString(i)).setPipeline("_id");
|
||||
indexRequest.source(Requests.INDEX_CONTENT_TYPE, "field", "value", "fail", i % 2 == 0);
|
||||
bulkRequest.add(indexRequest);
|
||||
}
|
||||
|
@ -216,10 +216,10 @@ public class IngestClientIT extends OpenSearchIntegTestCase {
|
|||
client().admin().cluster().putPipeline(putPipelineRequest).get();
|
||||
|
||||
BulkRequest bulkRequest = new BulkRequest();
|
||||
IndexRequest indexRequest = new IndexRequest("index", "type", "1").setPipeline("_id");
|
||||
IndexRequest indexRequest = new IndexRequest("index").id("1").setPipeline("_id");
|
||||
indexRequest.source(Requests.INDEX_CONTENT_TYPE, "field1", "val1");
|
||||
bulkRequest.add(indexRequest);
|
||||
UpdateRequest updateRequest = new UpdateRequest("index", "type", "2");
|
||||
UpdateRequest updateRequest = new UpdateRequest("index", "2");
|
||||
updateRequest.doc("{}", Requests.INDEX_CONTENT_TYPE);
|
||||
updateRequest.upsert("{\"field1\":\"upserted_val\"}", XContentType.JSON).upsertRequest().setPipeline("_id");
|
||||
bulkRequest.add(updateRequest);
|
||||
|
|
|
@ -67,12 +67,12 @@ public class SimpleRecoveryIT extends OpenSearchIntegTestCase {
|
|||
|
||||
NumShards numShards = getNumShards("test");
|
||||
|
||||
client().index(indexRequest("test").type("type1").id("1").source(source("1", "test"), XContentType.JSON)).actionGet();
|
||||
client().index(indexRequest("test").id("1").source(source("1", "test"), XContentType.JSON)).actionGet();
|
||||
FlushResponse flushResponse = client().admin().indices().flush(flushRequest("test")).actionGet();
|
||||
assertThat(flushResponse.getTotalShards(), equalTo(numShards.totalNumShards));
|
||||
assertThat(flushResponse.getSuccessfulShards(), equalTo(numShards.numPrimaries));
|
||||
assertThat(flushResponse.getFailedShards(), equalTo(0));
|
||||
client().index(indexRequest("test").type("type1").id("2").source(source("2", "test"), XContentType.JSON)).actionGet();
|
||||
client().index(indexRequest("test").id("2").source(source("2", "test"), XContentType.JSON)).actionGet();
|
||||
RefreshResponse refreshResponse = client().admin().indices().refresh(refreshRequest("test")).actionGet();
|
||||
assertThat(refreshResponse.getTotalShards(), equalTo(numShards.totalNumShards));
|
||||
assertThat(refreshResponse.getSuccessfulShards(), equalTo(numShards.numPrimaries));
|
||||
|
|
|
@ -467,7 +467,7 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
|
|||
ensureGreen();
|
||||
{
|
||||
BulkResponse bulkResponse = client().prepareBulk()
|
||||
.add(Requests.indexRequest(indexOrAlias()).type("type1").id("1").source(Requests.INDEX_CONTENT_TYPE, "field", "value"))
|
||||
.add(Requests.indexRequest(indexOrAlias()).id("1").source(Requests.INDEX_CONTENT_TYPE, "field", "value"))
|
||||
.execute()
|
||||
.actionGet();
|
||||
assertThat(bulkResponse.getItems().length, equalTo(1));
|
||||
|
@ -484,13 +484,7 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
|
|||
|
||||
{
|
||||
BulkResponse bulkResponse = client().prepareBulk()
|
||||
.add(
|
||||
Requests.indexRequest(indexOrAlias())
|
||||
.type("type1")
|
||||
.id("1")
|
||||
.routing("0")
|
||||
.source(Requests.INDEX_CONTENT_TYPE, "field", "value")
|
||||
)
|
||||
.add(Requests.indexRequest(indexOrAlias()).id("1").routing("0").source(Requests.INDEX_CONTENT_TYPE, "field", "value"))
|
||||
.execute()
|
||||
.actionGet();
|
||||
assertThat(bulkResponse.hasFailures(), equalTo(false));
|
||||
|
@ -498,7 +492,7 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
|
|||
|
||||
{
|
||||
BulkResponse bulkResponse = client().prepareBulk()
|
||||
.add(new UpdateRequest(indexOrAlias(), "type1", "1").doc(Requests.INDEX_CONTENT_TYPE, "field", "value2"))
|
||||
.add(new UpdateRequest(indexOrAlias(), "1").doc(Requests.INDEX_CONTENT_TYPE, "field", "value2"))
|
||||
.execute()
|
||||
.actionGet();
|
||||
assertThat(bulkResponse.getItems().length, equalTo(1));
|
||||
|
@ -515,17 +509,14 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
|
|||
|
||||
{
|
||||
BulkResponse bulkResponse = client().prepareBulk()
|
||||
.add(new UpdateRequest(indexOrAlias(), "type1", "1").doc(Requests.INDEX_CONTENT_TYPE, "field", "value2").routing("0"))
|
||||
.add(new UpdateRequest(indexOrAlias(), "1").doc(Requests.INDEX_CONTENT_TYPE, "field", "value2").routing("0"))
|
||||
.execute()
|
||||
.actionGet();
|
||||
assertThat(bulkResponse.hasFailures(), equalTo(false));
|
||||
}
|
||||
|
||||
{
|
||||
BulkResponse bulkResponse = client().prepareBulk()
|
||||
.add(Requests.deleteRequest(indexOrAlias()).type("type1").id("1"))
|
||||
.execute()
|
||||
.actionGet();
|
||||
BulkResponse bulkResponse = client().prepareBulk().add(Requests.deleteRequest(indexOrAlias()).id("1")).execute().actionGet();
|
||||
assertThat(bulkResponse.getItems().length, equalTo(1));
|
||||
assertThat(bulkResponse.hasFailures(), equalTo(true));
|
||||
|
||||
|
@ -540,7 +531,7 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
|
|||
|
||||
{
|
||||
BulkResponse bulkResponse = client().prepareBulk()
|
||||
.add(Requests.deleteRequest(indexOrAlias()).type("type1").id("1").routing("0"))
|
||||
.add(Requests.deleteRequest(indexOrAlias()).id("1").routing("0"))
|
||||
.execute()
|
||||
.actionGet();
|
||||
assertThat(bulkResponse.getItems().length, equalTo(1));
|
||||
|
|
|
@ -136,7 +136,7 @@ public class TransportSearchFailuresIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
private void index(Client client, String id, String nameValue, int age) throws IOException {
|
||||
client.index(Requests.indexRequest("test").type("type").id(id).source(source(id, nameValue, age))).actionGet();
|
||||
client.index(Requests.indexRequest("test").id(id).source(source(id, nameValue, age))).actionGet();
|
||||
}
|
||||
|
||||
private XContentBuilder source(String id, String nameValue, int age) throws IOException {
|
||||
|
|
|
@ -109,7 +109,7 @@ public class TransportTwoNodesSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
private void index(String id, String nameValue, int age) throws IOException {
|
||||
client().index(Requests.indexRequest("test").type("type").id(id).source(source(id, nameValue, age))).actionGet();
|
||||
client().index(Requests.indexRequest("test").id(id).source(source(id, nameValue, age))).actionGet();
|
||||
}
|
||||
|
||||
private XContentBuilder source(String id, String nameValue, int age) throws IOException {
|
||||
|
|
|
@ -94,9 +94,8 @@ public class FetchSubPhasePluginIT extends OpenSearchIntegTestCase {
|
|||
)
|
||||
.get();
|
||||
|
||||
client().index(
|
||||
indexRequest("test").type("type1").id("1").source(jsonBuilder().startObject().field("test", "I am sam i am").endObject())
|
||||
).actionGet();
|
||||
client().index(indexRequest("test").id("1").source(jsonBuilder().startObject().field("test", "I am sam i am").endObject()))
|
||||
.actionGet();
|
||||
|
||||
client().admin().indices().prepareRefresh().get();
|
||||
|
||||
|
|
|
@ -645,14 +645,10 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
)
|
||||
);
|
||||
client().index(
|
||||
indexRequest("test").type("type1")
|
||||
.id("1")
|
||||
.source(jsonBuilder().startObject().field("test", "value").field("num1", "2013-05-27").endObject())
|
||||
indexRequest("test").id("1").source(jsonBuilder().startObject().field("test", "value").field("num1", "2013-05-27").endObject())
|
||||
).actionGet();
|
||||
client().index(
|
||||
indexRequest("test").type("type1")
|
||||
.id("2")
|
||||
.source(jsonBuilder().startObject().field("test", "value").field("num1", "2013-05-28").endObject())
|
||||
indexRequest("test").id("2").source(jsonBuilder().startObject().field("test", "value").field("num1", "2013-05-28").endObject())
|
||||
).actionGet();
|
||||
refresh();
|
||||
|
||||
|
@ -690,13 +686,11 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
)
|
||||
);
|
||||
client().index(
|
||||
indexRequest("test").type("type1")
|
||||
.id("1")
|
||||
indexRequest("test").id("1")
|
||||
.source(jsonBuilder().startObject().field("test", "value").field("num1", System.currentTimeMillis()).endObject())
|
||||
).actionGet();
|
||||
client().index(
|
||||
indexRequest("test").type("type1")
|
||||
.id("2")
|
||||
indexRequest("test").id("2")
|
||||
.source(
|
||||
jsonBuilder().startObject()
|
||||
.field("test", "value")
|
||||
|
@ -749,24 +743,18 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
);
|
||||
|
||||
client().index(
|
||||
indexRequest("test").type("type1")
|
||||
.id("1")
|
||||
indexRequest("test").id("1")
|
||||
.source(jsonBuilder().startObject().field("test", "value").field("num1", "2013-05-27").field("num2", "1.0").endObject())
|
||||
).actionGet();
|
||||
client().index(
|
||||
indexRequest("test").type("type1")
|
||||
.id("2")
|
||||
.source(jsonBuilder().startObject().field("test", "value").field("num2", "1.0").endObject())
|
||||
indexRequest("test").id("2").source(jsonBuilder().startObject().field("test", "value").field("num2", "1.0").endObject())
|
||||
).actionGet();
|
||||
client().index(
|
||||
indexRequest("test").type("type1")
|
||||
.id("3")
|
||||
indexRequest("test").id("3")
|
||||
.source(jsonBuilder().startObject().field("test", "value").field("num1", "2013-05-30").field("num2", "1.0").endObject())
|
||||
).actionGet();
|
||||
client().index(
|
||||
indexRequest("test").type("type1")
|
||||
.id("4")
|
||||
.source(jsonBuilder().startObject().field("test", "value").field("num1", "2013-05-30").endObject())
|
||||
indexRequest("test").id("4").source(jsonBuilder().startObject().field("test", "value").field("num1", "2013-05-30").endObject())
|
||||
).actionGet();
|
||||
|
||||
refresh();
|
||||
|
@ -827,9 +815,7 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
+ "-"
|
||||
+ String.format(Locale.ROOT, "%02d", docDate.getDayOfMonth());
|
||||
client().index(
|
||||
indexRequest("test").type("type1")
|
||||
.id("1")
|
||||
.source(jsonBuilder().startObject().field("test", "value").field("num1", docDateString).endObject())
|
||||
indexRequest("test").id("1").source(jsonBuilder().startObject().field("test", "value").field("num1", docDateString).endObject())
|
||||
).actionGet();
|
||||
docDate = dt.minusDays(2);
|
||||
docDateString = docDate.getYear()
|
||||
|
@ -838,9 +824,7 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
+ "-"
|
||||
+ String.format(Locale.ROOT, "%02d", docDate.getDayOfMonth());
|
||||
client().index(
|
||||
indexRequest("test").type("type1")
|
||||
.id("2")
|
||||
.source(jsonBuilder().startObject().field("test", "value").field("num1", docDateString).endObject())
|
||||
indexRequest("test").id("2").source(jsonBuilder().startObject().field("test", "value").field("num1", docDateString).endObject())
|
||||
).actionGet();
|
||||
docDate = dt.minusDays(3);
|
||||
docDateString = docDate.getYear()
|
||||
|
@ -849,9 +833,7 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
+ "-"
|
||||
+ String.format(Locale.ROOT, "%02d", docDate.getDayOfMonth());
|
||||
client().index(
|
||||
indexRequest("test").type("type1")
|
||||
.id("3")
|
||||
.source(jsonBuilder().startObject().field("test", "value").field("num1", docDateString).endObject())
|
||||
indexRequest("test").id("3").source(jsonBuilder().startObject().field("test", "value").field("num1", docDateString).endObject())
|
||||
).actionGet();
|
||||
|
||||
refresh();
|
||||
|
@ -987,8 +969,7 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
);
|
||||
int numDocs = 2;
|
||||
client().index(
|
||||
indexRequest("test").type("type")
|
||||
.source(
|
||||
indexRequest("test").source(
|
||||
jsonBuilder().startObject()
|
||||
.field("test", "value")
|
||||
.startObject("geo")
|
||||
|
@ -1040,8 +1021,7 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
)
|
||||
);
|
||||
client().index(
|
||||
indexRequest("test").type("type")
|
||||
.source(jsonBuilder().startObject().field("test", "value").field("num", Integer.toString(1)).endObject())
|
||||
indexRequest("test").source(jsonBuilder().startObject().field("test", "value").field("num", Integer.toString(1)).endObject())
|
||||
).actionGet();
|
||||
refresh();
|
||||
// so, we indexed a string field, but now we try to score a num field
|
||||
|
@ -1079,9 +1059,8 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
)
|
||||
);
|
||||
client().index(
|
||||
indexRequest("test").type("type").source(jsonBuilder().startObject().field("test", "value").field("num", 1.0).endObject())
|
||||
).actionGet();
|
||||
client().index(indexRequest("test").source(jsonBuilder().startObject().field("test", "value").field("num", 1.0).endObject()))
|
||||
.actionGet();
|
||||
refresh();
|
||||
// so, we indexed a string field, but now we try to score a num field
|
||||
ActionFuture<SearchResponse> response = client().search(
|
||||
|
|
|
@ -95,14 +95,10 @@ public class FunctionScorePluginIT extends OpenSearchIntegTestCase {
|
|||
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().get();
|
||||
|
||||
client().index(
|
||||
indexRequest("test").type("type1")
|
||||
.id("1")
|
||||
.source(jsonBuilder().startObject().field("test", "value").field("num1", "2013-05-26").endObject())
|
||||
indexRequest("test").id("1").source(jsonBuilder().startObject().field("test", "value").field("num1", "2013-05-26").endObject())
|
||||
).actionGet();
|
||||
client().index(
|
||||
indexRequest("test").type("type1")
|
||||
.id("2")
|
||||
.source(jsonBuilder().startObject().field("test", "value").field("num1", "2013-05-27").endObject())
|
||||
indexRequest("test").id("2").source(jsonBuilder().startObject().field("test", "value").field("num1", "2013-05-27").endObject())
|
||||
).actionGet();
|
||||
|
||||
client().admin().indices().prepareRefresh().get();
|
||||
|
|
|
@ -105,11 +105,9 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
|
|||
assertThat(ensureGreen(), equalTo(ClusterHealthStatus.GREEN));
|
||||
|
||||
logger.info("Indexing...");
|
||||
client().index(indexRequest("test").type("type1").id("1").source(jsonBuilder().startObject().field("text", "lucene").endObject()))
|
||||
client().index(indexRequest("test").id("1").source(jsonBuilder().startObject().field("text", "lucene").endObject())).actionGet();
|
||||
client().index(indexRequest("test").id("2").source(jsonBuilder().startObject().field("text", "lucene release").endObject()))
|
||||
.actionGet();
|
||||
client().index(
|
||||
indexRequest("test").type("type1").id("2").source(jsonBuilder().startObject().field("text", "lucene release").endObject())
|
||||
).actionGet();
|
||||
client().admin().indices().refresh(refreshRequest()).actionGet();
|
||||
|
||||
logger.info("Running moreLikeThis");
|
||||
|
@ -140,11 +138,9 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
|
|||
assertThat(ensureGreen(), equalTo(ClusterHealthStatus.GREEN));
|
||||
|
||||
logger.info("Indexing...");
|
||||
client().index(indexRequest("test").type("type1").id("1").source(jsonBuilder().startObject().field("text", "lucene").endObject()))
|
||||
client().index(indexRequest("test").id("1").source(jsonBuilder().startObject().field("text", "lucene").endObject())).actionGet();
|
||||
client().index(indexRequest("test").id("2").source(jsonBuilder().startObject().field("text", "lucene release").endObject()))
|
||||
.actionGet();
|
||||
client().index(
|
||||
indexRequest("test").type("type1").id("2").source(jsonBuilder().startObject().field("text", "lucene release").endObject())
|
||||
).actionGet();
|
||||
client().admin().indices().refresh(refreshRequest()).actionGet();
|
||||
|
||||
logger.info("Running moreLikeThis");
|
||||
|
@ -177,14 +173,10 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
|
|||
ensureGreen();
|
||||
|
||||
client().index(
|
||||
indexRequest("test").type("type")
|
||||
.id("1")
|
||||
.source(jsonBuilder().startObject().field("myField", "and_foo").field("empty", "").endObject())
|
||||
indexRequest("test").id("1").source(jsonBuilder().startObject().field("myField", "and_foo").field("empty", "").endObject())
|
||||
).actionGet();
|
||||
client().index(
|
||||
indexRequest("test").type("type")
|
||||
.id("2")
|
||||
.source(jsonBuilder().startObject().field("myField", "and_foo").field("empty", "").endObject())
|
||||
indexRequest("test").id("2").source(jsonBuilder().startObject().field("myField", "and_foo").field("empty", "").endObject())
|
||||
).actionGet();
|
||||
|
||||
client().admin().indices().refresh(refreshRequest()).actionGet();
|
||||
|
@ -206,13 +198,10 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
|
|||
assertThat(ensureGreen(), equalTo(ClusterHealthStatus.GREEN));
|
||||
|
||||
logger.info("Indexing...");
|
||||
client().index(
|
||||
indexRequest("test").type("type1").id("1").source(jsonBuilder().startObject().field("some_long", 1367484649580L).endObject())
|
||||
).actionGet();
|
||||
client().index(indexRequest("test").type("type1").id("2").source(jsonBuilder().startObject().field("some_long", 0).endObject()))
|
||||
.actionGet();
|
||||
client().index(indexRequest("test").type("type1").id("3").source(jsonBuilder().startObject().field("some_long", -666).endObject()))
|
||||
client().index(indexRequest("test").id("1").source(jsonBuilder().startObject().field("some_long", 1367484649580L).endObject()))
|
||||
.actionGet();
|
||||
client().index(indexRequest("test").id("2").source(jsonBuilder().startObject().field("some_long", 0).endObject())).actionGet();
|
||||
client().index(indexRequest("test").id("3").source(jsonBuilder().startObject().field("some_long", -666).endObject())).actionGet();
|
||||
|
||||
client().admin().indices().refresh(refreshRequest()).actionGet();
|
||||
|
||||
|
@ -251,18 +240,14 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
|
|||
assertThat(ensureGreen(), equalTo(ClusterHealthStatus.GREEN));
|
||||
|
||||
logger.info("Indexing...");
|
||||
client().index(
|
||||
indexRequest("test").type("type1").id("1").source(jsonBuilder().startObject().field("text", "lucene beta").endObject())
|
||||
).actionGet();
|
||||
client().index(
|
||||
indexRequest("test").type("type1").id("2").source(jsonBuilder().startObject().field("text", "lucene release").endObject())
|
||||
).actionGet();
|
||||
client().index(
|
||||
indexRequest("test").type("type1").id("3").source(jsonBuilder().startObject().field("text", "opensearch beta").endObject())
|
||||
).actionGet();
|
||||
client().index(
|
||||
indexRequest("test").type("type1").id("4").source(jsonBuilder().startObject().field("text", "opensearch release").endObject())
|
||||
).actionGet();
|
||||
client().index(indexRequest("test").id("1").source(jsonBuilder().startObject().field("text", "lucene beta").endObject()))
|
||||
.actionGet();
|
||||
client().index(indexRequest("test").id("2").source(jsonBuilder().startObject().field("text", "lucene release").endObject()))
|
||||
.actionGet();
|
||||
client().index(indexRequest("test").id("3").source(jsonBuilder().startObject().field("text", "opensearch beta").endObject()))
|
||||
.actionGet();
|
||||
client().index(indexRequest("test").id("4").source(jsonBuilder().startObject().field("text", "opensearch release").endObject()))
|
||||
.actionGet();
|
||||
client().admin().indices().refresh(refreshRequest()).actionGet();
|
||||
|
||||
logger.info("Running moreLikeThis on index");
|
||||
|
@ -308,15 +293,12 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
|
|||
|
||||
assertThat(ensureGreen(), equalTo(ClusterHealthStatus.GREEN));
|
||||
|
||||
client().index(
|
||||
indexRequest(indexName).type(typeName).id("1").source(jsonBuilder().startObject().field("text", "opensearch index").endObject())
|
||||
).actionGet();
|
||||
client().index(
|
||||
indexRequest(indexName).type(typeName).id("2").source(jsonBuilder().startObject().field("text", "lucene index").endObject())
|
||||
).actionGet();
|
||||
client().index(
|
||||
indexRequest(indexName).type(typeName).id("3").source(jsonBuilder().startObject().field("text", "opensearch index").endObject())
|
||||
).actionGet();
|
||||
client().index(indexRequest(indexName).id("1").source(jsonBuilder().startObject().field("text", "opensearch index").endObject()))
|
||||
.actionGet();
|
||||
client().index(indexRequest(indexName).id("2").source(jsonBuilder().startObject().field("text", "lucene index").endObject()))
|
||||
.actionGet();
|
||||
client().index(indexRequest(indexName).id("3").source(jsonBuilder().startObject().field("text", "opensearch index").endObject()))
|
||||
.actionGet();
|
||||
refresh(indexName);
|
||||
|
||||
SearchResponse response = client().prepareSearch()
|
||||
|
@ -561,8 +543,7 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
|
|||
|
||||
logger.info("Indexing...");
|
||||
client().index(
|
||||
indexRequest("test").type("type1")
|
||||
.id("1")
|
||||
indexRequest("test").id("1")
|
||||
.source(
|
||||
jsonBuilder().startObject()
|
||||
.field("text", "Apache Lucene is a free/open source information retrieval software library")
|
||||
|
@ -570,8 +551,7 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
|
|||
)
|
||||
).actionGet();
|
||||
client().index(
|
||||
indexRequest("test").type("type1")
|
||||
.id("2")
|
||||
indexRequest("test").id("2")
|
||||
.source(jsonBuilder().startObject().field("text", "Lucene has been ported to other programming languages").endObject())
|
||||
).actionGet();
|
||||
client().admin().indices().refresh(refreshRequest()).actionGet();
|
||||
|
|
|
@ -326,7 +326,7 @@ public class UpdateIT extends OpenSearchIntegTestCase {
|
|||
DocumentMissingException.class,
|
||||
() -> client().prepareUpdate(indexOrAlias(), "type1", "1").setScript(fieldIncScript).execute().actionGet()
|
||||
);
|
||||
assertEquals("[type1][1]: document missing", ex.getMessage());
|
||||
assertEquals("[1]: document missing", ex.getMessage());
|
||||
|
||||
client().prepareIndex("test", "type1", "1").setSource("field", 1).execute().actionGet();
|
||||
|
||||
|
|
|
@ -255,7 +255,8 @@ public class ConcurrentSeqNoVersioningIT extends AbstractDisruptionTestCase {
|
|||
version = version.previousTerm();
|
||||
}
|
||||
|
||||
IndexRequest indexRequest = new IndexRequest("test", "type", partition.id).source("value", random.nextInt())
|
||||
IndexRequest indexRequest = new IndexRequest("test").id(partition.id)
|
||||
.source("value", random.nextInt())
|
||||
.setIfPrimaryTerm(version.primaryTerm)
|
||||
.setIfSeqNo(version.seqNo);
|
||||
Consumer<HistoryOutput> historyResponse = partition.invoke(version);
|
||||
|
|
|
@ -578,8 +578,6 @@ public class SimpleVersioningIT extends OpenSearchIntegTestCase {
|
|||
sb.append(deleteResponse.getIndex());
|
||||
sb.append(" id=");
|
||||
sb.append(deleteResponse.getId());
|
||||
sb.append(" type=");
|
||||
sb.append(deleteResponse.getType());
|
||||
sb.append(" version=");
|
||||
sb.append(deleteResponse.getVersion());
|
||||
sb.append(" found=");
|
||||
|
@ -590,8 +588,6 @@ public class SimpleVersioningIT extends OpenSearchIntegTestCase {
|
|||
sb.append(indexResponse.getIndex());
|
||||
sb.append(" id=");
|
||||
sb.append(indexResponse.getId());
|
||||
sb.append(" type=");
|
||||
sb.append(indexResponse.getType());
|
||||
sb.append(" version=");
|
||||
sb.append(indexResponse.getVersion());
|
||||
sb.append(" created=");
|
||||
|
|
|
@ -71,18 +71,6 @@ public interface DocWriteRequest<T> extends IndicesRequest, Accountable {
|
|||
*/
|
||||
String index();
|
||||
|
||||
/**
|
||||
* Set the type for this request
|
||||
* @return the Request
|
||||
*/
|
||||
T type(String type);
|
||||
|
||||
/**
|
||||
* Get the type that this request operates on
|
||||
* @return the type
|
||||
*/
|
||||
String type();
|
||||
|
||||
/**
|
||||
* Get the id of the document for this request
|
||||
* @return the id
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
package org.opensearch.action;
|
||||
|
||||
import org.opensearch.Version;
|
||||
import org.opensearch.action.support.WriteRequest;
|
||||
import org.opensearch.action.support.WriteRequest.RefreshPolicy;
|
||||
import org.opensearch.action.support.WriteResponse;
|
||||
|
@ -45,6 +46,7 @@ import org.opensearch.common.xcontent.XContentBuilder;
|
|||
import org.opensearch.common.xcontent.XContentParser;
|
||||
import org.opensearch.index.Index;
|
||||
import org.opensearch.index.IndexSettings;
|
||||
import org.opensearch.index.mapper.MapperService;
|
||||
import org.opensearch.index.seqno.SequenceNumbers;
|
||||
import org.opensearch.index.shard.ShardId;
|
||||
import org.opensearch.rest.RestStatus;
|
||||
|
@ -66,7 +68,6 @@ public abstract class DocWriteResponse extends ReplicationResponse implements Wr
|
|||
|
||||
private static final String _SHARDS = "_shards";
|
||||
private static final String _INDEX = "_index";
|
||||
private static final String _TYPE = "_type";
|
||||
private static final String _ID = "_id";
|
||||
private static final String _VERSION = "_version";
|
||||
private static final String _SEQ_NO = "_seq_no";
|
||||
|
@ -127,16 +128,14 @@ public abstract class DocWriteResponse extends ReplicationResponse implements Wr
|
|||
|
||||
private final ShardId shardId;
|
||||
private final String id;
|
||||
private final String type;
|
||||
private final long version;
|
||||
private final long seqNo;
|
||||
private final long primaryTerm;
|
||||
private boolean forcedRefresh;
|
||||
protected final Result result;
|
||||
|
||||
public DocWriteResponse(ShardId shardId, String type, String id, long seqNo, long primaryTerm, long version, Result result) {
|
||||
public DocWriteResponse(ShardId shardId, String id, long seqNo, long primaryTerm, long version, Result result) {
|
||||
this.shardId = Objects.requireNonNull(shardId);
|
||||
this.type = Objects.requireNonNull(type);
|
||||
this.id = Objects.requireNonNull(id);
|
||||
this.seqNo = seqNo;
|
||||
this.primaryTerm = primaryTerm;
|
||||
|
@ -148,7 +147,10 @@ public abstract class DocWriteResponse extends ReplicationResponse implements Wr
|
|||
protected DocWriteResponse(ShardId shardId, StreamInput in) throws IOException {
|
||||
super(in);
|
||||
this.shardId = shardId;
|
||||
type = in.readString();
|
||||
if (in.getVersion().before(Version.V_2_0_0)) {
|
||||
String type = in.readString();
|
||||
assert MapperService.SINGLE_MAPPING_NAME.equals(type) : "Expected [_doc] but received [" + type + "]";
|
||||
}
|
||||
id = in.readString();
|
||||
version = in.readZLong();
|
||||
seqNo = in.readZLong();
|
||||
|
@ -164,7 +166,10 @@ public abstract class DocWriteResponse extends ReplicationResponse implements Wr
|
|||
protected DocWriteResponse(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
shardId = new ShardId(in);
|
||||
type = in.readString();
|
||||
if (in.getVersion().before(Version.V_2_0_0)) {
|
||||
String type = in.readString();
|
||||
assert MapperService.SINGLE_MAPPING_NAME.equals(type) : "Expected [_doc] but received [" + type + "]";
|
||||
}
|
||||
id = in.readString();
|
||||
version = in.readZLong();
|
||||
seqNo = in.readZLong();
|
||||
|
@ -194,16 +199,6 @@ public abstract class DocWriteResponse extends ReplicationResponse implements Wr
|
|||
return this.shardId;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of the document changed.
|
||||
*
|
||||
* @deprecated Types are in the process of being removed.
|
||||
*/
|
||||
@Deprecated
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
/**
|
||||
* The id of the document changed.
|
||||
*/
|
||||
|
@ -270,7 +265,7 @@ public abstract class DocWriteResponse extends ReplicationResponse implements Wr
|
|||
try {
|
||||
// encode the path components separately otherwise the path separators will be encoded
|
||||
encodedIndex = URLEncoder.encode(getIndex(), "UTF-8");
|
||||
encodedType = URLEncoder.encode(getType(), "UTF-8");
|
||||
encodedType = URLEncoder.encode(MapperService.SINGLE_MAPPING_NAME, "UTF-8");
|
||||
encodedId = URLEncoder.encode(getId(), "UTF-8");
|
||||
encodedRouting = routing == null ? null : URLEncoder.encode(routing, "UTF-8");
|
||||
} catch (final UnsupportedEncodingException e) {
|
||||
|
@ -308,7 +303,9 @@ public abstract class DocWriteResponse extends ReplicationResponse implements Wr
|
|||
}
|
||||
|
||||
private void writeWithoutShardId(StreamOutput out) throws IOException {
|
||||
out.writeString(type);
|
||||
if (out.getVersion().before(Version.V_2_0_0)) {
|
||||
out.writeString(MapperService.SINGLE_MAPPING_NAME);
|
||||
}
|
||||
out.writeString(id);
|
||||
out.writeZLong(version);
|
||||
out.writeZLong(seqNo);
|
||||
|
@ -328,7 +325,6 @@ public abstract class DocWriteResponse extends ReplicationResponse implements Wr
|
|||
public XContentBuilder innerToXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
ReplicationResponse.ShardInfo shardInfo = getShardInfo();
|
||||
builder.field(_INDEX, shardId.getIndexName());
|
||||
builder.field(_TYPE, type);
|
||||
builder.field(_ID, id).field(_VERSION, version).field(RESULT, getResult().getLowercase());
|
||||
if (forcedRefresh) {
|
||||
builder.field(FORCED_REFRESH, true);
|
||||
|
@ -359,8 +355,6 @@ public abstract class DocWriteResponse extends ReplicationResponse implements Wr
|
|||
if (_INDEX.equals(currentFieldName)) {
|
||||
// index uuid and shard id are unknown and can't be parsed back for now.
|
||||
context.setShardId(new ShardId(new Index(parser.text(), IndexMetadata.INDEX_UUID_NA_VALUE), -1));
|
||||
} else if (_TYPE.equals(currentFieldName)) {
|
||||
context.setType(parser.text());
|
||||
} else if (_ID.equals(currentFieldName)) {
|
||||
context.setId(parser.text());
|
||||
} else if (_VERSION.equals(currentFieldName)) {
|
||||
|
@ -399,7 +393,6 @@ public abstract class DocWriteResponse extends ReplicationResponse implements Wr
|
|||
public abstract static class Builder {
|
||||
|
||||
protected ShardId shardId = null;
|
||||
protected String type = null;
|
||||
protected String id = null;
|
||||
protected Long version = null;
|
||||
protected Result result = null;
|
||||
|
@ -416,14 +409,6 @@ public abstract class DocWriteResponse extends ReplicationResponse implements Wr
|
|||
this.shardId = shardId;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -268,7 +268,6 @@ class BulkPrimaryExecutionContext {
|
|||
Engine.IndexResult indexResult = (Engine.IndexResult) result;
|
||||
response = new IndexResponse(
|
||||
primary.shardId(),
|
||||
requestToExecute.type(),
|
||||
requestToExecute.id(),
|
||||
result.getSeqNo(),
|
||||
result.getTerm(),
|
||||
|
@ -279,7 +278,6 @@ class BulkPrimaryExecutionContext {
|
|||
Engine.DeleteResult deleteResult = (Engine.DeleteResult) result;
|
||||
response = new DeleteResponse(
|
||||
primary.shardId(),
|
||||
requestToExecute.type(),
|
||||
requestToExecute.id(),
|
||||
deleteResult.getSeqNo(),
|
||||
result.getTerm(),
|
||||
|
|
|
@ -949,7 +949,6 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
|||
indexRequest.opType(),
|
||||
new UpdateResponse(
|
||||
new ShardId(indexRequest.index(), IndexMetadata.INDEX_UUID_NA_VALUE, 0),
|
||||
indexRequest.type(),
|
||||
id,
|
||||
SequenceNumbers.UNASSIGNED_SEQ_NO,
|
||||
SequenceNumbers.UNASSIGNED_PRIMARY_TERM,
|
||||
|
@ -965,10 +964,9 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
|||
logger.debug(
|
||||
String.format(
|
||||
Locale.ROOT,
|
||||
"failed to execute pipeline [%s] for document [%s/%s/%s]",
|
||||
"failed to execute pipeline [%s] for document [%s/%s]",
|
||||
indexRequest.getPipeline(),
|
||||
indexRequest.index(),
|
||||
indexRequest.type(),
|
||||
indexRequest.id()
|
||||
),
|
||||
e
|
||||
|
|
|
@ -340,7 +340,7 @@ public class TransportShardBulkAction extends TransportWriteAction<BulkShardRequ
|
|||
final DeleteRequest request = context.getRequestToExecute();
|
||||
result = primary.applyDeleteOperationOnPrimary(
|
||||
version,
|
||||
request.type(),
|
||||
MapperService.SINGLE_MAPPING_NAME,
|
||||
request.id(),
|
||||
request.versionType(),
|
||||
request.ifSeqNo(),
|
||||
|
@ -353,7 +353,7 @@ public class TransportShardBulkAction extends TransportWriteAction<BulkShardRequ
|
|||
request.versionType(),
|
||||
new SourceToParse(
|
||||
request.index(),
|
||||
request.type(),
|
||||
MapperService.SINGLE_MAPPING_NAME,
|
||||
request.id(),
|
||||
request.source(),
|
||||
request.getContentType(),
|
||||
|
@ -370,7 +370,7 @@ public class TransportShardBulkAction extends TransportWriteAction<BulkShardRequ
|
|||
try {
|
||||
primary.mapperService()
|
||||
.merge(
|
||||
context.getRequestToExecute().type(),
|
||||
MapperService.SINGLE_MAPPING_NAME,
|
||||
new CompressedXContent(result.getRequiredMappingUpdate(), XContentType.JSON, ToXContent.EMPTY_PARAMS),
|
||||
MapperService.MergeReason.MAPPING_UPDATE_PREFLIGHT
|
||||
);
|
||||
|
@ -383,7 +383,7 @@ public class TransportShardBulkAction extends TransportWriteAction<BulkShardRequ
|
|||
mappingUpdater.updateMappings(
|
||||
result.getRequiredMappingUpdate(),
|
||||
primary.shardId(),
|
||||
context.getRequestToExecute().type(),
|
||||
MapperService.SINGLE_MAPPING_NAME,
|
||||
new ActionListener<Void>() {
|
||||
@Override
|
||||
public void onResponse(Void v) {
|
||||
|
@ -485,7 +485,6 @@ public class TransportShardBulkAction extends TransportWriteAction<BulkShardRequ
|
|||
updateResponse = new UpdateResponse(
|
||||
indexResponse.getShardInfo(),
|
||||
indexResponse.getShardId(),
|
||||
indexResponse.getType(),
|
||||
indexResponse.getId(),
|
||||
indexResponse.getSeqNo(),
|
||||
indexResponse.getPrimaryTerm(),
|
||||
|
@ -518,7 +517,6 @@ public class TransportShardBulkAction extends TransportWriteAction<BulkShardRequ
|
|||
updateResponse = new UpdateResponse(
|
||||
deleteResponse.getShardInfo(),
|
||||
deleteResponse.getShardId(),
|
||||
deleteResponse.getType(),
|
||||
deleteResponse.getId(),
|
||||
deleteResponse.getSeqNo(),
|
||||
deleteResponse.getPrimaryTerm(),
|
||||
|
@ -608,7 +606,7 @@ public class TransportShardBulkAction extends TransportWriteAction<BulkShardRequ
|
|||
final ShardId shardId = replica.shardId();
|
||||
final SourceToParse sourceToParse = new SourceToParse(
|
||||
shardId.getIndexName(),
|
||||
indexRequest.type(),
|
||||
MapperService.SINGLE_MAPPING_NAME,
|
||||
indexRequest.id(),
|
||||
indexRequest.source(),
|
||||
indexRequest.getContentType(),
|
||||
|
@ -629,7 +627,7 @@ public class TransportShardBulkAction extends TransportWriteAction<BulkShardRequ
|
|||
primaryResponse.getSeqNo(),
|
||||
primaryResponse.getPrimaryTerm(),
|
||||
primaryResponse.getVersion(),
|
||||
deleteRequest.type(),
|
||||
MapperService.SINGLE_MAPPING_NAME,
|
||||
deleteRequest.id()
|
||||
);
|
||||
break;
|
||||
|
|
|
@ -34,6 +34,7 @@ package org.opensearch.action.delete;
|
|||
|
||||
import org.apache.lucene.util.RamUsageEstimator;
|
||||
import org.opensearch.LegacyESVersion;
|
||||
import org.opensearch.Version;
|
||||
import org.opensearch.action.ActionRequestValidationException;
|
||||
import org.opensearch.action.CompositeIndicesRequest;
|
||||
import org.opensearch.action.DocWriteRequest;
|
||||
|
@ -57,7 +58,7 @@ import static org.opensearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO;
|
|||
* A request to delete a document from an index based on its type and id. Best created using
|
||||
* {@link org.opensearch.client.Requests#deleteRequest(String)}.
|
||||
* <p>
|
||||
* The operation requires the {@link #index()}, {@link #type(String)} and {@link #id(String)} to
|
||||
* The operation requires the {@link #index()}, and {@link #id(String)} to
|
||||
* be set.
|
||||
*
|
||||
* @see DeleteResponse
|
||||
|
@ -73,8 +74,6 @@ public class DeleteRequest extends ReplicatedWriteRequest<DeleteRequest>
|
|||
|
||||
private static final ShardId NO_SHARD_ID = null;
|
||||
|
||||
// Set to null initially so we can know to override in bulk requests that have a default type.
|
||||
private String type;
|
||||
private String id;
|
||||
@Nullable
|
||||
private String routing;
|
||||
|
@ -89,7 +88,10 @@ public class DeleteRequest extends ReplicatedWriteRequest<DeleteRequest>
|
|||
|
||||
public DeleteRequest(@Nullable ShardId shardId, StreamInput in) throws IOException {
|
||||
super(shardId, in);
|
||||
type = in.readString();
|
||||
if (in.getVersion().before(Version.V_2_0_0)) {
|
||||
String type = in.readString();
|
||||
assert MapperService.SINGLE_MAPPING_NAME.equals(type) : "Expected [_doc] but received [" + type + "]";
|
||||
}
|
||||
id = in.readString();
|
||||
routing = in.readOptionalString();
|
||||
if (in.getVersion().before(LegacyESVersion.V_7_0_0)) {
|
||||
|
@ -106,7 +108,7 @@ public class DeleteRequest extends ReplicatedWriteRequest<DeleteRequest>
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructs a new delete request against the specified index. The {@link #type(String)} and {@link #id(String)}
|
||||
* Constructs a new delete request against the specified index. The {@link #id(String)}
|
||||
* must be set.
|
||||
*/
|
||||
public DeleteRequest(String index) {
|
||||
|
@ -114,23 +116,6 @@ public class DeleteRequest extends ReplicatedWriteRequest<DeleteRequest>
|
|||
this.index = index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new delete request against the specified index with the type and id.
|
||||
*
|
||||
* @param index The index to get the document from
|
||||
* @param type The type of the document
|
||||
* @param id The id of the document
|
||||
*
|
||||
* @deprecated Types are in the process of being removed. Use {@link #DeleteRequest(String, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public DeleteRequest(String index, String type, String id) {
|
||||
super(NO_SHARD_ID);
|
||||
this.index = index;
|
||||
this.type = type;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new delete request against the specified index and id.
|
||||
*
|
||||
|
@ -146,9 +131,6 @@ public class DeleteRequest extends ReplicatedWriteRequest<DeleteRequest>
|
|||
@Override
|
||||
public ActionRequestValidationException validate() {
|
||||
ActionRequestValidationException validationException = super.validate();
|
||||
if (Strings.isEmpty(type())) {
|
||||
validationException = addValidationError("type is missing", validationException);
|
||||
}
|
||||
if (Strings.isEmpty(id)) {
|
||||
validationException = addValidationError("id is missing", validationException);
|
||||
}
|
||||
|
@ -158,32 +140,6 @@ public class DeleteRequest extends ReplicatedWriteRequest<DeleteRequest>
|
|||
return validationException;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of the document to delete.
|
||||
*
|
||||
* @deprecated Types are in the process of being removed.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public String type() {
|
||||
if (type == null) {
|
||||
return MapperService.SINGLE_MAPPING_NAME;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of the document to delete.
|
||||
*
|
||||
* @deprecated Types are in the process of being removed.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public DeleteRequest type(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The id of the document to delete.
|
||||
*/
|
||||
|
@ -317,9 +273,9 @@ public class DeleteRequest extends ReplicatedWriteRequest<DeleteRequest>
|
|||
}
|
||||
|
||||
private void writeBody(StreamOutput out) throws IOException {
|
||||
// A 7.x request allows null types but if deserialized in a 6.x node will cause nullpointer exceptions.
|
||||
// So we use the type accessor method here to make the type non-null (will default it to "_doc").
|
||||
out.writeString(type());
|
||||
if (out.getVersion().before(Version.V_2_0_0)) {
|
||||
out.writeString(MapperService.SINGLE_MAPPING_NAME);
|
||||
}
|
||||
out.writeString(id);
|
||||
out.writeOptionalString(routing());
|
||||
if (out.getVersion().before(LegacyESVersion.V_7_0_0)) {
|
||||
|
@ -333,7 +289,7 @@ public class DeleteRequest extends ReplicatedWriteRequest<DeleteRequest>
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "delete {[" + index + "][" + type() + "][" + id + "]}";
|
||||
return "delete {[" + index + "][" + id + "]}";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -55,9 +55,10 @@ public class DeleteRequestBuilder extends ReplicationRequestBuilder<DeleteReques
|
|||
|
||||
/**
|
||||
* Sets the type of the document to delete.
|
||||
* @deprecated types will be removed
|
||||
*/
|
||||
@Deprecated
|
||||
public DeleteRequestBuilder setType(String type) {
|
||||
request.type(type);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,12 +58,12 @@ public class DeleteResponse extends DocWriteResponse {
|
|||
super(in);
|
||||
}
|
||||
|
||||
public DeleteResponse(ShardId shardId, String type, String id, long seqNo, long primaryTerm, long version, boolean found) {
|
||||
this(shardId, type, id, seqNo, primaryTerm, version, found ? Result.DELETED : Result.NOT_FOUND);
|
||||
public DeleteResponse(ShardId shardId, String id, long seqNo, long primaryTerm, long version, boolean found) {
|
||||
this(shardId, id, seqNo, primaryTerm, version, found ? Result.DELETED : Result.NOT_FOUND);
|
||||
}
|
||||
|
||||
private DeleteResponse(ShardId shardId, String type, String id, long seqNo, long primaryTerm, long version, Result result) {
|
||||
super(shardId, type, id, seqNo, primaryTerm, version, assertDeletedOrNotFound(result));
|
||||
private DeleteResponse(ShardId shardId, String id, long seqNo, long primaryTerm, long version, Result result) {
|
||||
super(shardId, id, seqNo, primaryTerm, version, assertDeletedOrNotFound(result));
|
||||
}
|
||||
|
||||
private static Result assertDeletedOrNotFound(Result result) {
|
||||
|
@ -81,7 +81,6 @@ public class DeleteResponse extends DocWriteResponse {
|
|||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("DeleteResponse[");
|
||||
builder.append("index=").append(getIndex());
|
||||
builder.append(",type=").append(getType());
|
||||
builder.append(",id=").append(getId());
|
||||
builder.append(",version=").append(getVersion());
|
||||
builder.append(",result=").append(getResult().getLowercase());
|
||||
|
@ -115,7 +114,7 @@ public class DeleteResponse extends DocWriteResponse {
|
|||
|
||||
@Override
|
||||
public DeleteResponse build() {
|
||||
DeleteResponse deleteResponse = new DeleteResponse(shardId, type, id, seqNo, primaryTerm, version, result);
|
||||
DeleteResponse deleteResponse = new DeleteResponse(shardId, id, seqNo, primaryTerm, version, result);
|
||||
deleteResponse.setForcedRefresh(forcedRefresh);
|
||||
if (shardInfo != null) {
|
||||
deleteResponse.setShardInfo(shardInfo);
|
||||
|
|
|
@ -47,7 +47,6 @@ import org.opensearch.client.Requests;
|
|||
import org.opensearch.cluster.metadata.MappingMetadata;
|
||||
import org.opensearch.cluster.metadata.Metadata;
|
||||
import org.opensearch.common.Nullable;
|
||||
import org.opensearch.common.Strings;
|
||||
import org.opensearch.common.UUIDs;
|
||||
import org.opensearch.common.bytes.BytesArray;
|
||||
import org.opensearch.common.bytes.BytesReference;
|
||||
|
@ -77,7 +76,7 @@ import static org.opensearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO;
|
|||
* Index request to index a typed JSON document into a specific index and make it searchable. Best
|
||||
* created using {@link org.opensearch.client.Requests#indexRequest(String)}.
|
||||
*
|
||||
* The index requires the {@link #index()}, {@link #type(String)}, {@link #id(String)} and
|
||||
* The index requires the {@link #index()}, {@link #id(String)} and
|
||||
* {@link #source(byte[], XContentType)} to be set.
|
||||
*
|
||||
* The source (content to index) can be set in its bytes form using ({@link #source(byte[], XContentType)}),
|
||||
|
@ -103,8 +102,6 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
|
|||
|
||||
private static final ShardId NO_SHARD_ID = null;
|
||||
|
||||
// Set to null initially so we can know to override in bulk requests that have a default type.
|
||||
private String type;
|
||||
private String id;
|
||||
@Nullable
|
||||
private String routing;
|
||||
|
@ -143,7 +140,10 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
|
|||
|
||||
public IndexRequest(@Nullable ShardId shardId, StreamInput in) throws IOException {
|
||||
super(shardId, in);
|
||||
type = in.readOptionalString();
|
||||
if (in.getVersion().before(Version.V_2_0_0)) {
|
||||
String type = in.readOptionalString();
|
||||
assert MapperService.SINGLE_MAPPING_NAME.equals(type) : "Expected [_doc] but received [" + type + "]";
|
||||
}
|
||||
id = in.readOptionalString();
|
||||
routing = in.readOptionalString();
|
||||
if (in.getVersion().before(LegacyESVersion.V_7_0_0)) {
|
||||
|
@ -181,7 +181,7 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructs a new index request against the specific index. The {@link #type(String)}
|
||||
* Constructs a new index request against the specific index. The
|
||||
* {@link #source(byte[], XContentType)} must be set.
|
||||
*/
|
||||
public IndexRequest(String index) {
|
||||
|
@ -189,44 +189,12 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
|
|||
this.index = index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new index request against the specific index and type. The
|
||||
* {@link #source(byte[], XContentType)} must be set.
|
||||
* @deprecated Types are in the process of being removed. Use {@link #IndexRequest(String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public IndexRequest(String index, String type) {
|
||||
super(NO_SHARD_ID);
|
||||
this.index = index;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new index request against the index, type, id and using the source.
|
||||
*
|
||||
* @param index The index to index into
|
||||
* @param type The type to index into
|
||||
* @param id The id of document
|
||||
*
|
||||
* @deprecated Types are in the process of being removed. Use {@link #IndexRequest(String)} with {@link #id(String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public IndexRequest(String index, String type, String id) {
|
||||
super(NO_SHARD_ID);
|
||||
this.index = index;
|
||||
this.type = type;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionRequestValidationException validate() {
|
||||
ActionRequestValidationException validationException = super.validate();
|
||||
if (source == null) {
|
||||
validationException = addValidationError("source is missing", validationException);
|
||||
}
|
||||
if (Strings.isEmpty(type())) {
|
||||
validationException = addValidationError("type is missing", validationException);
|
||||
}
|
||||
if (contentType == null) {
|
||||
validationException = addValidationError("content type is missing", validationException);
|
||||
}
|
||||
|
@ -298,30 +266,6 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
|
|||
return contentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of the indexed document.
|
||||
* @deprecated Types are in the process of being removed.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public String type() {
|
||||
if (type == null) {
|
||||
return MapperService.SINGLE_MAPPING_NAME;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of the indexed document.
|
||||
* @deprecated Types are in the process of being removed.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public IndexRequest type(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The id of the indexed document. If not set, will be automatically generated.
|
||||
*/
|
||||
|
@ -672,7 +616,7 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
|
|||
if (mappingMd != null) {
|
||||
// might as well check for routing here
|
||||
if (mappingMd.routing().required() && routing == null) {
|
||||
throw new RoutingMissingException(concreteIndex, type(), id);
|
||||
throw new RoutingMissingException(concreteIndex, id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -718,9 +662,9 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
|
|||
}
|
||||
|
||||
private void writeBody(StreamOutput out) throws IOException {
|
||||
// A 7.x request allows null types but if deserialized in a 6.x node will cause nullpointer exceptions.
|
||||
// So we use the type accessor method here to make the type non-null (will default it to "_doc").
|
||||
out.writeOptionalString(type());
|
||||
if (out.getVersion().before(Version.V_2_0_0)) {
|
||||
out.writeOptionalString(MapperService.SINGLE_MAPPING_NAME);
|
||||
}
|
||||
out.writeOptionalString(id);
|
||||
out.writeOptionalString(routing);
|
||||
if (out.getVersion().before(LegacyESVersion.V_7_0_0)) {
|
||||
|
@ -767,7 +711,7 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
|
|||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
return "index {[" + index + "][" + type() + "][" + id + "], source[" + sSource + "]}";
|
||||
return "index {[" + index + "][" + id + "], source[" + sSource + "]}";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -61,9 +61,10 @@ public class IndexRequestBuilder extends ReplicationRequestBuilder<IndexRequest,
|
|||
|
||||
/**
|
||||
* Sets the type to index the document to.
|
||||
* @deprecated types will be removed
|
||||
*/
|
||||
@Deprecated
|
||||
public IndexRequestBuilder setType(String type) {
|
||||
request.type(type);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,12 +59,12 @@ public class IndexResponse extends DocWriteResponse {
|
|||
super(in);
|
||||
}
|
||||
|
||||
public IndexResponse(ShardId shardId, String type, String id, long seqNo, long primaryTerm, long version, boolean created) {
|
||||
this(shardId, type, id, seqNo, primaryTerm, version, created ? Result.CREATED : Result.UPDATED);
|
||||
public IndexResponse(ShardId shardId, String id, long seqNo, long primaryTerm, long version, boolean created) {
|
||||
this(shardId, id, seqNo, primaryTerm, version, created ? Result.CREATED : Result.UPDATED);
|
||||
}
|
||||
|
||||
private IndexResponse(ShardId shardId, String type, String id, long seqNo, long primaryTerm, long version, Result result) {
|
||||
super(shardId, type, id, seqNo, primaryTerm, version, assertCreatedOrUpdated(result));
|
||||
private IndexResponse(ShardId shardId, String id, long seqNo, long primaryTerm, long version, Result result) {
|
||||
super(shardId, id, seqNo, primaryTerm, version, assertCreatedOrUpdated(result));
|
||||
}
|
||||
|
||||
private static Result assertCreatedOrUpdated(Result result) {
|
||||
|
@ -82,7 +82,6 @@ public class IndexResponse extends DocWriteResponse {
|
|||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("IndexResponse[");
|
||||
builder.append("index=").append(getIndex());
|
||||
builder.append(",type=").append(getType());
|
||||
builder.append(",id=").append(getId());
|
||||
builder.append(",version=").append(getVersion());
|
||||
builder.append(",result=").append(getResult().getLowercase());
|
||||
|
@ -117,7 +116,7 @@ public class IndexResponse extends DocWriteResponse {
|
|||
public static class Builder extends DocWriteResponse.Builder {
|
||||
@Override
|
||||
public IndexResponse build() {
|
||||
IndexResponse indexResponse = new IndexResponse(shardId, type, id, seqNo, primaryTerm, version, result);
|
||||
IndexResponse indexResponse = new IndexResponse(shardId, id, seqNo, primaryTerm, version, result);
|
||||
indexResponse.setForcedRefresh(forcedRefresh);
|
||||
if (shardInfo != null) {
|
||||
indexResponse.setShardInfo(shardInfo);
|
||||
|
|
|
@ -200,7 +200,6 @@ public class SimulatePipelineRequest extends ActionRequest implements ToXContent
|
|||
"[types removal] specifying _type in pipeline simulation requests is deprecated"
|
||||
);
|
||||
}
|
||||
String type = ConfigurationUtils.readStringOrIntProperty(null, null, dataMap, Metadata.TYPE.getFieldName(), "_doc");
|
||||
String id = ConfigurationUtils.readStringOrIntProperty(null, null, dataMap, Metadata.ID.getFieldName(), "_id");
|
||||
String routing = ConfigurationUtils.readOptionalStringOrIntProperty(null, null, dataMap, Metadata.ROUTING.getFieldName());
|
||||
Long version = null;
|
||||
|
@ -213,7 +212,7 @@ public class SimulatePipelineRequest extends ActionRequest implements ToXContent
|
|||
ConfigurationUtils.readStringProperty(null, null, dataMap, Metadata.VERSION_TYPE.getFieldName())
|
||||
);
|
||||
}
|
||||
IngestDocument ingestDocument = new IngestDocument(index, type, id, routing, version, versionType, document);
|
||||
IngestDocument ingestDocument = new IngestDocument(index, id, routing, version, versionType, document);
|
||||
if (dataMap.containsKey(Metadata.IF_SEQ_NO.getFieldName())) {
|
||||
Long ifSeqNo = (Long) ConfigurationUtils.readObject(null, null, dataMap, Metadata.IF_SEQ_NO.getFieldName());
|
||||
ingestDocument.setFieldValue(Metadata.IF_SEQ_NO.getFieldName(), ifSeqNo);
|
||||
|
|
|
@ -66,24 +66,22 @@ final class WriteableIngestDocument implements Writeable, ToXContentFragment {
|
|||
a -> {
|
||||
HashMap<String, Object> sourceAndMetadata = new HashMap<>();
|
||||
sourceAndMetadata.put(Metadata.INDEX.getFieldName(), a[0]);
|
||||
sourceAndMetadata.put(Metadata.TYPE.getFieldName(), a[1]);
|
||||
sourceAndMetadata.put(Metadata.ID.getFieldName(), a[2]);
|
||||
sourceAndMetadata.put(Metadata.ID.getFieldName(), a[1]);
|
||||
if (a[2] != null) {
|
||||
sourceAndMetadata.put(Metadata.ROUTING.getFieldName(), a[2]);
|
||||
}
|
||||
if (a[3] != null) {
|
||||
sourceAndMetadata.put(Metadata.ROUTING.getFieldName(), a[3]);
|
||||
sourceAndMetadata.put(Metadata.VERSION.getFieldName(), a[3]);
|
||||
}
|
||||
if (a[4] != null) {
|
||||
sourceAndMetadata.put(Metadata.VERSION.getFieldName(), a[4]);
|
||||
sourceAndMetadata.put(Metadata.VERSION_TYPE.getFieldName(), a[4]);
|
||||
}
|
||||
if (a[5] != null) {
|
||||
sourceAndMetadata.put(Metadata.VERSION_TYPE.getFieldName(), a[5]);
|
||||
}
|
||||
sourceAndMetadata.putAll((Map<String, Object>) a[6]);
|
||||
return new WriteableIngestDocument(new IngestDocument(sourceAndMetadata, (Map<String, Object>) a[7]));
|
||||
sourceAndMetadata.putAll((Map<String, Object>) a[5]);
|
||||
return new WriteableIngestDocument(new IngestDocument(sourceAndMetadata, (Map<String, Object>) a[6]));
|
||||
}
|
||||
);
|
||||
static {
|
||||
INGEST_DOC_PARSER.declareString(constructorArg(), new ParseField(Metadata.INDEX.getFieldName()));
|
||||
INGEST_DOC_PARSER.declareString(constructorArg(), new ParseField(Metadata.TYPE.getFieldName()));
|
||||
INGEST_DOC_PARSER.declareString(constructorArg(), new ParseField(Metadata.ID.getFieldName()));
|
||||
INGEST_DOC_PARSER.declareString(optionalConstructorArg(), new ParseField(Metadata.ROUTING.getFieldName()));
|
||||
INGEST_DOC_PARSER.declareLong(optionalConstructorArg(), new ParseField(Metadata.VERSION.getFieldName()));
|
||||
|
|
|
@ -142,7 +142,7 @@ public class TransportUpdateAction extends TransportInstanceSingleOperationActio
|
|||
request.routing((metadata.resolveWriteIndexRouting(request.routing(), request.index())));
|
||||
// Fail fast on the node that received the request, rather than failing when translating on the index or delete request.
|
||||
if (request.routing() == null && metadata.routingRequired(concreteIndex)) {
|
||||
throw new RoutingMissingException(concreteIndex, request.type(), request.id());
|
||||
throw new RoutingMissingException(concreteIndex, request.id());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,6 @@ public class TransportUpdateAction extends TransportInstanceSingleOperationActio
|
|||
UpdateResponse update = new UpdateResponse(
|
||||
response.getShardInfo(),
|
||||
response.getShardId(),
|
||||
response.getType(),
|
||||
response.getId(),
|
||||
response.getSeqNo(),
|
||||
response.getPrimaryTerm(),
|
||||
|
@ -267,7 +266,6 @@ public class TransportUpdateAction extends TransportInstanceSingleOperationActio
|
|||
UpdateResponse update = new UpdateResponse(
|
||||
response.getShardInfo(),
|
||||
response.getShardId(),
|
||||
response.getType(),
|
||||
response.getId(),
|
||||
response.getSeqNo(),
|
||||
response.getPrimaryTerm(),
|
||||
|
@ -296,7 +294,6 @@ public class TransportUpdateAction extends TransportInstanceSingleOperationActio
|
|||
UpdateResponse update = new UpdateResponse(
|
||||
response.getShardInfo(),
|
||||
response.getShardId(),
|
||||
response.getType(),
|
||||
response.getId(),
|
||||
response.getSeqNo(),
|
||||
response.getPrimaryTerm(),
|
||||
|
|
|
@ -51,7 +51,6 @@ import org.opensearch.index.VersionType;
|
|||
import org.opensearch.index.engine.DocumentMissingException;
|
||||
import org.opensearch.index.engine.DocumentSourceMissingException;
|
||||
import org.opensearch.index.get.GetResult;
|
||||
import org.opensearch.index.mapper.MapperService;
|
||||
import org.opensearch.index.mapper.RoutingFieldMapper;
|
||||
import org.opensearch.index.shard.IndexShard;
|
||||
import org.opensearch.index.shard.ShardId;
|
||||
|
@ -97,7 +96,7 @@ public class UpdateHelper {
|
|||
return prepareUpsert(shardId, request, getResult, nowInMillis);
|
||||
} else if (getResult.internalSourceRef() == null) {
|
||||
// no source, we can't do anything, throw a failure...
|
||||
throw new DocumentSourceMissingException(shardId, request.type(), request.id());
|
||||
throw new DocumentSourceMissingException(shardId, request.id());
|
||||
} else if (request.script() == null && request.doc() != null) {
|
||||
// The request has no script, it is a new doc that should be merged with the old document
|
||||
return prepareUpdateIndexRequest(shardId, request, getResult, request.detectNoop());
|
||||
|
@ -138,7 +137,7 @@ public class UpdateHelper {
|
|||
*/
|
||||
Result prepareUpsert(ShardId shardId, UpdateRequest request, final GetResult getResult, LongSupplier nowInMillis) {
|
||||
if (request.upsertRequest() == null && !request.docAsUpsert()) {
|
||||
throw new DocumentMissingException(shardId, request.type(), request.id());
|
||||
throw new DocumentMissingException(shardId, request.id());
|
||||
}
|
||||
IndexRequest indexRequest = request.docAsUpsert() ? request.doc() : request.upsertRequest();
|
||||
if (request.scriptedUpsert() && request.script() != null) {
|
||||
|
@ -156,7 +155,6 @@ public class UpdateHelper {
|
|||
case NONE:
|
||||
UpdateResponse update = new UpdateResponse(
|
||||
shardId,
|
||||
MapperService.SINGLE_MAPPING_NAME,
|
||||
getResult.getId(),
|
||||
getResult.getSeqNo(),
|
||||
getResult.getPrimaryTerm(),
|
||||
|
@ -172,7 +170,6 @@ public class UpdateHelper {
|
|||
}
|
||||
|
||||
indexRequest.index(request.index())
|
||||
.type(request.type())
|
||||
.id(request.id())
|
||||
.setRefreshPolicy(request.getRefreshPolicy())
|
||||
.routing(request.routing())
|
||||
|
@ -221,7 +218,6 @@ public class UpdateHelper {
|
|||
if (detectNoop && noop) {
|
||||
UpdateResponse update = new UpdateResponse(
|
||||
shardId,
|
||||
MapperService.SINGLE_MAPPING_NAME,
|
||||
getResult.getId(),
|
||||
getResult.getSeqNo(),
|
||||
getResult.getPrimaryTerm(),
|
||||
|
@ -243,7 +239,6 @@ public class UpdateHelper {
|
|||
return new Result(update, DocWriteResponse.Result.NOOP, updatedSourceAsMap, updateSourceContentType);
|
||||
} else {
|
||||
final IndexRequest finalIndexRequest = Requests.indexRequest(request.index())
|
||||
.type(request.type())
|
||||
.id(request.id())
|
||||
.routing(routing)
|
||||
.source(updatedSourceAsMap, updateSourceContentType)
|
||||
|
@ -287,7 +282,6 @@ public class UpdateHelper {
|
|||
switch (operation) {
|
||||
case INDEX:
|
||||
final IndexRequest indexRequest = Requests.indexRequest(request.index())
|
||||
.type(request.type())
|
||||
.id(request.id())
|
||||
.routing(routing)
|
||||
.source(updatedSourceAsMap, updateSourceContentType)
|
||||
|
@ -299,7 +293,6 @@ public class UpdateHelper {
|
|||
return new Result(indexRequest, DocWriteResponse.Result.UPDATED, updatedSourceAsMap, updateSourceContentType);
|
||||
case DELETE:
|
||||
DeleteRequest deleteRequest = Requests.deleteRequest(request.index())
|
||||
.type(request.type())
|
||||
.id(request.id())
|
||||
.routing(routing)
|
||||
.setIfSeqNo(getResult.getSeqNo())
|
||||
|
@ -312,7 +305,6 @@ public class UpdateHelper {
|
|||
// If it was neither an INDEX or DELETE operation, treat it as a noop
|
||||
UpdateResponse update = new UpdateResponse(
|
||||
shardId,
|
||||
MapperService.SINGLE_MAPPING_NAME,
|
||||
getResult.getId(),
|
||||
getResult.getSeqNo(),
|
||||
getResult.getPrimaryTerm(),
|
||||
|
|
|
@ -34,6 +34,7 @@ package org.opensearch.action.update;
|
|||
|
||||
import org.apache.lucene.util.RamUsageEstimator;
|
||||
import org.opensearch.LegacyESVersion;
|
||||
import org.opensearch.Version;
|
||||
import org.opensearch.action.ActionRequestValidationException;
|
||||
import org.opensearch.action.DocWriteRequest;
|
||||
import org.opensearch.action.index.IndexRequest;
|
||||
|
@ -122,8 +123,6 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
|||
PARSER.declareLong(UpdateRequest::setIfPrimaryTerm, IF_PRIMARY_TERM);
|
||||
}
|
||||
|
||||
// Set to null initially so we can know to override in bulk requests that have a default type.
|
||||
private String type;
|
||||
private String id;
|
||||
@Nullable
|
||||
private String routing;
|
||||
|
@ -160,7 +159,10 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
|||
public UpdateRequest(@Nullable ShardId shardId, StreamInput in) throws IOException {
|
||||
super(shardId, in);
|
||||
waitForActiveShards = ActiveShardCount.readFrom(in);
|
||||
type = in.readString();
|
||||
if (in.getVersion().before(Version.V_2_0_0)) {
|
||||
String type = in.readString();
|
||||
assert MapperService.SINGLE_MAPPING_NAME.equals(type) : "Expected [_doc] but received [" + type + "]";
|
||||
}
|
||||
id = in.readString();
|
||||
routing = in.readOptionalString();
|
||||
if (in.getVersion().before(LegacyESVersion.V_7_0_0)) {
|
||||
|
@ -210,25 +212,12 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Types are in the process of being removed. Use {@link #UpdateRequest(String, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public UpdateRequest(String index, String type, String id) {
|
||||
super(index);
|
||||
this.type = type;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionRequestValidationException validate() {
|
||||
ActionRequestValidationException validationException = super.validate();
|
||||
if (upsertRequest != null && upsertRequest.version() != Versions.MATCH_ANY) {
|
||||
validationException = addValidationError("can't provide version in upsert request", validationException);
|
||||
}
|
||||
if (Strings.isEmpty(type())) {
|
||||
validationException = addValidationError("type is missing", validationException);
|
||||
}
|
||||
if (Strings.isEmpty(id)) {
|
||||
validationException = addValidationError("id is missing", validationException);
|
||||
}
|
||||
|
@ -263,31 +252,6 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
|||
return validationException;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of the indexed document.
|
||||
*
|
||||
* @deprecated Types are in the process of being removed.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public String type() {
|
||||
if (type == null) {
|
||||
return MapperService.SINGLE_MAPPING_NAME;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of the indexed document.
|
||||
*
|
||||
* @deprecated Types are in the process of being removed.
|
||||
*/
|
||||
@Deprecated
|
||||
public UpdateRequest type(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The id of the indexed document.
|
||||
*/
|
||||
|
@ -919,9 +883,9 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
|||
|
||||
private void doWrite(StreamOutput out, boolean thin) throws IOException {
|
||||
waitForActiveShards.writeTo(out);
|
||||
// A 7.x request allows null types but if deserialized in a 6.x node will cause nullpointer exceptions.
|
||||
// So we use the type accessor method here to make the type non-null (will default it to "_doc").
|
||||
out.writeString(type());
|
||||
if (out.getVersion().before(Version.V_2_0_0)) {
|
||||
out.writeString(MapperService.SINGLE_MAPPING_NAME);
|
||||
}
|
||||
out.writeString(id);
|
||||
out.writeOptionalString(routing);
|
||||
if (out.getVersion().before(LegacyESVersion.V_7_0_0)) {
|
||||
|
@ -941,7 +905,6 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
|||
out.writeBoolean(true);
|
||||
// make sure the basics are set
|
||||
doc.index(index);
|
||||
doc.type(type);
|
||||
doc.id(id);
|
||||
if (thin) {
|
||||
doc.writeThin(out);
|
||||
|
@ -959,7 +922,6 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
|||
out.writeBoolean(true);
|
||||
// make sure the basics are set
|
||||
upsertRequest.index(index);
|
||||
upsertRequest.type(type);
|
||||
upsertRequest.id(id);
|
||||
if (thin) {
|
||||
upsertRequest.writeThin(out);
|
||||
|
@ -1039,13 +1001,7 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder res = new StringBuilder().append("update {[")
|
||||
.append(index)
|
||||
.append("][")
|
||||
.append(type())
|
||||
.append("][")
|
||||
.append(id)
|
||||
.append("]");
|
||||
StringBuilder res = new StringBuilder().append("update {[").append(index).append("][").append(id).append("]");
|
||||
res.append(", doc_as_upsert[").append(docAsUpsert).append("]");
|
||||
if (doc != null) {
|
||||
res.append(", doc[").append(doc).append("]");
|
||||
|
|
|
@ -54,15 +54,21 @@ public class UpdateRequestBuilder extends InstanceShardOperationRequestBuilder<U
|
|||
super(client, action, new UpdateRequest());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public UpdateRequestBuilder(OpenSearchClient client, UpdateAction action, String index, String type, String id) {
|
||||
super(client, action, new UpdateRequest(index, type, id));
|
||||
super(client, action, new UpdateRequest(index, id));
|
||||
}
|
||||
|
||||
public UpdateRequestBuilder(OpenSearchClient client, UpdateAction action, String index, String id) {
|
||||
super(client, action, new UpdateRequest(index, id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of the indexed document.
|
||||
* @deprecated types will be removed
|
||||
*/
|
||||
@Deprecated
|
||||
public UpdateRequestBuilder setType(String type) {
|
||||
request.type(type);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.opensearch.common.io.stream.StreamOutput;
|
|||
import org.opensearch.common.xcontent.XContentBuilder;
|
||||
import org.opensearch.common.xcontent.XContentParser;
|
||||
import org.opensearch.index.get.GetResult;
|
||||
import org.opensearch.index.mapper.MapperService;
|
||||
import org.opensearch.index.shard.ShardId;
|
||||
import org.opensearch.rest.RestStatus;
|
||||
|
||||
|
@ -70,21 +69,12 @@ public class UpdateResponse extends DocWriteResponse {
|
|||
* Constructor to be used when a update didn't translate in a write.
|
||||
* For example: update script with operation set to none
|
||||
*/
|
||||
public UpdateResponse(ShardId shardId, String type, String id, long seqNo, long primaryTerm, long version, Result result) {
|
||||
this(new ShardInfo(0, 0), shardId, type, id, seqNo, primaryTerm, version, result);
|
||||
public UpdateResponse(ShardId shardId, String id, long seqNo, long primaryTerm, long version, Result result) {
|
||||
this(new ShardInfo(0, 0), shardId, id, seqNo, primaryTerm, version, result);
|
||||
}
|
||||
|
||||
public UpdateResponse(
|
||||
ShardInfo shardInfo,
|
||||
ShardId shardId,
|
||||
String type,
|
||||
String id,
|
||||
long seqNo,
|
||||
long primaryTerm,
|
||||
long version,
|
||||
Result result
|
||||
) {
|
||||
super(shardId, MapperService.SINGLE_MAPPING_NAME, id, seqNo, primaryTerm, version, result);
|
||||
public UpdateResponse(ShardInfo shardInfo, ShardId shardId, String id, long seqNo, long primaryTerm, long version, Result result) {
|
||||
super(shardId, id, seqNo, primaryTerm, version, result);
|
||||
setShardInfo(shardInfo);
|
||||
}
|
||||
|
||||
|
@ -138,7 +128,6 @@ public class UpdateResponse extends DocWriteResponse {
|
|||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("UpdateResponse[");
|
||||
builder.append("index=").append(getIndex());
|
||||
builder.append(",type=").append(getType());
|
||||
builder.append(",id=").append(getId());
|
||||
builder.append(",version=").append(getVersion());
|
||||
builder.append(",seqNo=").append(getSeqNo());
|
||||
|
@ -191,9 +180,9 @@ public class UpdateResponse extends DocWriteResponse {
|
|||
public UpdateResponse build() {
|
||||
UpdateResponse update;
|
||||
if (shardInfo != null) {
|
||||
update = new UpdateResponse(shardInfo, shardId, type, id, seqNo, primaryTerm, version, result);
|
||||
update = new UpdateResponse(shardInfo, shardId, id, seqNo, primaryTerm, version, result);
|
||||
} else {
|
||||
update = new UpdateResponse(shardId, type, id, seqNo, primaryTerm, version, result);
|
||||
update = new UpdateResponse(shardId, id, seqNo, primaryTerm, version, result);
|
||||
}
|
||||
if (getResult != null) {
|
||||
update.setGetResult(
|
||||
|
|
|
@ -97,8 +97,8 @@ public class Requests {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create an index request against a specific index. Note the {@link IndexRequest#type(String)} must be
|
||||
* set as well and optionally the {@link IndexRequest#id(String)}.
|
||||
* Create an index request against a specific index.
|
||||
* Note that setting {@link IndexRequest#id(String)} is optional.
|
||||
*
|
||||
* @param index The index name to index the request against
|
||||
* @return The index request
|
||||
|
@ -109,8 +109,8 @@ public class Requests {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a delete request against a specific index. Note the {@link DeleteRequest#type(String)} and
|
||||
* {@link DeleteRequest#id(String)} must be set.
|
||||
* Creates a delete request against a specific index.
|
||||
* Note that {@link DeleteRequest#id(String)} must be set.
|
||||
*
|
||||
* @param index The index name to delete from
|
||||
* @return The delete request
|
||||
|
|
|
@ -39,8 +39,8 @@ import java.io.IOException;
|
|||
|
||||
public class DocumentMissingException extends EngineException {
|
||||
|
||||
public DocumentMissingException(ShardId shardId, String type, String id) {
|
||||
super(shardId, "[" + type + "][" + id + "]: document missing");
|
||||
public DocumentMissingException(ShardId shardId, String id) {
|
||||
super(shardId, "[" + id + "]: document missing");
|
||||
}
|
||||
|
||||
public DocumentMissingException(StreamInput in) throws IOException {
|
||||
|
|
|
@ -39,8 +39,8 @@ import java.io.IOException;
|
|||
|
||||
public class DocumentSourceMissingException extends EngineException {
|
||||
|
||||
public DocumentSourceMissingException(ShardId shardId, String type, String id) {
|
||||
super(shardId, "[" + type + "][" + id + "]: document source missing");
|
||||
public DocumentSourceMissingException(ShardId shardId, String id) {
|
||||
super(shardId, "[" + id + "]: document source missing");
|
||||
}
|
||||
|
||||
public DocumentSourceMissingException(StreamInput in) throws IOException {
|
||||
|
|
|
@ -50,7 +50,6 @@ import org.opensearch.common.xcontent.XContentBuilder;
|
|||
import org.opensearch.common.xcontent.XContentFactory;
|
||||
import org.opensearch.common.xcontent.XContentParser;
|
||||
import org.opensearch.index.VersionType;
|
||||
import org.opensearch.index.mapper.MapperService;
|
||||
import org.opensearch.index.query.QueryBuilder;
|
||||
import org.opensearch.script.Script;
|
||||
import org.opensearch.search.sort.SortOrder;
|
||||
|
@ -209,14 +208,6 @@ public class ReindexRequest extends AbstractBulkIndexByScrollRequest<ReindexRequ
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the document type for the destination index
|
||||
*/
|
||||
public ReindexRequest setDestDocType(String docType) {
|
||||
this.getDestination().type(docType);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the routing to decide which shard the documents need to be routed to
|
||||
*/
|
||||
|
@ -303,9 +294,6 @@ public class ReindexRequest extends AbstractBulkIndexByScrollRequest<ReindexRequ
|
|||
}
|
||||
searchToString(b);
|
||||
b.append(" to [").append(destination.index()).append(']');
|
||||
if (destination.type() != null) {
|
||||
b.append('[').append(destination.type()).append(']');
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
|
@ -327,10 +315,6 @@ public class ReindexRequest extends AbstractBulkIndexByScrollRequest<ReindexRequ
|
|||
// build destination
|
||||
builder.startObject("dest");
|
||||
builder.field("index", getDestination().index());
|
||||
String type = getDestination().type();
|
||||
if (type != null && type.equals(MapperService.SINGLE_MAPPING_NAME) == false) {
|
||||
builder.field("type", getDestination().type());
|
||||
}
|
||||
if (getDestination().routing() != null) {
|
||||
builder.field("routing", getDestination().routing());
|
||||
}
|
||||
|
@ -384,10 +368,6 @@ public class ReindexRequest extends AbstractBulkIndexByScrollRequest<ReindexRequ
|
|||
|
||||
ObjectParser<IndexRequest, Void> destParser = new ObjectParser<>("dest");
|
||||
destParser.declareString(IndexRequest::index, new ParseField("index"));
|
||||
destParser.declareString((request, type) -> {
|
||||
deprecationLogger.deprecate("reindex_with_types", TYPES_DEPRECATION_MESSAGE);
|
||||
request.type(type);
|
||||
}, new ParseField("type"));
|
||||
destParser.declareString(IndexRequest::routing, new ParseField("routing"));
|
||||
destParser.declareString(IndexRequest::opType, new ParseField("op_type"));
|
||||
destParser.declareString(IndexRequest::setPipeline, new ParseField("pipeline"));
|
||||
|
|
|
@ -78,14 +78,6 @@ public class ReindexRequestBuilder extends AbstractBulkIndexByScrollRequestBuild
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the destination index and type.
|
||||
*/
|
||||
public ReindexRequestBuilder destination(String index, String type) {
|
||||
destination.setIndex(index).setType(type);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup reindexing from a remote cluster.
|
||||
*/
|
||||
|
|
|
@ -76,19 +76,10 @@ public final class IngestDocument {
|
|||
// Contains all pipelines that have been executed for this document
|
||||
private final Set<String> executedPipelines = new LinkedHashSet<>();
|
||||
|
||||
public IngestDocument(
|
||||
String index,
|
||||
String type,
|
||||
String id,
|
||||
String routing,
|
||||
Long version,
|
||||
VersionType versionType,
|
||||
Map<String, Object> source
|
||||
) {
|
||||
public IngestDocument(String index, String id, String routing, Long version, VersionType versionType, Map<String, Object> source) {
|
||||
this.sourceAndMetadata = new HashMap<>();
|
||||
this.sourceAndMetadata.putAll(source);
|
||||
this.sourceAndMetadata.put(Metadata.INDEX.getFieldName(), index);
|
||||
this.sourceAndMetadata.put(Metadata.TYPE.getFieldName(), type);
|
||||
this.sourceAndMetadata.put(Metadata.ID.getFieldName(), id);
|
||||
if (routing != null) {
|
||||
this.sourceAndMetadata.put(Metadata.ROUTING.getFieldName(), routing);
|
||||
|
|
|
@ -722,13 +722,12 @@ public class IngestService implements ClusterStateApplier, ReportingService<Inge
|
|||
// (e.g. the pipeline may have been removed while we're ingesting a document
|
||||
totalMetrics.preIngest();
|
||||
String index = indexRequest.index();
|
||||
String type = indexRequest.type();
|
||||
String id = indexRequest.id();
|
||||
String routing = indexRequest.routing();
|
||||
Long version = indexRequest.version();
|
||||
VersionType versionType = indexRequest.versionType();
|
||||
Map<String, Object> sourceAsMap = indexRequest.sourceAsMap();
|
||||
IngestDocument ingestDocument = new IngestDocument(index, type, id, routing, version, versionType, sourceAsMap);
|
||||
IngestDocument ingestDocument = new IngestDocument(index, id, routing, version, versionType, sourceAsMap);
|
||||
ingestDocument.executePipeline(pipeline, (result, e) -> {
|
||||
long ingestTimeInMillis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTimeInNanos);
|
||||
totalMetrics.postIngest(ingestTimeInMillis);
|
||||
|
@ -743,7 +742,6 @@ public class IngestService implements ClusterStateApplier, ReportingService<Inge
|
|||
// it's fine to set all metadata fields all the time, as ingest document holds their starting values
|
||||
// before ingestion, which might also get modified during ingestion.
|
||||
indexRequest.index((String) metadataMap.get(IngestDocument.Metadata.INDEX));
|
||||
indexRequest.type((String) metadataMap.get(IngestDocument.Metadata.TYPE));
|
||||
indexRequest.id((String) metadataMap.get(IngestDocument.Metadata.ID));
|
||||
indexRequest.routing((String) metadataMap.get(IngestDocument.Metadata.ROUTING));
|
||||
indexRequest.version(((Number) metadataMap.get(IngestDocument.Metadata.VERSION)).longValue());
|
||||
|
|
|
@ -35,7 +35,6 @@ package org.opensearch.rest.action.document;
|
|||
import org.opensearch.action.delete.DeleteRequest;
|
||||
import org.opensearch.action.support.ActiveShardCount;
|
||||
import org.opensearch.client.node.NodeClient;
|
||||
import org.opensearch.common.logging.DeprecationLogger;
|
||||
import org.opensearch.index.VersionType;
|
||||
import org.opensearch.rest.BaseRestHandler;
|
||||
import org.opensearch.rest.RestRequest;
|
||||
|
@ -50,19 +49,10 @@ import static java.util.Collections.unmodifiableList;
|
|||
import static org.opensearch.rest.RestRequest.Method.DELETE;
|
||||
|
||||
public class RestDeleteAction extends BaseRestHandler {
|
||||
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestDeleteAction.class);
|
||||
public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in "
|
||||
+ "document index requests is deprecated, use the /{index}/_doc/{id} endpoint instead.";
|
||||
|
||||
@Override
|
||||
public List<Route> routes() {
|
||||
return unmodifiableList(
|
||||
asList(
|
||||
new Route(DELETE, "/{index}/_doc/{id}"),
|
||||
// Deprecated typed endpoint.
|
||||
new Route(DELETE, "/{index}/{type}/{id}")
|
||||
)
|
||||
);
|
||||
return unmodifiableList(asList(new Route(DELETE, "/{index}/_doc/{id}")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,14 +62,7 @@ public class RestDeleteAction extends BaseRestHandler {
|
|||
|
||||
@Override
|
||||
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
|
||||
DeleteRequest deleteRequest;
|
||||
if (request.hasParam("type")) {
|
||||
deprecationLogger.deprecate("delete_with_types", TYPES_DEPRECATION_MESSAGE);
|
||||
deleteRequest = new DeleteRequest(request.param("index"), request.param("type"), request.param("id"));
|
||||
} else {
|
||||
deleteRequest = new DeleteRequest(request.param("index"), request.param("id"));
|
||||
}
|
||||
|
||||
DeleteRequest deleteRequest = new DeleteRequest(request.param("index"), request.param("id"));
|
||||
deleteRequest.routing(request.param("routing"));
|
||||
deleteRequest.timeout(request.paramAsTime("timeout", DeleteRequest.DEFAULT_TIMEOUT));
|
||||
deleteRequest.setRefreshPolicy(request.param("refresh"));
|
||||
|
|
|
@ -123,9 +123,7 @@ public class RestIndexAction extends BaseRestHandler {
|
|||
|
||||
@Override
|
||||
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
|
||||
IndexRequest indexRequest;
|
||||
final String type = request.param("type");
|
||||
indexRequest = new IndexRequest(request.param("index"));
|
||||
IndexRequest indexRequest = new IndexRequest(request.param("index"));
|
||||
indexRequest.id(request.param("id"));
|
||||
indexRequest.routing(request.param("routing"));
|
||||
indexRequest.setPipeline(request.param("pipeline"));
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.opensearch.common.xcontent.ToXContent;
|
|||
import org.opensearch.common.xcontent.XContentBuilder;
|
||||
import org.opensearch.common.xcontent.XContentParser;
|
||||
import org.opensearch.common.xcontent.json.JsonXContent;
|
||||
import org.opensearch.index.mapper.MapperService;
|
||||
import org.opensearch.index.seqno.SequenceNumbers;
|
||||
import org.opensearch.index.shard.ShardId;
|
||||
import org.opensearch.test.OpenSearchTestCase;
|
||||
|
@ -53,7 +54,6 @@ public class DocWriteResponseTests extends OpenSearchTestCase {
|
|||
public void testGetLocation() {
|
||||
final DocWriteResponse response = new DocWriteResponse(
|
||||
new ShardId("index", "uuid", 0),
|
||||
"type",
|
||||
"id",
|
||||
SequenceNumbers.UNASSIGNED_SEQ_NO,
|
||||
17,
|
||||
|
@ -61,14 +61,13 @@ public class DocWriteResponseTests extends OpenSearchTestCase {
|
|||
Result.CREATED
|
||||
) {
|
||||
};
|
||||
assertEquals("/index/type/id", response.getLocation(null));
|
||||
assertEquals("/index/type/id?routing=test_routing", response.getLocation("test_routing"));
|
||||
assertEquals("/index/" + MapperService.SINGLE_MAPPING_NAME + "/id", response.getLocation(null));
|
||||
assertEquals("/index/" + MapperService.SINGLE_MAPPING_NAME + "/id?routing=test_routing", response.getLocation("test_routing"));
|
||||
}
|
||||
|
||||
public void testGetLocationNonAscii() {
|
||||
final DocWriteResponse response = new DocWriteResponse(
|
||||
new ShardId("index", "uuid", 0),
|
||||
"type",
|
||||
"❤",
|
||||
SequenceNumbers.UNASSIGNED_SEQ_NO,
|
||||
17,
|
||||
|
@ -76,14 +75,13 @@ public class DocWriteResponseTests extends OpenSearchTestCase {
|
|||
Result.CREATED
|
||||
) {
|
||||
};
|
||||
assertEquals("/index/type/%E2%9D%A4", response.getLocation(null));
|
||||
assertEquals("/index/type/%E2%9D%A4?routing=%C3%A4", response.getLocation("ä"));
|
||||
assertEquals("/index/" + MapperService.SINGLE_MAPPING_NAME + "/%E2%9D%A4", response.getLocation(null));
|
||||
assertEquals("/index/" + MapperService.SINGLE_MAPPING_NAME + "/%E2%9D%A4?routing=%C3%A4", response.getLocation("ä"));
|
||||
}
|
||||
|
||||
public void testGetLocationWithSpaces() {
|
||||
final DocWriteResponse response = new DocWriteResponse(
|
||||
new ShardId("index", "uuid", 0),
|
||||
"type",
|
||||
"a b",
|
||||
SequenceNumbers.UNASSIGNED_SEQ_NO,
|
||||
17,
|
||||
|
@ -91,8 +89,8 @@ public class DocWriteResponseTests extends OpenSearchTestCase {
|
|||
Result.CREATED
|
||||
) {
|
||||
};
|
||||
assertEquals("/index/type/a+b", response.getLocation(null));
|
||||
assertEquals("/index/type/a+b?routing=c+d", response.getLocation("c d"));
|
||||
assertEquals("/index/" + MapperService.SINGLE_MAPPING_NAME + "/a+b", response.getLocation(null));
|
||||
assertEquals("/index/" + MapperService.SINGLE_MAPPING_NAME + "/a+b?routing=c+d", response.getLocation("c d"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,7 +100,6 @@ public class DocWriteResponseTests extends OpenSearchTestCase {
|
|||
public void testToXContentDoesntIncludeForcedRefreshUnlessForced() throws IOException {
|
||||
DocWriteResponse response = new DocWriteResponse(
|
||||
new ShardId("index", "uuid", 0),
|
||||
"type",
|
||||
"id",
|
||||
SequenceNumbers.UNASSIGNED_SEQ_NO,
|
||||
17,
|
||||
|
|
|
@ -85,16 +85,16 @@ public class BulkPrimaryExecutionContextTests extends OpenSearchTestCase {
|
|||
final DocWriteRequest request;
|
||||
switch (randomFrom(DocWriteRequest.OpType.values())) {
|
||||
case INDEX:
|
||||
request = new IndexRequest("index", "_doc", "id_" + i);
|
||||
request = new IndexRequest("index").id("id_" + i);
|
||||
break;
|
||||
case CREATE:
|
||||
request = new IndexRequest("index", "_doc", "id_" + i).create(true);
|
||||
request = new IndexRequest("index").id("id_" + i).create(true);
|
||||
break;
|
||||
case UPDATE:
|
||||
request = new UpdateRequest("index", "_doc", "id_" + i);
|
||||
request = new UpdateRequest("index", "id_" + i);
|
||||
break;
|
||||
case DELETE:
|
||||
request = new DeleteRequest("index", "_doc", "id_" + i);
|
||||
request = new DeleteRequest("index", "id_" + i);
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError("unknown type");
|
||||
|
@ -139,7 +139,7 @@ public class BulkPrimaryExecutionContextTests extends OpenSearchTestCase {
|
|||
}
|
||||
break;
|
||||
case UPDATE:
|
||||
context.setRequestToExecute(new IndexRequest(current.index(), current.type(), current.id()));
|
||||
context.setRequestToExecute(new IndexRequest(current.index()).id(current.id()));
|
||||
if (failure) {
|
||||
result = new Engine.IndexResult(new OpenSearchException("bla"), 1, 1, 1);
|
||||
} else {
|
||||
|
|
|
@ -58,7 +58,7 @@ public class BulkRequestModifierTests extends OpenSearchTestCase {
|
|||
int numRequests = scaledRandomIntBetween(8, 64);
|
||||
BulkRequest bulkRequest = new BulkRequest();
|
||||
for (int i = 0; i < numRequests; i++) {
|
||||
bulkRequest.add(new IndexRequest("_index", "_type", String.valueOf(i)).source("{}", XContentType.JSON));
|
||||
bulkRequest.add(new IndexRequest("_index").id(String.valueOf(i)).source("{}", XContentType.JSON));
|
||||
}
|
||||
CaptureActionListener actionListener = new CaptureActionListener();
|
||||
TransportBulkAction.BulkRequestModifier bulkRequestModifier = new TransportBulkAction.BulkRequestModifier(bulkRequest);
|
||||
|
@ -98,7 +98,7 @@ public class BulkRequestModifierTests extends OpenSearchTestCase {
|
|||
public void testPipelineFailures() {
|
||||
BulkRequest originalBulkRequest = new BulkRequest();
|
||||
for (int i = 0; i < 32; i++) {
|
||||
originalBulkRequest.add(new IndexRequest("index", "type", String.valueOf(i)));
|
||||
originalBulkRequest.add(new IndexRequest("index").id(String.valueOf(i)));
|
||||
}
|
||||
|
||||
TransportBulkAction.BulkRequestModifier modifier = new TransportBulkAction.BulkRequestModifier(originalBulkRequest);
|
||||
|
@ -127,15 +127,7 @@ public class BulkRequestModifierTests extends OpenSearchTestCase {
|
|||
List<BulkItemResponse> originalResponses = new ArrayList<>();
|
||||
for (DocWriteRequest<?> actionRequest : bulkRequest.requests()) {
|
||||
IndexRequest indexRequest = (IndexRequest) actionRequest;
|
||||
IndexResponse indexResponse = new IndexResponse(
|
||||
new ShardId("index", "_na_", 0),
|
||||
indexRequest.type(),
|
||||
indexRequest.id(),
|
||||
1,
|
||||
17,
|
||||
1,
|
||||
true
|
||||
);
|
||||
IndexResponse indexResponse = new IndexResponse(new ShardId("index", "_na_", 0), indexRequest.id(), 1, 17, 1, true);
|
||||
originalResponses.add(new BulkItemResponse(Integer.parseInt(indexRequest.id()), indexRequest.opType(), indexResponse));
|
||||
}
|
||||
bulkResponseListener.onResponse(new BulkResponse(originalResponses.toArray(new BulkItemResponse[originalResponses.size()]), 0));
|
||||
|
@ -149,7 +141,7 @@ public class BulkRequestModifierTests extends OpenSearchTestCase {
|
|||
public void testNoFailures() {
|
||||
BulkRequest originalBulkRequest = new BulkRequest();
|
||||
for (int i = 0; i < 32; i++) {
|
||||
originalBulkRequest.add(new IndexRequest("index", "type", String.valueOf(i)));
|
||||
originalBulkRequest.add(new IndexRequest("index").id(String.valueOf(i)));
|
||||
}
|
||||
|
||||
TransportBulkAction.BulkRequestModifier modifier = new TransportBulkAction.BulkRequestModifier(originalBulkRequest);
|
||||
|
|
|
@ -141,9 +141,9 @@ public class BulkRequestTests extends OpenSearchTestCase {
|
|||
public void testBulkAddIterable() {
|
||||
BulkRequest bulkRequest = Requests.bulkRequest();
|
||||
List<DocWriteRequest<?>> requests = new ArrayList<>();
|
||||
requests.add(new IndexRequest("test", "test", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value"));
|
||||
requests.add(new UpdateRequest("test", "test", "id").doc(Requests.INDEX_CONTENT_TYPE, "field", "value"));
|
||||
requests.add(new DeleteRequest("test", "test", "id"));
|
||||
requests.add(new IndexRequest("test").id("id").source(Requests.INDEX_CONTENT_TYPE, "field", "value"));
|
||||
requests.add(new UpdateRequest("test", "id").doc(Requests.INDEX_CONTENT_TYPE, "field", "value"));
|
||||
requests.add(new DeleteRequest("test", "id"));
|
||||
bulkRequest.add(requests);
|
||||
assertThat(bulkRequest.requests().size(), equalTo(3));
|
||||
assertThat(bulkRequest.requests().get(0), instanceOf(IndexRequest.class));
|
||||
|
@ -251,12 +251,12 @@ public class BulkRequestTests extends OpenSearchTestCase {
|
|||
public void testBulkRequestWithRefresh() throws Exception {
|
||||
BulkRequest bulkRequest = new BulkRequest();
|
||||
// We force here a "id is missing" validation error
|
||||
bulkRequest.add(new DeleteRequest("index", "type", null).setRefreshPolicy(RefreshPolicy.IMMEDIATE));
|
||||
bulkRequest.add(new DeleteRequest("index", null).setRefreshPolicy(RefreshPolicy.IMMEDIATE));
|
||||
// We force here a "type is missing" validation error
|
||||
bulkRequest.add(new DeleteRequest("index", "", "id"));
|
||||
bulkRequest.add(new DeleteRequest("index", "type", "id").setRefreshPolicy(RefreshPolicy.IMMEDIATE));
|
||||
bulkRequest.add(new UpdateRequest("index", "type", "id").doc("{}", XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE));
|
||||
bulkRequest.add(new IndexRequest("index", "type", "id").source("{}", XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE));
|
||||
bulkRequest.add(new DeleteRequest("index", "id"));
|
||||
bulkRequest.add(new DeleteRequest("index", "id").setRefreshPolicy(RefreshPolicy.IMMEDIATE));
|
||||
bulkRequest.add(new UpdateRequest("index", "id").doc("{}", XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE));
|
||||
bulkRequest.add(new IndexRequest("index").id("id").source("{}", XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE));
|
||||
ActionRequestValidationException validate = bulkRequest.validate();
|
||||
assertThat(validate, notNullValue());
|
||||
assertThat(validate.validationErrors(), not(empty()));
|
||||
|
@ -265,7 +265,6 @@ public class BulkRequestTests extends OpenSearchTestCase {
|
|||
contains(
|
||||
"RefreshPolicy is not supported on an item request. Set it on the BulkRequest instead.",
|
||||
"id is missing",
|
||||
"type is missing",
|
||||
"RefreshPolicy is not supported on an item request. Set it on the BulkRequest instead.",
|
||||
"RefreshPolicy is not supported on an item request. Set it on the BulkRequest instead.",
|
||||
"RefreshPolicy is not supported on an item request. Set it on the BulkRequest instead."
|
||||
|
@ -276,8 +275,8 @@ public class BulkRequestTests extends OpenSearchTestCase {
|
|||
// issue 15120
|
||||
public void testBulkNoSource() throws Exception {
|
||||
BulkRequest bulkRequest = new BulkRequest();
|
||||
bulkRequest.add(new UpdateRequest("index", "type", "id"));
|
||||
bulkRequest.add(new IndexRequest("index", "type", "id"));
|
||||
bulkRequest.add(new UpdateRequest("index", "id"));
|
||||
bulkRequest.add(new IndexRequest("index").id("id"));
|
||||
ActionRequestValidationException validate = bulkRequest.validate();
|
||||
assertThat(validate, notNullValue());
|
||||
assertThat(validate.validationErrors(), not(empty()));
|
||||
|
|
|
@ -87,11 +87,11 @@ public class RetryTests extends OpenSearchTestCase {
|
|||
|
||||
private BulkRequest createBulkRequest() {
|
||||
BulkRequest request = new BulkRequest();
|
||||
request.add(new UpdateRequest("shop", "products", "1"));
|
||||
request.add(new UpdateRequest("shop", "products", "2"));
|
||||
request.add(new UpdateRequest("shop", "products", "3"));
|
||||
request.add(new UpdateRequest("shop", "products", "4"));
|
||||
request.add(new UpdateRequest("shop", "products", "5"));
|
||||
request.add(new UpdateRequest("shop", "1"));
|
||||
request.add(new UpdateRequest("shop", "2"));
|
||||
request.add(new UpdateRequest("shop", "3"));
|
||||
request.add(new UpdateRequest("shop", "4"));
|
||||
request.add(new UpdateRequest("shop", "5"));
|
||||
return request;
|
||||
}
|
||||
|
||||
|
@ -238,11 +238,7 @@ public class RetryTests extends OpenSearchTestCase {
|
|||
}
|
||||
|
||||
private BulkItemResponse successfulResponse() {
|
||||
return new BulkItemResponse(
|
||||
1,
|
||||
OpType.DELETE,
|
||||
new DeleteResponse(new ShardId("test", "test", 0), "_doc", "test", 0, 0, 0, false)
|
||||
);
|
||||
return new BulkItemResponse(1, OpType.DELETE, new DeleteResponse(new ShardId("test", "test", 0), "test", 0, 0, 0, false));
|
||||
}
|
||||
|
||||
private BulkItemResponse failedResponse() {
|
||||
|
|
|
@ -79,7 +79,7 @@ public class TransportBulkActionIndicesThatCannotBeCreatedTests extends OpenSear
|
|||
bulkRequest.add(new IndexRequest(randomAlphaOfLength(5)));
|
||||
bulkRequest.add(new IndexRequest(randomAlphaOfLength(5)));
|
||||
bulkRequest.add(new DeleteRequest(randomAlphaOfLength(5)));
|
||||
bulkRequest.add(new UpdateRequest(randomAlphaOfLength(5), randomAlphaOfLength(5), randomAlphaOfLength(5)));
|
||||
bulkRequest.add(new UpdateRequest(randomAlphaOfLength(5), randomAlphaOfLength(5)));
|
||||
// Test emulating auto_create_index=false
|
||||
indicesThatCannotBeCreatedTestCase(emptySet(), bulkRequest, null);
|
||||
// Test emulating auto_create_index=true
|
||||
|
@ -95,7 +95,7 @@ public class TransportBulkActionIndicesThatCannotBeCreatedTests extends OpenSear
|
|||
bulkRequest.add(new IndexRequest("no"));
|
||||
bulkRequest.add(new IndexRequest("can't"));
|
||||
bulkRequest.add(new DeleteRequest("do").version(0).versionType(VersionType.EXTERNAL));
|
||||
bulkRequest.add(new UpdateRequest("nothin", randomAlphaOfLength(5), randomAlphaOfLength(5)));
|
||||
bulkRequest.add(new UpdateRequest("nothin", randomAlphaOfLength(5)));
|
||||
indicesThatCannotBeCreatedTestCase(
|
||||
new HashSet<>(Arrays.asList("no", "can't", "do", "nothin")),
|
||||
bulkRequest,
|
||||
|
|
|
@ -290,7 +290,7 @@ public class TransportBulkActionIngestTests extends OpenSearchTestCase {
|
|||
|
||||
public void testIngestSkipped() throws Exception {
|
||||
BulkRequest bulkRequest = new BulkRequest();
|
||||
IndexRequest indexRequest = new IndexRequest("index", "type", "id");
|
||||
IndexRequest indexRequest = new IndexRequest("index").id("id");
|
||||
indexRequest.source(emptyMap());
|
||||
bulkRequest.add(indexRequest);
|
||||
action.execute(null, bulkRequest, ActionListener.wrap(response -> {}, exception -> { throw new AssertionError(exception); }));
|
||||
|
@ -299,7 +299,7 @@ public class TransportBulkActionIngestTests extends OpenSearchTestCase {
|
|||
}
|
||||
|
||||
public void testSingleItemBulkActionIngestSkipped() throws Exception {
|
||||
IndexRequest indexRequest = new IndexRequest("index", "type", "id");
|
||||
IndexRequest indexRequest = new IndexRequest("index").id("id");
|
||||
indexRequest.source(emptyMap());
|
||||
singleItemBulkWriteAction.execute(
|
||||
null,
|
||||
|
@ -313,10 +313,10 @@ public class TransportBulkActionIngestTests extends OpenSearchTestCase {
|
|||
public void testIngestLocal() throws Exception {
|
||||
Exception exception = new Exception("fake exception");
|
||||
BulkRequest bulkRequest = new BulkRequest();
|
||||
IndexRequest indexRequest1 = new IndexRequest("index", "type", "id");
|
||||
IndexRequest indexRequest1 = new IndexRequest("index").id("id");
|
||||
indexRequest1.source(emptyMap());
|
||||
indexRequest1.setPipeline("testpipeline");
|
||||
IndexRequest indexRequest2 = new IndexRequest("index", "type", "id");
|
||||
IndexRequest indexRequest2 = new IndexRequest("index").id("id");
|
||||
indexRequest2.source(emptyMap());
|
||||
indexRequest2.setPipeline("testpipeline");
|
||||
bulkRequest.add(indexRequest1);
|
||||
|
@ -360,7 +360,7 @@ public class TransportBulkActionIngestTests extends OpenSearchTestCase {
|
|||
|
||||
public void testSingleItemBulkActionIngestLocal() throws Exception {
|
||||
Exception exception = new Exception("fake exception");
|
||||
IndexRequest indexRequest = new IndexRequest("index", "type", "id");
|
||||
IndexRequest indexRequest = new IndexRequest("index").id("id");
|
||||
indexRequest.source(emptyMap());
|
||||
indexRequest.setPipeline("testpipeline");
|
||||
AtomicBoolean responseCalled = new AtomicBoolean(false);
|
||||
|
@ -444,7 +444,7 @@ public class TransportBulkActionIngestTests extends OpenSearchTestCase {
|
|||
public void testIngestForward() throws Exception {
|
||||
localIngest = false;
|
||||
BulkRequest bulkRequest = new BulkRequest();
|
||||
IndexRequest indexRequest = new IndexRequest("index", "type", "id");
|
||||
IndexRequest indexRequest = new IndexRequest("index").id("id");
|
||||
indexRequest.source(emptyMap());
|
||||
indexRequest.setPipeline("testpipeline");
|
||||
bulkRequest.add(indexRequest);
|
||||
|
@ -485,7 +485,7 @@ public class TransportBulkActionIngestTests extends OpenSearchTestCase {
|
|||
|
||||
public void testSingleItemBulkActionIngestForward() throws Exception {
|
||||
localIngest = false;
|
||||
IndexRequest indexRequest = new IndexRequest("index", "type", "id");
|
||||
IndexRequest indexRequest = new IndexRequest("index").id("id");
|
||||
indexRequest.source(emptyMap());
|
||||
indexRequest.setPipeline("testpipeline");
|
||||
IndexResponse indexResponse = mock(IndexResponse.class);
|
||||
|
@ -527,11 +527,11 @@ public class TransportBulkActionIngestTests extends OpenSearchTestCase {
|
|||
}
|
||||
|
||||
public void testUseDefaultPipeline() throws Exception {
|
||||
validateDefaultPipeline(new IndexRequest(WITH_DEFAULT_PIPELINE, "type", "id"));
|
||||
validateDefaultPipeline(new IndexRequest(WITH_DEFAULT_PIPELINE).id("id"));
|
||||
}
|
||||
|
||||
public void testUseDefaultPipelineWithAlias() throws Exception {
|
||||
validateDefaultPipeline(new IndexRequest(WITH_DEFAULT_PIPELINE_ALIAS, "type", "id"));
|
||||
validateDefaultPipeline(new IndexRequest(WITH_DEFAULT_PIPELINE_ALIAS).id("id"));
|
||||
}
|
||||
|
||||
public void testUseDefaultPipelineWithBulkUpsert() throws Exception {
|
||||
|
@ -547,15 +547,14 @@ public class TransportBulkActionIngestTests extends OpenSearchTestCase {
|
|||
private void validatePipelineWithBulkUpsert(@Nullable String indexRequestIndexName, String updateRequestIndexName) throws Exception {
|
||||
Exception exception = new Exception("fake exception");
|
||||
BulkRequest bulkRequest = new BulkRequest();
|
||||
IndexRequest indexRequest1 = new IndexRequest(indexRequestIndexName, "type", "id1").source(emptyMap());
|
||||
IndexRequest indexRequest2 = new IndexRequest(indexRequestIndexName, "type", "id2").source(emptyMap());
|
||||
IndexRequest indexRequest3 = new IndexRequest(indexRequestIndexName, "type", "id3").source(emptyMap());
|
||||
UpdateRequest upsertRequest = new UpdateRequest(updateRequestIndexName, "type", "id1").upsert(indexRequest1)
|
||||
.script(mockScript("1"));
|
||||
UpdateRequest docAsUpsertRequest = new UpdateRequest(updateRequestIndexName, "type", "id2").doc(indexRequest2).docAsUpsert(true);
|
||||
IndexRequest indexRequest1 = new IndexRequest(indexRequestIndexName).id("id1").source(emptyMap());
|
||||
IndexRequest indexRequest2 = new IndexRequest(indexRequestIndexName).id("id2").source(emptyMap());
|
||||
IndexRequest indexRequest3 = new IndexRequest(indexRequestIndexName).id("id3").source(emptyMap());
|
||||
UpdateRequest upsertRequest = new UpdateRequest(updateRequestIndexName, "id1").upsert(indexRequest1).script(mockScript("1"));
|
||||
UpdateRequest docAsUpsertRequest = new UpdateRequest(updateRequestIndexName, "id2").doc(indexRequest2).docAsUpsert(true);
|
||||
// this test only covers the mechanics that scripted bulk upserts will execute a default pipeline. However, in practice scripted
|
||||
// bulk upserts with a default pipeline are a bit surprising since the script executes AFTER the pipeline.
|
||||
UpdateRequest scriptedUpsert = new UpdateRequest(updateRequestIndexName, "type", "id2").upsert(indexRequest3)
|
||||
UpdateRequest scriptedUpsert = new UpdateRequest(updateRequestIndexName, "id2").upsert(indexRequest3)
|
||||
.script(mockScript("1"))
|
||||
.scriptedUpsert(true);
|
||||
bulkRequest.add(upsertRequest).add(docAsUpsertRequest).add(scriptedUpsert);
|
||||
|
@ -604,7 +603,7 @@ public class TransportBulkActionIngestTests extends OpenSearchTestCase {
|
|||
|
||||
public void testDoExecuteCalledTwiceCorrectly() throws Exception {
|
||||
Exception exception = new Exception("fake exception");
|
||||
IndexRequest indexRequest = new IndexRequest("missing_index", "type", "id");
|
||||
IndexRequest indexRequest = new IndexRequest("missing_index").id("id");
|
||||
indexRequest.setPipeline("testpipeline");
|
||||
indexRequest.source(emptyMap());
|
||||
AtomicBoolean responseCalled = new AtomicBoolean(false);
|
||||
|
@ -644,7 +643,7 @@ public class TransportBulkActionIngestTests extends OpenSearchTestCase {
|
|||
|
||||
public void testNotFindDefaultPipelineFromTemplateMatches() {
|
||||
Exception exception = new Exception("fake exception");
|
||||
IndexRequest indexRequest = new IndexRequest("missing_index", "type", "id");
|
||||
IndexRequest indexRequest = new IndexRequest("missing_index").id("id");
|
||||
indexRequest.source(emptyMap());
|
||||
AtomicBoolean responseCalled = new AtomicBoolean(false);
|
||||
AtomicBoolean failureCalled = new AtomicBoolean(false);
|
||||
|
@ -698,7 +697,7 @@ public class TransportBulkActionIngestTests extends OpenSearchTestCase {
|
|||
when(metadata.getTemplates()).thenReturn(templateMetadataBuilder.build());
|
||||
when(metadata.indices()).thenReturn(ImmutableOpenMap.of());
|
||||
|
||||
IndexRequest indexRequest = new IndexRequest("missing_index", "type", "id");
|
||||
IndexRequest indexRequest = new IndexRequest("missing_index").id("id");
|
||||
indexRequest.source(emptyMap());
|
||||
AtomicBoolean responseCalled = new AtomicBoolean(false);
|
||||
AtomicBoolean failureCalled = new AtomicBoolean(false);
|
||||
|
|
|
@ -168,7 +168,7 @@ public class TransportBulkActionTests extends OpenSearchTestCase {
|
|||
}
|
||||
|
||||
public void testDeleteNonExistingDocDoesNotCreateIndex() throws Exception {
|
||||
BulkRequest bulkRequest = new BulkRequest().add(new DeleteRequest("index", "type", "id"));
|
||||
BulkRequest bulkRequest = new BulkRequest().add(new DeleteRequest("index", "id"));
|
||||
|
||||
PlainActionFuture<BulkResponse> future = PlainActionFuture.newFuture();
|
||||
ActionTestUtils.execute(bulkAction, null, bulkRequest, future);
|
||||
|
@ -183,9 +183,7 @@ public class TransportBulkActionTests extends OpenSearchTestCase {
|
|||
}
|
||||
|
||||
public void testDeleteNonExistingDocExternalVersionCreatesIndex() throws Exception {
|
||||
BulkRequest bulkRequest = new BulkRequest().add(
|
||||
new DeleteRequest("index", "type", "id").versionType(VersionType.EXTERNAL).version(0)
|
||||
);
|
||||
BulkRequest bulkRequest = new BulkRequest().add(new DeleteRequest("index", "id").versionType(VersionType.EXTERNAL).version(0));
|
||||
|
||||
PlainActionFuture<BulkResponse> future = PlainActionFuture.newFuture();
|
||||
ActionTestUtils.execute(bulkAction, null, bulkRequest, future);
|
||||
|
@ -194,9 +192,7 @@ public class TransportBulkActionTests extends OpenSearchTestCase {
|
|||
}
|
||||
|
||||
public void testDeleteNonExistingDocExternalGteVersionCreatesIndex() throws Exception {
|
||||
BulkRequest bulkRequest = new BulkRequest().add(
|
||||
new DeleteRequest("index2", "type", "id").versionType(VersionType.EXTERNAL_GTE).version(0)
|
||||
);
|
||||
BulkRequest bulkRequest = new BulkRequest().add(new DeleteRequest("index2", "id").versionType(VersionType.EXTERNAL_GTE).version(0));
|
||||
|
||||
PlainActionFuture<BulkResponse> future = PlainActionFuture.newFuture();
|
||||
ActionTestUtils.execute(bulkAction, null, bulkRequest, future);
|
||||
|
@ -205,12 +201,10 @@ public class TransportBulkActionTests extends OpenSearchTestCase {
|
|||
}
|
||||
|
||||
public void testGetIndexWriteRequest() throws Exception {
|
||||
IndexRequest indexRequest = new IndexRequest("index", "type", "id1").source(emptyMap());
|
||||
UpdateRequest upsertRequest = new UpdateRequest("index", "type", "id1").upsert(indexRequest).script(mockScript("1"));
|
||||
UpdateRequest docAsUpsertRequest = new UpdateRequest("index", "type", "id2").doc(indexRequest).docAsUpsert(true);
|
||||
UpdateRequest scriptedUpsert = new UpdateRequest("index", "type", "id2").upsert(indexRequest)
|
||||
.script(mockScript("1"))
|
||||
.scriptedUpsert(true);
|
||||
IndexRequest indexRequest = new IndexRequest("index").id("id1").source(emptyMap());
|
||||
UpdateRequest upsertRequest = new UpdateRequest("index", "id1").upsert(indexRequest).script(mockScript("1"));
|
||||
UpdateRequest docAsUpsertRequest = new UpdateRequest("index", "id2").doc(indexRequest).docAsUpsert(true);
|
||||
UpdateRequest scriptedUpsert = new UpdateRequest("index", "id2").upsert(indexRequest).script(mockScript("1")).scriptedUpsert(true);
|
||||
|
||||
assertEquals(TransportBulkAction.getIndexWriteRequest(indexRequest), indexRequest);
|
||||
assertEquals(TransportBulkAction.getIndexWriteRequest(upsertRequest), indexRequest);
|
||||
|
@ -220,7 +214,7 @@ public class TransportBulkActionTests extends OpenSearchTestCase {
|
|||
DeleteRequest deleteRequest = new DeleteRequest("index", "id");
|
||||
assertNull(TransportBulkAction.getIndexWriteRequest(deleteRequest));
|
||||
|
||||
UpdateRequest badUpsertRequest = new UpdateRequest("index", "type", "id1");
|
||||
UpdateRequest badUpsertRequest = new UpdateRequest("index", "id1");
|
||||
assertNull(TransportBulkAction.getIndexWriteRequest(badUpsertRequest));
|
||||
}
|
||||
|
||||
|
|
|
@ -122,8 +122,7 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
|||
|
||||
BulkItemRequest[] items = new BulkItemRequest[1];
|
||||
boolean create = randomBoolean();
|
||||
DocWriteRequest<IndexRequest> writeRequest = new IndexRequest("index", "_doc", "id").source(Requests.INDEX_CONTENT_TYPE)
|
||||
.create(create);
|
||||
DocWriteRequest<IndexRequest> writeRequest = new IndexRequest("index").id("id").source(Requests.INDEX_CONTENT_TYPE).create(create);
|
||||
BulkItemRequest primaryRequest = new BulkItemRequest(0, writeRequest);
|
||||
items[0] = primaryRequest;
|
||||
BulkShardRequest bulkShardRequest = new BulkShardRequest(shardId, RefreshPolicy.NONE, items);
|
||||
|
@ -154,7 +153,7 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
|||
// Assert that the document actually made it there
|
||||
assertDocCount(shard, 1);
|
||||
|
||||
writeRequest = new IndexRequest("index", "_doc", "id").source(Requests.INDEX_CONTENT_TYPE).create(true);
|
||||
writeRequest = new IndexRequest("index").id("id").source(Requests.INDEX_CONTENT_TYPE).create(true);
|
||||
primaryRequest = new BulkItemRequest(0, writeRequest);
|
||||
items[0] = primaryRequest;
|
||||
bulkShardRequest = new BulkShardRequest(shardId, RefreshPolicy.NONE, items);
|
||||
|
@ -203,7 +202,8 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
|||
|
||||
BulkItemRequest[] items = new BulkItemRequest[randomIntBetween(2, 5)];
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
DocWriteRequest<IndexRequest> writeRequest = new IndexRequest("index", "_doc", "id_" + i).source(Requests.INDEX_CONTENT_TYPE)
|
||||
DocWriteRequest<IndexRequest> writeRequest = new IndexRequest("index").id("id_" + i)
|
||||
.source(Requests.INDEX_CONTENT_TYPE)
|
||||
.opType(DocWriteRequest.OpType.INDEX);
|
||||
items[i] = new BulkItemRequest(i, writeRequest);
|
||||
}
|
||||
|
@ -264,11 +264,7 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
|||
public void testExecuteBulkIndexRequestWithMappingUpdates() throws Exception {
|
||||
|
||||
BulkItemRequest[] items = new BulkItemRequest[1];
|
||||
DocWriteRequest<IndexRequest> writeRequest = new IndexRequest("index", "_doc", "id").source(
|
||||
Requests.INDEX_CONTENT_TYPE,
|
||||
"foo",
|
||||
"bar"
|
||||
);
|
||||
DocWriteRequest<IndexRequest> writeRequest = new IndexRequest("index").id("id").source(Requests.INDEX_CONTENT_TYPE, "foo", "bar");
|
||||
items[0] = new BulkItemRequest(0, writeRequest);
|
||||
BulkShardRequest bulkShardRequest = new BulkShardRequest(shardId, RefreshPolicy.NONE, items);
|
||||
|
||||
|
@ -342,11 +338,7 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
|||
IndexShard shard = newStartedShard(true);
|
||||
|
||||
BulkItemRequest[] items = new BulkItemRequest[1];
|
||||
DocWriteRequest<IndexRequest> writeRequest = new IndexRequest("index", "_doc", "id").source(
|
||||
Requests.INDEX_CONTENT_TYPE,
|
||||
"foo",
|
||||
"bar"
|
||||
);
|
||||
DocWriteRequest<IndexRequest> writeRequest = new IndexRequest("index").id("id").source(Requests.INDEX_CONTENT_TYPE, "foo", "bar");
|
||||
items[0] = new BulkItemRequest(0, writeRequest);
|
||||
BulkShardRequest bulkShardRequest = new BulkShardRequest(shardId, RefreshPolicy.NONE, items);
|
||||
|
||||
|
@ -402,7 +394,7 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
|||
IndexShard shard = newStartedShard(true);
|
||||
|
||||
BulkItemRequest[] items = new BulkItemRequest[1];
|
||||
DocWriteRequest<DeleteRequest> writeRequest = new DeleteRequest("index", "_doc", "id");
|
||||
DocWriteRequest<DeleteRequest> writeRequest = new DeleteRequest("index", "id");
|
||||
items[0] = new BulkItemRequest(0, writeRequest);
|
||||
BulkShardRequest bulkShardRequest = new BulkShardRequest(shardId, RefreshPolicy.NONE, items);
|
||||
|
||||
|
@ -441,7 +433,6 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
|||
assertThat(response.getResult(), equalTo(DocWriteResponse.Result.NOT_FOUND));
|
||||
assertThat(response.getShardId(), equalTo(shard.shardId()));
|
||||
assertThat(response.getIndex(), equalTo("index"));
|
||||
assertThat(response.getType(), equalTo("_doc"));
|
||||
assertThat(response.getId(), equalTo("id"));
|
||||
assertThat(response.getVersion(), equalTo(1L));
|
||||
assertThat(response.getSeqNo(), equalTo(0L));
|
||||
|
@ -450,7 +441,7 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
|||
// Now do the same after indexing the document, it should now find and delete the document
|
||||
indexDoc(shard, "_doc", "id", "{}");
|
||||
|
||||
writeRequest = new DeleteRequest("index", "_doc", "id");
|
||||
writeRequest = new DeleteRequest("index", "id");
|
||||
items[0] = new BulkItemRequest(0, writeRequest);
|
||||
bulkShardRequest = new BulkShardRequest(shardId, RefreshPolicy.NONE, items);
|
||||
|
||||
|
@ -489,7 +480,6 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
|||
assertThat(response.getResult(), equalTo(DocWriteResponse.Result.DELETED));
|
||||
assertThat(response.getShardId(), equalTo(shard.shardId()));
|
||||
assertThat(response.getIndex(), equalTo("index"));
|
||||
assertThat(response.getType(), equalTo("_doc"));
|
||||
assertThat(response.getId(), equalTo("id"));
|
||||
assertThat(response.getVersion(), equalTo(3L));
|
||||
assertThat(response.getSeqNo(), equalTo(2L));
|
||||
|
@ -500,14 +490,10 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
|||
}
|
||||
|
||||
public void testNoopUpdateRequest() throws Exception {
|
||||
DocWriteRequest<UpdateRequest> writeRequest = new UpdateRequest("index", "_doc", "id").doc(
|
||||
Requests.INDEX_CONTENT_TYPE,
|
||||
"field",
|
||||
"value"
|
||||
);
|
||||
DocWriteRequest<UpdateRequest> writeRequest = new UpdateRequest("index", "id").doc(Requests.INDEX_CONTENT_TYPE, "field", "value");
|
||||
BulkItemRequest primaryRequest = new BulkItemRequest(0, writeRequest);
|
||||
|
||||
DocWriteResponse noopUpdateResponse = new UpdateResponse(shardId, "_doc", "id", 0, 2, 1, DocWriteResponse.Result.NOOP);
|
||||
DocWriteResponse noopUpdateResponse = new UpdateResponse(shardId, "id", 0, 2, 1, DocWriteResponse.Result.NOOP);
|
||||
|
||||
IndexShard shard = mock(IndexShard.class);
|
||||
|
||||
|
@ -553,14 +539,10 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
|||
|
||||
public void testUpdateRequestWithFailure() throws Exception {
|
||||
IndexSettings indexSettings = new IndexSettings(indexMetadata(), Settings.EMPTY);
|
||||
DocWriteRequest<UpdateRequest> writeRequest = new UpdateRequest("index", "_doc", "id").doc(
|
||||
Requests.INDEX_CONTENT_TYPE,
|
||||
"field",
|
||||
"value"
|
||||
);
|
||||
DocWriteRequest<UpdateRequest> writeRequest = new UpdateRequest("index", "id").doc(Requests.INDEX_CONTENT_TYPE, "field", "value");
|
||||
BulkItemRequest primaryRequest = new BulkItemRequest(0, writeRequest);
|
||||
|
||||
IndexRequest updateResponse = new IndexRequest("index", "_doc", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value");
|
||||
IndexRequest updateResponse = new IndexRequest("index").id("id").source(Requests.INDEX_CONTENT_TYPE, "field", "value");
|
||||
|
||||
Exception err = new OpenSearchException("I'm dead <(x.x)>");
|
||||
Engine.IndexResult indexResult = new Engine.IndexResult(err, 0, 0, 0);
|
||||
|
@ -614,14 +596,10 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
|||
|
||||
public void testUpdateRequestWithConflictFailure() throws Exception {
|
||||
IndexSettings indexSettings = new IndexSettings(indexMetadata(), Settings.EMPTY);
|
||||
DocWriteRequest<UpdateRequest> writeRequest = new UpdateRequest("index", "_doc", "id").doc(
|
||||
Requests.INDEX_CONTENT_TYPE,
|
||||
"field",
|
||||
"value"
|
||||
);
|
||||
DocWriteRequest<UpdateRequest> writeRequest = new UpdateRequest("index", "id").doc(Requests.INDEX_CONTENT_TYPE, "field", "value");
|
||||
BulkItemRequest primaryRequest = new BulkItemRequest(0, writeRequest);
|
||||
|
||||
IndexRequest updateResponse = new IndexRequest("index", "_doc", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value");
|
||||
IndexRequest updateResponse = new IndexRequest("index").id("id").source(Requests.INDEX_CONTENT_TYPE, "field", "value");
|
||||
|
||||
Exception err = new VersionConflictEngineException(shardId, "id", "I'm conflicted <(;_;)>");
|
||||
Engine.IndexResult indexResult = new Engine.IndexResult(err, 0, 0, 0);
|
||||
|
@ -673,14 +651,10 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
|||
|
||||
public void testUpdateRequestWithSuccess() throws Exception {
|
||||
IndexSettings indexSettings = new IndexSettings(indexMetadata(), Settings.EMPTY);
|
||||
DocWriteRequest<UpdateRequest> writeRequest = new UpdateRequest("index", "_doc", "id").doc(
|
||||
Requests.INDEX_CONTENT_TYPE,
|
||||
"field",
|
||||
"value"
|
||||
);
|
||||
DocWriteRequest<UpdateRequest> writeRequest = new UpdateRequest("index", "id").doc(Requests.INDEX_CONTENT_TYPE, "field", "value");
|
||||
BulkItemRequest primaryRequest = new BulkItemRequest(0, writeRequest);
|
||||
|
||||
IndexRequest updateResponse = new IndexRequest("index", "_doc", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value");
|
||||
IndexRequest updateResponse = new IndexRequest("index").id("id").source(Requests.INDEX_CONTENT_TYPE, "field", "value");
|
||||
|
||||
boolean created = randomBoolean();
|
||||
Translog.Location resultLocation = new Translog.Location(42, 42, 42);
|
||||
|
@ -734,14 +708,10 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
|||
|
||||
public void testUpdateWithDelete() throws Exception {
|
||||
IndexSettings indexSettings = new IndexSettings(indexMetadata(), Settings.EMPTY);
|
||||
DocWriteRequest<UpdateRequest> writeRequest = new UpdateRequest("index", "_doc", "id").doc(
|
||||
Requests.INDEX_CONTENT_TYPE,
|
||||
"field",
|
||||
"value"
|
||||
);
|
||||
DocWriteRequest<UpdateRequest> writeRequest = new UpdateRequest("index", "id").doc(Requests.INDEX_CONTENT_TYPE, "field", "value");
|
||||
BulkItemRequest primaryRequest = new BulkItemRequest(0, writeRequest);
|
||||
|
||||
DeleteRequest updateResponse = new DeleteRequest("index", "_doc", "id");
|
||||
DeleteRequest updateResponse = new DeleteRequest("index", "id");
|
||||
|
||||
boolean found = randomBoolean();
|
||||
Translog.Location resultLocation = new Translog.Location(42, 42, 42);
|
||||
|
@ -791,11 +761,7 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
|||
}
|
||||
|
||||
public void testFailureDuringUpdateProcessing() throws Exception {
|
||||
DocWriteRequest<UpdateRequest> writeRequest = new UpdateRequest("index", "_doc", "id").doc(
|
||||
Requests.INDEX_CONTENT_TYPE,
|
||||
"field",
|
||||
"value"
|
||||
);
|
||||
DocWriteRequest<UpdateRequest> writeRequest = new UpdateRequest("index", "id").doc(Requests.INDEX_CONTENT_TYPE, "field", "value");
|
||||
BulkItemRequest primaryRequest = new BulkItemRequest(0, writeRequest);
|
||||
|
||||
IndexShard shard = mock(IndexShard.class);
|
||||
|
@ -838,7 +804,8 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
|||
|
||||
BulkItemRequest[] items = new BulkItemRequest[randomIntBetween(2, 5)];
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
DocWriteRequest<IndexRequest> writeRequest = new IndexRequest("index", "_doc", "id_" + i).source(Requests.INDEX_CONTENT_TYPE)
|
||||
DocWriteRequest<IndexRequest> writeRequest = new IndexRequest("index").id("id_" + i)
|
||||
.source(Requests.INDEX_CONTENT_TYPE)
|
||||
.opType(DocWriteRequest.OpType.INDEX);
|
||||
items[i] = new BulkItemRequest(i, writeRequest);
|
||||
}
|
||||
|
@ -875,7 +842,7 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
|||
|
||||
public void testNoOpReplicationOnPrimaryDocumentFailure() throws Exception {
|
||||
final IndexShard shard = spy(newStartedShard(false));
|
||||
BulkItemRequest itemRequest = new BulkItemRequest(0, new IndexRequest("index", "_doc").source(Requests.INDEX_CONTENT_TYPE));
|
||||
BulkItemRequest itemRequest = new BulkItemRequest(0, new IndexRequest("index").source(Requests.INDEX_CONTENT_TYPE));
|
||||
final String failureMessage = "simulated primary failure";
|
||||
final IOException exception = new IOException(failureMessage);
|
||||
itemRequest.setPrimaryResponse(
|
||||
|
@ -895,12 +862,12 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
|||
|
||||
public void testRetries() throws Exception {
|
||||
IndexSettings indexSettings = new IndexSettings(indexMetadata(), Settings.EMPTY);
|
||||
UpdateRequest writeRequest = new UpdateRequest("index", "_doc", "id").doc(Requests.INDEX_CONTENT_TYPE, "field", "value");
|
||||
UpdateRequest writeRequest = new UpdateRequest("index", "id").doc(Requests.INDEX_CONTENT_TYPE, "field", "value");
|
||||
// the beating will continue until success has come.
|
||||
writeRequest.retryOnConflict(Integer.MAX_VALUE);
|
||||
BulkItemRequest primaryRequest = new BulkItemRequest(0, writeRequest);
|
||||
|
||||
IndexRequest updateResponse = new IndexRequest("index", "_doc", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value");
|
||||
IndexRequest updateResponse = new IndexRequest("index").id("id").source(Requests.INDEX_CONTENT_TYPE, "field", "value");
|
||||
|
||||
Exception err = new VersionConflictEngineException(shardId, "id", "I'm conflicted <(;_;)>");
|
||||
Engine.IndexResult conflictedResult = new Engine.IndexResult(err, 0);
|
||||
|
@ -1078,7 +1045,7 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
|||
new BulkItemResponse(
|
||||
0,
|
||||
DocWriteRequest.OpType.INDEX,
|
||||
new IndexResponse(shardId, "_doc", "ignore-primary-response-on-primary", 42, 42, 42, false)
|
||||
new IndexResponse(shardId, "ignore-primary-response-on-primary", 42, 42, 42, false)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -42,23 +42,14 @@ public class DeleteRequestTests extends OpenSearchTestCase {
|
|||
|
||||
public void testValidation() {
|
||||
{
|
||||
final DeleteRequest request = new DeleteRequest("index4", "_doc", "0");
|
||||
final DeleteRequest request = new DeleteRequest("index4", "0");
|
||||
final ActionRequestValidationException validate = request.validate();
|
||||
|
||||
assertThat(validate, nullValue());
|
||||
}
|
||||
|
||||
{
|
||||
// Empty types are accepted but fail validation
|
||||
final DeleteRequest request = new DeleteRequest("index4", "", randomBoolean() ? "" : null);
|
||||
final ActionRequestValidationException validate = request.validate();
|
||||
|
||||
assertThat(validate, not(nullValue()));
|
||||
assertThat(validate.validationErrors(), hasItems("type is missing", "id is missing"));
|
||||
}
|
||||
{
|
||||
// Null types are defaulted
|
||||
final DeleteRequest request = new DeleteRequest("index4", randomBoolean() ? "" : null);
|
||||
final DeleteRequest request = new DeleteRequest("index4", null);
|
||||
final ActionRequestValidationException validate = request.validate();
|
||||
|
||||
assertThat(validate, not(nullValue()));
|
||||
|
|
|
@ -55,21 +55,21 @@ public class DeleteResponseTests extends OpenSearchTestCase {
|
|||
|
||||
public void testToXContent() {
|
||||
{
|
||||
DeleteResponse response = new DeleteResponse(new ShardId("index", "index_uuid", 0), "type", "id", 3, 17, 5, true);
|
||||
DeleteResponse response = new DeleteResponse(new ShardId("index", "index_uuid", 0), "id", 3, 17, 5, true);
|
||||
String output = Strings.toString(response);
|
||||
assertEquals(
|
||||
"{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":5,\"result\":\"deleted\","
|
||||
"{\"_index\":\"index\",\"_id\":\"id\",\"_version\":5,\"result\":\"deleted\","
|
||||
+ "\"_shards\":null,\"_seq_no\":3,\"_primary_term\":17}",
|
||||
output
|
||||
);
|
||||
}
|
||||
{
|
||||
DeleteResponse response = new DeleteResponse(new ShardId("index", "index_uuid", 0), "type", "id", -1, 0, 7, true);
|
||||
DeleteResponse response = new DeleteResponse(new ShardId("index", "index_uuid", 0), "id", -1, 0, 7, true);
|
||||
response.setForcedRefresh(true);
|
||||
response.setShardInfo(new ReplicationResponse.ShardInfo(10, 5));
|
||||
String output = Strings.toString(response);
|
||||
assertEquals(
|
||||
"{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":7,\"result\":\"deleted\","
|
||||
"{\"_index\":\"index\",\"_id\":\"id\",\"_version\":7,\"result\":\"deleted\","
|
||||
+ "\"forced_refresh\":true,\"_shards\":{\"total\":10,\"successful\":5,\"failed\":0}}",
|
||||
output
|
||||
);
|
||||
|
@ -141,19 +141,11 @@ public class DeleteResponseTests extends OpenSearchTestCase {
|
|||
|
||||
Tuple<ReplicationResponse.ShardInfo, ReplicationResponse.ShardInfo> shardInfos = RandomObjects.randomShardInfo(random());
|
||||
|
||||
DeleteResponse actual = new DeleteResponse(new ShardId(index, indexUUid, shardId), type, id, seqNo, primaryTerm, version, found);
|
||||
DeleteResponse actual = new DeleteResponse(new ShardId(index, indexUUid, shardId), id, seqNo, primaryTerm, version, found);
|
||||
actual.setForcedRefresh(forcedRefresh);
|
||||
actual.setShardInfo(shardInfos.v1());
|
||||
|
||||
DeleteResponse expected = new DeleteResponse(
|
||||
new ShardId(index, INDEX_UUID_NA_VALUE, -1),
|
||||
type,
|
||||
id,
|
||||
seqNo,
|
||||
primaryTerm,
|
||||
version,
|
||||
found
|
||||
);
|
||||
DeleteResponse expected = new DeleteResponse(new ShardId(index, INDEX_UUID_NA_VALUE, -1), id, seqNo, primaryTerm, version, found);
|
||||
expected.setForcedRefresh(forcedRefresh);
|
||||
expected.setShardInfo(shardInfos.v2());
|
||||
|
||||
|
|
|
@ -137,11 +137,10 @@ public class IndexRequestTests extends OpenSearchTestCase {
|
|||
|
||||
public void testIndexResponse() {
|
||||
ShardId shardId = new ShardId(randomAlphaOfLengthBetween(3, 10), randomAlphaOfLengthBetween(3, 10), randomIntBetween(0, 1000));
|
||||
String type = randomAlphaOfLengthBetween(3, 10);
|
||||
String id = randomAlphaOfLengthBetween(3, 10);
|
||||
long version = randomLong();
|
||||
boolean created = randomBoolean();
|
||||
IndexResponse indexResponse = new IndexResponse(shardId, type, id, SequenceNumbers.UNASSIGNED_SEQ_NO, 0, version, created);
|
||||
IndexResponse indexResponse = new IndexResponse(shardId, id, SequenceNumbers.UNASSIGNED_SEQ_NO, 0, version, created);
|
||||
int total = randomIntBetween(1, 10);
|
||||
int successful = randomIntBetween(1, 10);
|
||||
ReplicationResponse.ShardInfo shardInfo = new ReplicationResponse.ShardInfo(total, successful);
|
||||
|
@ -151,7 +150,6 @@ public class IndexRequestTests extends OpenSearchTestCase {
|
|||
forcedRefresh = randomBoolean();
|
||||
indexResponse.setForcedRefresh(forcedRefresh);
|
||||
}
|
||||
assertEquals(type, indexResponse.getType());
|
||||
assertEquals(id, indexResponse.getId());
|
||||
assertEquals(version, indexResponse.getVersion());
|
||||
assertEquals(shardId, indexResponse.getShardId());
|
||||
|
@ -162,8 +160,6 @@ public class IndexRequestTests extends OpenSearchTestCase {
|
|||
assertEquals(
|
||||
"IndexResponse[index="
|
||||
+ shardId.getIndexName()
|
||||
+ ",type="
|
||||
+ type
|
||||
+ ",id="
|
||||
+ id
|
||||
+ ",version="
|
||||
|
@ -220,13 +216,13 @@ public class IndexRequestTests extends OpenSearchTestCase {
|
|||
|
||||
String source = "{\"name\":\"value\"}";
|
||||
request.source(source, XContentType.JSON);
|
||||
assertEquals("index {[index][_doc][null], source[" + source + "]}", request.toString());
|
||||
assertEquals("index {[index][null], source[" + source + "]}", request.toString());
|
||||
|
||||
source = "{\"name\":\"" + randomUnicodeOfLength(IndexRequest.MAX_SOURCE_LENGTH_IN_TOSTRING) + "\"}";
|
||||
request.source(source, XContentType.JSON);
|
||||
int actualBytes = source.getBytes("UTF-8").length;
|
||||
assertEquals(
|
||||
"index {[index][_doc][null], source[n/a, actual length: ["
|
||||
"index {[index][null], source[n/a, actual length: ["
|
||||
+ new ByteSizeValue(actualBytes).toString()
|
||||
+ "], max length: "
|
||||
+ new ByteSizeValue(IndexRequest.MAX_SOURCE_LENGTH_IN_TOSTRING).toString()
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue