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