[Remove] type support from Bulk API (#2215)
Removes all support for type parameter from the Bulk API. Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
This commit is contained in:
parent
44441d8fc5
commit
1b571ece28
|
@ -97,7 +97,6 @@ public class RestNoopBulkAction extends BaseRestHandler {
|
||||||
bulkRequest.add(
|
bulkRequest.add(
|
||||||
request.requiredContent(),
|
request.requiredContent(),
|
||||||
defaultIndex,
|
defaultIndex,
|
||||||
defaultType,
|
|
||||||
defaultRouting,
|
defaultRouting,
|
||||||
null,
|
null,
|
||||||
defaultPipeline,
|
defaultPipeline,
|
||||||
|
|
|
@ -49,11 +49,8 @@ import org.opensearch.common.unit.ByteSizeValue;
|
||||||
import org.opensearch.common.unit.TimeValue;
|
import org.opensearch.common.unit.TimeValue;
|
||||||
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.index.mapper.MapperService;
|
|
||||||
import org.opensearch.rest.action.document.RestBulkAction;
|
|
||||||
import org.opensearch.search.SearchHit;
|
import org.opensearch.search.SearchHit;
|
||||||
import org.hamcrest.Matcher;
|
import org.hamcrest.Matcher;
|
||||||
import org.hamcrest.Matchers;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -69,9 +66,7 @@ import java.util.stream.IntStream;
|
||||||
import static org.opensearch.common.xcontent.XContentFactory.jsonBuilder;
|
import static org.opensearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.fieldFromSource;
|
import static org.opensearch.test.hamcrest.OpenSearchAssertions.fieldFromSource;
|
||||||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.hasId;
|
import static org.opensearch.test.hamcrest.OpenSearchAssertions.hasId;
|
||||||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.hasIndex;
|
|
||||||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.hasProperty;
|
import static org.opensearch.test.hamcrest.OpenSearchAssertions.hasProperty;
|
||||||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.hasType;
|
|
||||||
import static org.hamcrest.Matchers.both;
|
import static org.hamcrest.Matchers.both;
|
||||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
import static org.hamcrest.Matchers.either;
|
import static org.hamcrest.Matchers.either;
|
||||||
|
@ -96,17 +91,6 @@ public class BulkProcessorIT extends OpenSearchRestHighLevelClientTestCase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BulkProcessor.Builder initBulkProcessorBuilderUsingTypes(BulkProcessor.Listener listener) {
|
|
||||||
return BulkProcessor.builder(
|
|
||||||
(request, bulkListener) -> highLevelClient().bulkAsync(
|
|
||||||
request,
|
|
||||||
expectWarningsOnce(RestBulkAction.TYPES_DEPRECATION_MESSAGE),
|
|
||||||
bulkListener
|
|
||||||
),
|
|
||||||
listener
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testThatBulkProcessorCountIsCorrect() throws Exception {
|
public void testThatBulkProcessorCountIsCorrect() throws Exception {
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
BulkProcessorTestListener listener = new BulkProcessorTestListener(latch);
|
BulkProcessorTestListener listener = new BulkProcessorTestListener(latch);
|
||||||
|
@ -210,7 +194,6 @@ public class BulkProcessorIT extends OpenSearchRestHighLevelClientTestCase {
|
||||||
for (BulkItemResponse bulkItemResponse : listener.bulkItems) {
|
for (BulkItemResponse bulkItemResponse : listener.bulkItems) {
|
||||||
assertThat(bulkItemResponse.getFailureMessage(), bulkItemResponse.isFailed(), equalTo(false));
|
assertThat(bulkItemResponse.getFailureMessage(), bulkItemResponse.isFailed(), equalTo(false));
|
||||||
assertThat(bulkItemResponse.getIndex(), equalTo("test"));
|
assertThat(bulkItemResponse.getIndex(), equalTo("test"));
|
||||||
assertThat(bulkItemResponse.getType(), equalTo("_doc"));
|
|
||||||
// with concurrent requests > 1 we can't rely on the order of the bulk requests
|
// with concurrent requests > 1 we can't rely on the order of the bulk requests
|
||||||
assertThat(Integer.valueOf(bulkItemResponse.getId()), both(greaterThan(0)).and(lessThanOrEqualTo(numDocs)));
|
assertThat(Integer.valueOf(bulkItemResponse.getId()), both(greaterThan(0)).and(lessThanOrEqualTo(numDocs)));
|
||||||
// we do want to check that we don't get duplicate ids back
|
// we do want to check that we don't get duplicate ids back
|
||||||
|
@ -317,7 +300,6 @@ public class BulkProcessorIT extends OpenSearchRestHighLevelClientTestCase {
|
||||||
Set<String> readOnlyIds = new HashSet<>();
|
Set<String> readOnlyIds = new HashSet<>();
|
||||||
for (BulkItemResponse bulkItemResponse : listener.bulkItems) {
|
for (BulkItemResponse bulkItemResponse : listener.bulkItems) {
|
||||||
assertThat(bulkItemResponse.getIndex(), either(equalTo("test")).or(equalTo("test-ro")));
|
assertThat(bulkItemResponse.getIndex(), either(equalTo("test")).or(equalTo("test-ro")));
|
||||||
assertThat(bulkItemResponse.getType(), equalTo("_doc"));
|
|
||||||
if (bulkItemResponse.getIndex().equals("test")) {
|
if (bulkItemResponse.getIndex().equals("test")) {
|
||||||
assertThat(bulkItemResponse.isFailed(), equalTo(false));
|
assertThat(bulkItemResponse.isFailed(), equalTo(false));
|
||||||
// with concurrent requests > 1 we can't rely on the order of the bulk requests
|
// with concurrent requests > 1 we can't rely on the order of the bulk requests
|
||||||
|
@ -346,7 +328,6 @@ public class BulkProcessorIT extends OpenSearchRestHighLevelClientTestCase {
|
||||||
// tag::bulk-processor-mix-parameters
|
// tag::bulk-processor-mix-parameters
|
||||||
try (BulkProcessor processor = initBulkProcessorBuilder(listener)
|
try (BulkProcessor processor = initBulkProcessorBuilder(listener)
|
||||||
.setGlobalIndex("tweets")
|
.setGlobalIndex("tweets")
|
||||||
.setGlobalType("_doc")
|
|
||||||
.setGlobalRouting("routing")
|
.setGlobalRouting("routing")
|
||||||
.setGlobalPipeline("pipeline_id")
|
.setGlobalPipeline("pipeline_id")
|
||||||
.build()) {
|
.build()) {
|
||||||
|
@ -373,87 +354,13 @@ public class BulkProcessorIT extends OpenSearchRestHighLevelClientTestCase {
|
||||||
createIndexWithMultipleShards("test");
|
createIndexWithMultipleShards("test");
|
||||||
|
|
||||||
createFieldAddingPipleine("pipeline_id", "fieldNameXYZ", "valueXYZ");
|
createFieldAddingPipleine("pipeline_id", "fieldNameXYZ", "valueXYZ");
|
||||||
final String customType = "testType";
|
|
||||||
final String ignoredType = "ignoredType";
|
|
||||||
|
|
||||||
int numDocs = randomIntBetween(10, 10);
|
int numDocs = randomIntBetween(10, 10);
|
||||||
{
|
{
|
||||||
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
|
// Check that untyped document additions inherit the global type
|
||||||
String globalType = customType;
|
|
||||||
String localType = null;
|
String localType = null;
|
||||||
try (
|
|
||||||
BulkProcessor processor = initBulkProcessorBuilderUsingTypes(listener)
|
|
||||||
// let's make sure that the bulk action limit trips, one single execution will index all the documents
|
|
||||||
.setConcurrentRequests(randomIntBetween(0, 1))
|
|
||||||
.setBulkActions(numDocs)
|
|
||||||
.setFlushInterval(TimeValue.timeValueHours(24))
|
|
||||||
.setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB))
|
|
||||||
.setGlobalIndex("test")
|
|
||||||
.setGlobalType(globalType)
|
|
||||||
.setGlobalRouting("routing")
|
|
||||||
.setGlobalPipeline("pipeline_id")
|
|
||||||
.build()
|
|
||||||
) {
|
|
||||||
|
|
||||||
indexDocs(processor, numDocs, null, localType, "test", globalType, "pipeline_id");
|
|
||||||
latch.await();
|
|
||||||
|
|
||||||
assertThat(listener.beforeCounts.get(), equalTo(1));
|
|
||||||
assertThat(listener.afterCounts.get(), equalTo(1));
|
|
||||||
assertThat(listener.bulkFailures.size(), equalTo(0));
|
|
||||||
assertResponseItems(listener.bulkItems, numDocs, globalType);
|
|
||||||
|
|
||||||
Iterable<SearchHit> hits = searchAll(new SearchRequest("test").routing("routing"));
|
|
||||||
|
|
||||||
assertThat(hits, everyItem(hasProperty(fieldFromSource("fieldNameXYZ"), equalTo("valueXYZ"))));
|
|
||||||
assertThat(hits, everyItem(Matchers.allOf(hasIndex("test"), hasType(globalType))));
|
|
||||||
assertThat(hits, containsInAnyOrder(expectedIds(numDocs)));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
{
|
|
||||||
// Check that typed document additions don't inherit the global type
|
|
||||||
String globalType = ignoredType;
|
|
||||||
String localType = customType;
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
|
||||||
BulkProcessorTestListener listener = new BulkProcessorTestListener(latch);
|
|
||||||
try (
|
|
||||||
BulkProcessor processor = initBulkProcessorBuilderUsingTypes(listener)
|
|
||||||
// let's make sure that the bulk action limit trips, one single execution will index all the documents
|
|
||||||
.setConcurrentRequests(randomIntBetween(0, 1))
|
|
||||||
.setBulkActions(numDocs)
|
|
||||||
.setFlushInterval(TimeValue.timeValueHours(24))
|
|
||||||
.setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB))
|
|
||||||
.setGlobalIndex("test")
|
|
||||||
.setGlobalType(globalType)
|
|
||||||
.setGlobalRouting("routing")
|
|
||||||
.setGlobalPipeline("pipeline_id")
|
|
||||||
.build()
|
|
||||||
) {
|
|
||||||
indexDocs(processor, numDocs, null, localType, "test", globalType, "pipeline_id");
|
|
||||||
latch.await();
|
|
||||||
|
|
||||||
assertThat(listener.beforeCounts.get(), equalTo(1));
|
|
||||||
assertThat(listener.afterCounts.get(), equalTo(1));
|
|
||||||
assertThat(listener.bulkFailures.size(), equalTo(0));
|
|
||||||
assertResponseItems(listener.bulkItems, numDocs, localType);
|
|
||||||
|
|
||||||
Iterable<SearchHit> hits = searchAll(new SearchRequest("test").routing("routing"));
|
|
||||||
|
|
||||||
assertThat(hits, everyItem(hasProperty(fieldFromSource("fieldNameXYZ"), equalTo("valueXYZ"))));
|
|
||||||
assertThat(hits, everyItem(Matchers.allOf(hasIndex("test"), hasType(localType))));
|
|
||||||
assertThat(hits, containsInAnyOrder(expectedIds(numDocs)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
// Check that untyped document additions and untyped global inherit the established custom type
|
|
||||||
// (the custom document type introduced to the mapping by the earlier code in this test)
|
|
||||||
String globalType = null;
|
|
||||||
String localType = null;
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
|
||||||
BulkProcessorTestListener listener = new BulkProcessorTestListener(latch);
|
|
||||||
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
|
||||||
|
@ -462,23 +369,22 @@ public class BulkProcessorIT extends OpenSearchRestHighLevelClientTestCase {
|
||||||
.setFlushInterval(TimeValue.timeValueHours(24))
|
.setFlushInterval(TimeValue.timeValueHours(24))
|
||||||
.setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB))
|
.setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB))
|
||||||
.setGlobalIndex("test")
|
.setGlobalIndex("test")
|
||||||
.setGlobalType(globalType)
|
|
||||||
.setGlobalRouting("routing")
|
.setGlobalRouting("routing")
|
||||||
.setGlobalPipeline("pipeline_id")
|
.setGlobalPipeline("pipeline_id")
|
||||||
.build()
|
.build()
|
||||||
) {
|
) {
|
||||||
indexDocs(processor, numDocs, null, localType, "test", globalType, "pipeline_id");
|
|
||||||
|
indexDocs(processor, numDocs, null, localType, "test", "pipeline_id");
|
||||||
latch.await();
|
latch.await();
|
||||||
|
|
||||||
assertThat(listener.beforeCounts.get(), equalTo(1));
|
assertThat(listener.beforeCounts.get(), equalTo(1));
|
||||||
assertThat(listener.afterCounts.get(), equalTo(1));
|
assertThat(listener.afterCounts.get(), equalTo(1));
|
||||||
assertThat(listener.bulkFailures.size(), equalTo(0));
|
assertThat(listener.bulkFailures.size(), equalTo(0));
|
||||||
assertResponseItems(listener.bulkItems, numDocs, MapperService.SINGLE_MAPPING_NAME);
|
assertResponseItems(listener.bulkItems, numDocs);
|
||||||
|
|
||||||
Iterable<SearchHit> hits = searchAll(new SearchRequest("test").routing("routing"));
|
Iterable<SearchHit> hits = searchAll(new SearchRequest("test").routing("routing"));
|
||||||
|
|
||||||
assertThat(hits, everyItem(hasProperty(fieldFromSource("fieldNameXYZ"), equalTo("valueXYZ"))));
|
assertThat(hits, everyItem(hasProperty(fieldFromSource("fieldNameXYZ"), equalTo("valueXYZ"))));
|
||||||
assertThat(hits, everyItem(Matchers.allOf(hasIndex("test"), hasType(customType))));
|
|
||||||
assertThat(hits, containsInAnyOrder(expectedIds(numDocs)));
|
assertThat(hits, containsInAnyOrder(expectedIds(numDocs)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -495,7 +401,6 @@ public class BulkProcessorIT extends OpenSearchRestHighLevelClientTestCase {
|
||||||
String localIndex,
|
String localIndex,
|
||||||
String localType,
|
String localType,
|
||||||
String globalIndex,
|
String globalIndex,
|
||||||
String globalType,
|
|
||||||
String globalPipeline
|
String globalPipeline
|
||||||
) throws Exception {
|
) throws Exception {
|
||||||
MultiGetRequest multiGetRequest = new MultiGetRequest();
|
MultiGetRequest multiGetRequest = new MultiGetRequest();
|
||||||
|
@ -510,7 +415,7 @@ public class BulkProcessorIT extends OpenSearchRestHighLevelClientTestCase {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
BytesArray data = bytesBulkRequest(localIndex, localType, i);
|
BytesArray data = bytesBulkRequest(localIndex, localType, i);
|
||||||
processor.add(data, globalIndex, globalType, globalPipeline, XContentType.JSON);
|
processor.add(data, globalIndex, globalPipeline, XContentType.JSON);
|
||||||
}
|
}
|
||||||
multiGetRequest.add(localIndex, Integer.toString(i));
|
multiGetRequest.add(localIndex, Integer.toString(i));
|
||||||
}
|
}
|
||||||
|
@ -538,19 +443,14 @@ 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, null);
|
return indexDocs(processor, numDocs, "test", null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertResponseItems(List<BulkItemResponse> bulkItemResponses, int numDocs) {
|
private static void assertResponseItems(List<BulkItemResponse> bulkItemResponses, int numDocs) {
|
||||||
assertResponseItems(bulkItemResponses, numDocs, MapperService.SINGLE_MAPPING_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void assertResponseItems(List<BulkItemResponse> bulkItemResponses, int numDocs, String expectedType) {
|
|
||||||
assertThat(bulkItemResponses.size(), is(numDocs));
|
assertThat(bulkItemResponses.size(), is(numDocs));
|
||||||
int i = 1;
|
int i = 1;
|
||||||
for (BulkItemResponse bulkItemResponse : bulkItemResponses) {
|
for (BulkItemResponse bulkItemResponse : bulkItemResponses) {
|
||||||
assertThat(bulkItemResponse.getIndex(), equalTo("test"));
|
assertThat(bulkItemResponse.getIndex(), equalTo("test"));
|
||||||
assertThat(bulkItemResponse.getType(), equalTo(expectedType));
|
|
||||||
assertThat(bulkItemResponse.getId(), equalTo(Integer.toString(i++)));
|
assertThat(bulkItemResponse.getId(), equalTo(Integer.toString(i++)));
|
||||||
assertThat(
|
assertThat(
|
||||||
"item " + i + " failed with cause: " + bulkItemResponse.getFailureMessage(),
|
"item " + i + " failed with cause: " + bulkItemResponse.getFailureMessage(),
|
||||||
|
|
|
@ -37,7 +37,6 @@ import org.opensearch.action.bulk.BulkResponse;
|
||||||
import org.opensearch.action.index.IndexRequest;
|
import org.opensearch.action.index.IndexRequest;
|
||||||
import org.opensearch.action.search.SearchRequest;
|
import org.opensearch.action.search.SearchRequest;
|
||||||
import org.opensearch.common.xcontent.XContentType;
|
import org.opensearch.common.xcontent.XContentType;
|
||||||
import org.opensearch.rest.action.document.RestBulkAction;
|
|
||||||
import org.opensearch.search.SearchHit;
|
import org.opensearch.search.SearchHit;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -46,7 +45,6 @@ import java.util.function.Function;
|
||||||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.hasId;
|
import static org.opensearch.test.hamcrest.OpenSearchAssertions.hasId;
|
||||||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.hasIndex;
|
import static org.opensearch.test.hamcrest.OpenSearchAssertions.hasIndex;
|
||||||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.hasProperty;
|
import static org.opensearch.test.hamcrest.OpenSearchAssertions.hasProperty;
|
||||||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.hasType;
|
|
||||||
import static org.hamcrest.Matchers.both;
|
import static org.hamcrest.Matchers.both;
|
||||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
import static org.hamcrest.Matchers.emptyIterable;
|
import static org.hamcrest.Matchers.emptyIterable;
|
||||||
|
@ -117,7 +115,7 @@ public class BulkRequestWithGlobalParametersIT extends OpenSearchRestHighLevelCl
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGlobalIndex() throws IOException {
|
public void testGlobalIndex() throws IOException {
|
||||||
BulkRequest request = new BulkRequest("global_index", null);
|
BulkRequest request = new BulkRequest("global_index");
|
||||||
request.add(new IndexRequest().id("1").source(XContentType.JSON, "field", "bulk1"));
|
request.add(new IndexRequest().id("1").source(XContentType.JSON, "field", "bulk1"));
|
||||||
request.add(new IndexRequest().id("2").source(XContentType.JSON, "field", "bulk2"));
|
request.add(new IndexRequest().id("2").source(XContentType.JSON, "field", "bulk2"));
|
||||||
|
|
||||||
|
@ -129,7 +127,7 @@ public class BulkRequestWithGlobalParametersIT extends OpenSearchRestHighLevelCl
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void testIndexGlobalAndPerRequest() throws IOException {
|
public void testIndexGlobalAndPerRequest() throws IOException {
|
||||||
BulkRequest request = new BulkRequest("global_index", null);
|
BulkRequest request = new BulkRequest("global_index");
|
||||||
request.add(new IndexRequest("local_index").id("1").source(XContentType.JSON, "field", "bulk1"));
|
request.add(new IndexRequest("local_index").id("1").source(XContentType.JSON, "field", "bulk1"));
|
||||||
request.add(
|
request.add(
|
||||||
new IndexRequest().id("2") // will take global index
|
new IndexRequest().id("2") // will take global index
|
||||||
|
@ -142,31 +140,6 @@ public class BulkRequestWithGlobalParametersIT extends OpenSearchRestHighLevelCl
|
||||||
assertThat(hits, containsInAnyOrder(both(hasId("1")).and(hasIndex("local_index")), both(hasId("2")).and(hasIndex("global_index"))));
|
assertThat(hits, containsInAnyOrder(both(hasId("1")).and(hasIndex("local_index")), both(hasId("2")).and(hasIndex("global_index"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGlobalType() throws IOException {
|
|
||||||
BulkRequest request = new BulkRequest(null, "global_type");
|
|
||||||
request.add(new IndexRequest("index").id("1").source(XContentType.JSON, "field", "bulk1"));
|
|
||||||
request.add(new IndexRequest("index").id("2").source(XContentType.JSON, "field", "bulk2"));
|
|
||||||
|
|
||||||
bulkWithTypes(request);
|
|
||||||
|
|
||||||
Iterable<SearchHit> hits = searchAll("index");
|
|
||||||
assertThat(hits, everyItem(hasType("global_type")));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testTypeGlobalAndPerRequest() throws IOException {
|
|
||||||
BulkRequest request = new BulkRequest(null, "global_type");
|
|
||||||
request.add(new IndexRequest("index1", "local_type", "1").source(XContentType.JSON, "field", "bulk1"));
|
|
||||||
request.add(
|
|
||||||
new IndexRequest("index2").id("2") // will take global type
|
|
||||||
.source(XContentType.JSON, "field", "bulk2")
|
|
||||||
);
|
|
||||||
|
|
||||||
bulkWithTypes(request);
|
|
||||||
|
|
||||||
Iterable<SearchHit> hits = searchAll("index1", "index2");
|
|
||||||
assertThat(hits, containsInAnyOrder(both(hasId("1")).and(hasType("local_type")), both(hasId("2")).and(hasType("global_type"))));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testGlobalRouting() throws IOException {
|
public void testGlobalRouting() throws IOException {
|
||||||
createIndexWithMultipleShards("index");
|
createIndexWithMultipleShards("index");
|
||||||
BulkRequest request = new BulkRequest((String) null);
|
BulkRequest request = new BulkRequest((String) null);
|
||||||
|
@ -194,28 +167,6 @@ public class BulkRequestWithGlobalParametersIT extends OpenSearchRestHighLevelCl
|
||||||
assertThat(hits, containsInAnyOrder(hasId("1"), hasId("2")));
|
assertThat(hits, containsInAnyOrder(hasId("1"), hasId("2")));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGlobalIndexNoTypes() throws IOException {
|
|
||||||
BulkRequest request = new BulkRequest("global_index");
|
|
||||||
request.add(new IndexRequest().id("1").source(XContentType.JSON, "field", "bulk1"));
|
|
||||||
request.add(new IndexRequest().id("2").source(XContentType.JSON, "field", "bulk2"));
|
|
||||||
|
|
||||||
bulk(request);
|
|
||||||
|
|
||||||
Iterable<SearchHit> hits = searchAll("global_index");
|
|
||||||
assertThat(hits, everyItem(hasIndex("global_index")));
|
|
||||||
}
|
|
||||||
|
|
||||||
private BulkResponse bulkWithTypes(BulkRequest request) throws IOException {
|
|
||||||
BulkResponse bulkResponse = execute(
|
|
||||||
request,
|
|
||||||
highLevelClient()::bulk,
|
|
||||||
highLevelClient()::bulkAsync,
|
|
||||||
expectWarningsOnce(RestBulkAction.TYPES_DEPRECATION_MESSAGE)
|
|
||||||
);
|
|
||||||
assertFalse(bulkResponse.hasFailures());
|
|
||||||
return bulkResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
private BulkResponse bulk(BulkRequest request) throws IOException {
|
private BulkResponse bulk(BulkRequest request) throws IOException {
|
||||||
BulkResponse bulkResponse = execute(request, highLevelClient()::bulk, highLevelClient()::bulkAsync, RequestOptions.DEFAULT);
|
BulkResponse bulkResponse = execute(request, highLevelClient()::bulk, highLevelClient()::bulkAsync, RequestOptions.DEFAULT);
|
||||||
assertFalse(bulkResponse.hasFailures());
|
assertFalse(bulkResponse.hasFailures());
|
||||||
|
|
|
@ -69,7 +69,6 @@ import org.opensearch.common.xcontent.XContentType;
|
||||||
import org.opensearch.index.VersionType;
|
import org.opensearch.index.VersionType;
|
||||||
import org.opensearch.index.get.GetResult;
|
import org.opensearch.index.get.GetResult;
|
||||||
import org.opensearch.rest.RestStatus;
|
import org.opensearch.rest.RestStatus;
|
||||||
import org.opensearch.rest.action.document.RestBulkAction;
|
|
||||||
import org.opensearch.script.Script;
|
import org.opensearch.script.Script;
|
||||||
import org.opensearch.script.ScriptType;
|
import org.opensearch.script.ScriptType;
|
||||||
import org.opensearch.search.fetch.subphase.FetchSourceContext;
|
import org.opensearch.search.fetch.subphase.FetchSourceContext;
|
||||||
|
@ -441,10 +440,9 @@ 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", "type", "id1").source("{\"field\":\"value1\"}", XContentType.JSON));
|
bulk.add(new IndexRequest("index", "id1").source("{\"field\":\"value1\"}", XContentType.JSON));
|
||||||
bulk.add(new IndexRequest("index", "type", "id2").source("{\"field\":\"value2\"}", XContentType.JSON));
|
bulk.add(new IndexRequest("index", "id2").source("{\"field\":\"value2\"}", XContentType.JSON));
|
||||||
|
|
||||||
highLevelClient().bulk(bulk, expectWarningsOnce(RestBulkAction.TYPES_DEPRECATION_MESSAGE));
|
|
||||||
MultiGetRequest multiGetRequest = new MultiGetRequest();
|
MultiGetRequest multiGetRequest = new MultiGetRequest();
|
||||||
multiGetRequest.add("index", "id1");
|
multiGetRequest.add("index", "id1");
|
||||||
multiGetRequest.add("index", "id2");
|
multiGetRequest.add("index", "id2");
|
||||||
|
@ -1016,7 +1014,6 @@ public class CrudIT extends OpenSearchRestHighLevelClientTestCase {
|
||||||
|
|
||||||
assertEquals(i, bulkItemResponse.getItemId());
|
assertEquals(i, bulkItemResponse.getItemId());
|
||||||
assertEquals("index", bulkItemResponse.getIndex());
|
assertEquals("index", bulkItemResponse.getIndex());
|
||||||
assertEquals("_doc", bulkItemResponse.getType());
|
|
||||||
assertEquals(String.valueOf(i), bulkItemResponse.getId());
|
assertEquals(String.valueOf(i), bulkItemResponse.getId());
|
||||||
|
|
||||||
DocWriteRequest.OpType requestOpType = bulkRequest.requests().get(i).opType();
|
DocWriteRequest.OpType requestOpType = bulkRequest.requests().get(i).opType();
|
||||||
|
|
|
@ -25,15 +25,15 @@ setup:
|
||||||
bulk:
|
bulk:
|
||||||
refresh: true
|
refresh: true
|
||||||
body:
|
body:
|
||||||
- '{"index": {"_index": "test-0", "_type": "_doc"}}'
|
- '{"index": {"_index": "test-0"}}'
|
||||||
- '{"ip": "10.0.0.1", "integer": 38, "float": 12.5713, "name": "Ruth", "bool": true}'
|
- '{"ip": "10.0.0.1", "integer": 38, "float": 12.5713, "name": "Ruth", "bool": true}'
|
||||||
- '{"index": {"_index": "test-0", "_type": "_doc"}}'
|
- '{"index": {"_index": "test-0"}}'
|
||||||
- '{"ip": "10.0.0.2", "integer": 42, "float": 15.3393, "name": "Jackie", "surname": "Bowling", "bool": false}'
|
- '{"ip": "10.0.0.2", "integer": 42, "float": 15.3393, "name": "Jackie", "surname": "Bowling", "bool": false}'
|
||||||
- '{"index": {"_index": "test-1", "_type": "_doc"}}'
|
- '{"index": {"_index": "test-1"}}'
|
||||||
- '{"ip": "10.0.0.3", "integer": 29, "float": 19.0517, "name": "Stephanie", "bool": true}'
|
- '{"ip": "10.0.0.3", "integer": 29, "float": 19.0517, "name": "Stephanie", "bool": true}'
|
||||||
- '{"index": {"_index": "test-1", "_type": "_doc"}}'
|
- '{"index": {"_index": "test-1"}}'
|
||||||
- '{"ip": "10.0.0.4", "integer": 19, "float": 19.3717, "surname": "Hamilton", "bool": true}'
|
- '{"ip": "10.0.0.4", "integer": 19, "float": 19.3717, "surname": "Hamilton", "bool": true}'
|
||||||
- '{"index": {"_index": "test-2", "_type": "_doc"}}'
|
- '{"index": {"_index": "test-2"}}'
|
||||||
- '{"ip": "10.0.0.5", "integer": 0, "float": 17.3349, "name": "Natalie", "bool": false}'
|
- '{"ip": "10.0.0.5", "integer": 0, "float": 17.3349, "name": "Natalie", "bool": false}'
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
@ -315,7 +315,7 @@ public class AsyncBulkByScrollActionTests extends OpenSearchTestCase {
|
||||||
responses[i] = new BulkItemResponse(
|
responses[i] = new BulkItemResponse(
|
||||||
i,
|
i,
|
||||||
randomFrom(DocWriteRequest.OpType.values()),
|
randomFrom(DocWriteRequest.OpType.values()),
|
||||||
new Failure(shardId.getIndexName(), "type", "id" + i, new VersionConflictEngineException(shardId, "id", "test"))
|
new Failure(shardId.getIndexName(), "id" + i, new VersionConflictEngineException(shardId, "id", "test"))
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -433,7 +433,7 @@ public class AsyncBulkByScrollActionTests extends OpenSearchTestCase {
|
||||||
* Mimicks bulk indexing failures.
|
* Mimicks bulk indexing failures.
|
||||||
*/
|
*/
|
||||||
public void testBulkFailuresAbortRequest() throws Exception {
|
public void testBulkFailuresAbortRequest() throws Exception {
|
||||||
Failure failure = new Failure("index", "type", "id", new RuntimeException("test"));
|
Failure failure = new Failure("index", "id", new RuntimeException("test"));
|
||||||
DummyAsyncBulkByScrollAction action = new DummyAsyncBulkByScrollAction();
|
DummyAsyncBulkByScrollAction action = new DummyAsyncBulkByScrollAction();
|
||||||
BulkResponse bulkResponse = new BulkResponse(
|
BulkResponse bulkResponse = new BulkResponse(
|
||||||
new BulkItemResponse[] { new BulkItemResponse(0, DocWriteRequest.OpType.CREATE, failure) },
|
new BulkItemResponse[] { new BulkItemResponse(0, DocWriteRequest.OpType.CREATE, failure) },
|
||||||
|
@ -982,12 +982,7 @@ public class AsyncBulkByScrollActionTests extends OpenSearchTestCase {
|
||||||
responses[i] = new BulkItemResponse(
|
responses[i] = new BulkItemResponse(
|
||||||
i,
|
i,
|
||||||
item.opType(),
|
item.opType(),
|
||||||
new Failure(
|
new Failure(response.getIndex(), response.getId(), new OpenSearchRejectedExecutionException())
|
||||||
response.getIndex(),
|
|
||||||
response.getType(),
|
|
||||||
response.getId(),
|
|
||||||
new OpenSearchRejectedExecutionException()
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
responses[i] = new BulkItemResponse(i, item.opType(), response);
|
responses[i] = new BulkItemResponse(i, item.opType(), response);
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class BulkIndexByScrollResponseTests extends OpenSearchTestCase {
|
||||||
List<BulkItemResponse.Failure> bulkFailures = frequently()
|
List<BulkItemResponse.Failure> bulkFailures = frequently()
|
||||||
? emptyList()
|
? emptyList()
|
||||||
: IntStream.range(0, between(1, 3))
|
: IntStream.range(0, between(1, 3))
|
||||||
.mapToObj(j -> new BulkItemResponse.Failure("idx", "type", "id", new Exception()))
|
.mapToObj(j -> new BulkItemResponse.Failure("idx", "id", new Exception()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
allBulkFailures.addAll(bulkFailures);
|
allBulkFailures.addAll(bulkFailures);
|
||||||
List<SearchFailure> searchFailures = frequently()
|
List<SearchFailure> searchFailures = frequently()
|
||||||
|
|
|
@ -123,7 +123,6 @@
|
||||||
- match: {version_conflicts: 1}
|
- match: {version_conflicts: 1}
|
||||||
- match: {batches: 1}
|
- match: {batches: 1}
|
||||||
- match: {failures.0.index: test}
|
- match: {failures.0.index: test}
|
||||||
- match: {failures.0.type: _doc}
|
|
||||||
- match: {failures.0.id: "1"}
|
- match: {failures.0.id: "1"}
|
||||||
- match: {failures.0.status: 409}
|
- match: {failures.0.status: 409}
|
||||||
- match: {failures.0.cause.type: version_conflict_engine_exception}
|
- match: {failures.0.cause.type: version_conflict_engine_exception}
|
||||||
|
@ -176,7 +175,6 @@
|
||||||
- match: {version_conflicts: 1}
|
- match: {version_conflicts: 1}
|
||||||
- match: {batches: 1}
|
- match: {batches: 1}
|
||||||
- match: {failures.0.index: test}
|
- match: {failures.0.index: test}
|
||||||
- match: {failures.0.type: _doc}
|
|
||||||
- match: {failures.0.id: "1"}
|
- match: {failures.0.id: "1"}
|
||||||
- match: {failures.0.status: 409}
|
- match: {failures.0.status: 409}
|
||||||
- match: {failures.0.cause.type: version_conflict_engine_exception}
|
- match: {failures.0.cause.type: version_conflict_engine_exception}
|
||||||
|
|
|
@ -104,7 +104,6 @@
|
||||||
- match: {version_conflicts: 1}
|
- match: {version_conflicts: 1}
|
||||||
- match: {batches: 1}
|
- match: {batches: 1}
|
||||||
- match: {failures.0.index: test}
|
- match: {failures.0.index: test}
|
||||||
- match: {failures.0.type: _doc}
|
|
||||||
- match: {failures.0.id: "1"}
|
- match: {failures.0.id: "1"}
|
||||||
- match: {failures.0.status: 409}
|
- match: {failures.0.status: 409}
|
||||||
- match: {failures.0.cause.type: version_conflict_engine_exception}
|
- match: {failures.0.cause.type: version_conflict_engine_exception}
|
||||||
|
@ -144,7 +143,6 @@
|
||||||
- match: {version_conflicts: 1}
|
- match: {version_conflicts: 1}
|
||||||
- match: {batches: 1}
|
- match: {batches: 1}
|
||||||
- match: {failures.0.index: test}
|
- match: {failures.0.index: test}
|
||||||
- match: {failures.0.type: _doc}
|
|
||||||
- match: {failures.0.id: "1"}
|
- match: {failures.0.id: "1"}
|
||||||
- match: {failures.0.status: 409}
|
- match: {failures.0.status: 409}
|
||||||
- match: {failures.0.cause.type: version_conflict_engine_exception}
|
- match: {failures.0.cause.type: version_conflict_engine_exception}
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class Netty4HttpRequestSizeLimitIT extends OpenSearchNetty4IntegTestCase
|
||||||
|
|
||||||
List<Tuple<String, CharSequence>> requests = new ArrayList<>();
|
List<Tuple<String, CharSequence>> requests = new ArrayList<>();
|
||||||
for (int i = 0; i < 150; i++) {
|
for (int i = 0; i < 150; i++) {
|
||||||
requests.add(Tuple.tuple("/index/type/_bulk", bulkRequest));
|
requests.add(Tuple.tuple("/index/_bulk", bulkRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpServerTransport httpServerTransport = internalCluster().getInstance(HttpServerTransport.class);
|
HttpServerTransport httpServerTransport = internalCluster().getInstance(HttpServerTransport.class);
|
||||||
|
|
|
@ -45,17 +45,14 @@ setup:
|
||||||
body:
|
body:
|
||||||
- index:
|
- index:
|
||||||
_index: docs
|
_index: docs
|
||||||
_type: doc
|
|
||||||
_id: 1
|
_id: 1
|
||||||
- snapshot: one
|
- snapshot: one
|
||||||
- index:
|
- index:
|
||||||
_index: docs
|
_index: docs
|
||||||
_type: doc
|
|
||||||
_id: 2
|
_id: 2
|
||||||
- snapshot: one
|
- snapshot: one
|
||||||
- index:
|
- index:
|
||||||
_index: docs
|
_index: docs
|
||||||
_type: doc
|
|
||||||
_id: 3
|
_id: 3
|
||||||
- snapshot: one
|
- snapshot: one
|
||||||
|
|
||||||
|
@ -93,22 +90,18 @@ setup:
|
||||||
body:
|
body:
|
||||||
- index:
|
- index:
|
||||||
_index: docs
|
_index: docs
|
||||||
_type: doc
|
|
||||||
_id: 4
|
_id: 4
|
||||||
- snapshot: two
|
- snapshot: two
|
||||||
- index:
|
- index:
|
||||||
_index: docs
|
_index: docs
|
||||||
_type: doc
|
|
||||||
_id: 5
|
_id: 5
|
||||||
- snapshot: two
|
- snapshot: two
|
||||||
- index:
|
- index:
|
||||||
_index: docs
|
_index: docs
|
||||||
_type: doc
|
|
||||||
_id: 6
|
_id: 6
|
||||||
- snapshot: two
|
- snapshot: two
|
||||||
- index:
|
- index:
|
||||||
_index: docs
|
_index: docs
|
||||||
_type: doc
|
|
||||||
_id: 7
|
_id: 7
|
||||||
- snapshot: two
|
- snapshot: two
|
||||||
|
|
||||||
|
|
|
@ -48,17 +48,14 @@ setup:
|
||||||
body:
|
body:
|
||||||
- index:
|
- index:
|
||||||
_index: docs
|
_index: docs
|
||||||
_type: doc
|
|
||||||
_id: 1
|
_id: 1
|
||||||
- snapshot: one
|
- snapshot: one
|
||||||
- index:
|
- index:
|
||||||
_index: docs
|
_index: docs
|
||||||
_type: doc
|
|
||||||
_id: 2
|
_id: 2
|
||||||
- snapshot: one
|
- snapshot: one
|
||||||
- index:
|
- index:
|
||||||
_index: docs
|
_index: docs
|
||||||
_type: doc
|
|
||||||
_id: 3
|
_id: 3
|
||||||
- snapshot: one
|
- snapshot: one
|
||||||
|
|
||||||
|
@ -96,22 +93,18 @@ setup:
|
||||||
body:
|
body:
|
||||||
- index:
|
- index:
|
||||||
_index: docs
|
_index: docs
|
||||||
_type: doc
|
|
||||||
_id: 4
|
_id: 4
|
||||||
- snapshot: two
|
- snapshot: two
|
||||||
- index:
|
- index:
|
||||||
_index: docs
|
_index: docs
|
||||||
_type: doc
|
|
||||||
_id: 5
|
_id: 5
|
||||||
- snapshot: two
|
- snapshot: two
|
||||||
- index:
|
- index:
|
||||||
_index: docs
|
_index: docs
|
||||||
_type: doc
|
|
||||||
_id: 6
|
_id: 6
|
||||||
- snapshot: two
|
- snapshot: two
|
||||||
- index:
|
- index:
|
||||||
_index: docs
|
_index: docs
|
||||||
_type: doc
|
|
||||||
_id: 7
|
_id: 7
|
||||||
- snapshot: two
|
- snapshot: two
|
||||||
|
|
||||||
|
|
|
@ -131,17 +131,14 @@ setup:
|
||||||
body:
|
body:
|
||||||
- index:
|
- index:
|
||||||
_index: docs
|
_index: docs
|
||||||
_type: doc
|
|
||||||
_id: 1
|
_id: 1
|
||||||
- snapshot: one
|
- snapshot: one
|
||||||
- index:
|
- index:
|
||||||
_index: docs
|
_index: docs
|
||||||
_type: doc
|
|
||||||
_id: 2
|
_id: 2
|
||||||
- snapshot: one
|
- snapshot: one
|
||||||
- index:
|
- index:
|
||||||
_index: docs
|
_index: docs
|
||||||
_type: doc
|
|
||||||
_id: 3
|
_id: 3
|
||||||
- snapshot: one
|
- snapshot: one
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,6 @@ import org.opensearch.common.xcontent.json.JsonXContent;
|
||||||
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.action.document.RestBulkAction;
|
import org.opensearch.rest.action.document.RestBulkAction;
|
||||||
import org.opensearch.rest.action.document.RestUpdateAction;
|
|
||||||
import org.opensearch.rest.action.search.RestExplainAction;
|
import org.opensearch.rest.action.search.RestExplainAction;
|
||||||
import org.opensearch.test.NotEqualMessageBuilder;
|
import org.opensearch.test.NotEqualMessageBuilder;
|
||||||
import org.opensearch.test.XContentTestUtils;
|
import org.opensearch.test.XContentTestUtils;
|
||||||
|
@ -99,6 +98,8 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
private String index;
|
private String index;
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
|
public static final String TYPES_DEPRECATION_MESSAGE_BULK = "[types removal]" + " Specifying types in bulk requests is deprecated.";
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setIndex() {
|
public void setIndex() {
|
||||||
index = getTestName().toLowerCase(Locale.ROOT);
|
index = getTestName().toLowerCase(Locale.ROOT);
|
||||||
|
@ -490,15 +491,13 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
bulk.append("{\"index\":{}}\n");
|
bulk.append("{\"index\":{}}\n");
|
||||||
bulk.append("{\"test\":\"test\"}\n");
|
bulk.append("{\"test\":\"test\"}\n");
|
||||||
}
|
}
|
||||||
Request bulkRequest = new Request("POST", "/" + index + "_write/" + type + "/_bulk");
|
Request bulkRequest = new Request("POST", "/" + index + "_write/_bulk");
|
||||||
bulkRequest.setJsonEntity(bulk.toString());
|
bulkRequest.setJsonEntity(bulk.toString());
|
||||||
bulkRequest.addParameter("refresh", "");
|
bulkRequest.addParameter("refresh", "");
|
||||||
bulkRequest.setOptions(expectWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE));
|
|
||||||
assertThat(EntityUtils.toString(client().performRequest(bulkRequest).getEntity()), containsString("\"errors\":false"));
|
assertThat(EntityUtils.toString(client().performRequest(bulkRequest).getEntity()), containsString("\"errors\":false"));
|
||||||
|
|
||||||
if (isRunningAgainstOldCluster()) {
|
if (isRunningAgainstOldCluster()) {
|
||||||
Request rolloverRequest = new Request("POST", "/" + index + "_write/_rollover");
|
Request rolloverRequest = new Request("POST", "/" + index + "_write/_rollover");
|
||||||
rolloverRequest.setOptions(allowTypesRemovalWarnings());
|
|
||||||
rolloverRequest.setJsonEntity("{"
|
rolloverRequest.setJsonEntity("{"
|
||||||
+ " \"conditions\": {"
|
+ " \"conditions\": {"
|
||||||
+ " \"max_docs\": 5"
|
+ " \"max_docs\": 5"
|
||||||
|
@ -864,9 +863,6 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
}
|
}
|
||||||
templateBuilder.endObject();
|
templateBuilder.endObject();
|
||||||
templateBuilder.startObject("mappings"); {
|
templateBuilder.startObject("mappings"); {
|
||||||
if (isRunningAgainstAncientCluster()) {
|
|
||||||
templateBuilder.startObject(type);
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
templateBuilder.startObject("_source");
|
templateBuilder.startObject("_source");
|
||||||
{
|
{
|
||||||
|
@ -874,9 +870,6 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
}
|
}
|
||||||
templateBuilder.endObject();
|
templateBuilder.endObject();
|
||||||
}
|
}
|
||||||
if (isRunningAgainstAncientCluster()) {
|
|
||||||
templateBuilder.endObject();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
templateBuilder.endObject();
|
templateBuilder.endObject();
|
||||||
templateBuilder.startObject("aliases"); {
|
templateBuilder.startObject("aliases"); {
|
||||||
|
@ -895,7 +888,6 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
templateBuilder.endObject().endObject();
|
templateBuilder.endObject().endObject();
|
||||||
Request createTemplateRequest = new Request("PUT", "/_template/test_template");
|
Request createTemplateRequest = new Request("PUT", "/_template/test_template");
|
||||||
createTemplateRequest.setJsonEntity(Strings.toString(templateBuilder));
|
createTemplateRequest.setJsonEntity(Strings.toString(templateBuilder));
|
||||||
createTemplateRequest.setOptions(allowTypesRemovalWarnings());
|
|
||||||
|
|
||||||
client().performRequest(createTemplateRequest);
|
client().performRequest(createTemplateRequest);
|
||||||
|
|
||||||
|
@ -1144,10 +1136,9 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
bulk.append("{\"index\":{\"_id\":\"").append(count + i).append("\"}}\n");
|
bulk.append("{\"index\":{\"_id\":\"").append(count + i).append("\"}}\n");
|
||||||
bulk.append("{\"test\":\"test\"}\n");
|
bulk.append("{\"test\":\"test\"}\n");
|
||||||
}
|
}
|
||||||
Request writeToRestoredRequest = new Request("POST", "/restored_" + index + "/" + type + "/_bulk");
|
Request writeToRestoredRequest = new Request("POST", "/restored_" + index + "/_bulk");
|
||||||
writeToRestoredRequest.addParameter("refresh", "true");
|
writeToRestoredRequest.addParameter("refresh", "true");
|
||||||
writeToRestoredRequest.setJsonEntity(bulk.toString());
|
writeToRestoredRequest.setJsonEntity(bulk.toString());
|
||||||
writeToRestoredRequest.setOptions(expectWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE));
|
|
||||||
assertThat(EntityUtils.toString(client().performRequest(writeToRestoredRequest).getEntity()), containsString("\"errors\":false"));
|
assertThat(EntityUtils.toString(client().performRequest(writeToRestoredRequest).getEntity()), containsString("\"errors\":false"));
|
||||||
|
|
||||||
// And count to make sure the add worked
|
// And count to make sure the add worked
|
||||||
|
@ -1155,7 +1146,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
Request countAfterWriteRequest = new Request("GET", "/restored_" + index + "/_search");
|
Request countAfterWriteRequest = new Request("GET", "/restored_" + index + "/_search");
|
||||||
countAfterWriteRequest.addParameter("size", "0");
|
countAfterWriteRequest.addParameter("size", "0");
|
||||||
Map<String, Object> countAfterResponse = entityAsMap(client().performRequest(countRequest));
|
Map<String, Object> countAfterResponse = entityAsMap(client().performRequest(countRequest));
|
||||||
assertTotalHits(count+extras, countAfterResponse);
|
assertTotalHits(count + extras, countAfterResponse);
|
||||||
|
|
||||||
// Clean up the index for the next iteration
|
// Clean up the index for the next iteration
|
||||||
client().performRequest(new Request("DELETE", "/restored_*"));
|
client().performRequest(new Request("DELETE", "/restored_*"));
|
||||||
|
@ -1165,24 +1156,17 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
clusterSettingsRequest.addParameter("flat_settings", "true");
|
clusterSettingsRequest.addParameter("flat_settings", "true");
|
||||||
Map<String, Object> clusterSettingsResponse = entityAsMap(client().performRequest(clusterSettingsRequest));
|
Map<String, Object> clusterSettingsResponse = entityAsMap(client().performRequest(clusterSettingsRequest));
|
||||||
@SuppressWarnings("unchecked") final Map<String, Object> persistentSettings =
|
@SuppressWarnings("unchecked") final Map<String, Object> persistentSettings =
|
||||||
(Map<String, Object>)clusterSettingsResponse.get("persistent");
|
(Map<String, Object>) clusterSettingsResponse.get("persistent");
|
||||||
assertThat(persistentSettings.get("cluster.routing.allocation.exclude.test_attr"), equalTo(getOldClusterVersion().toString()));
|
assertThat(persistentSettings.get("cluster.routing.allocation.exclude.test_attr"), equalTo(getOldClusterVersion().toString()));
|
||||||
|
|
||||||
// Check that the template was restored successfully
|
// Check that the template was restored successfully
|
||||||
Request getTemplateRequest = new Request("GET", "/_template/test_template");
|
Request getTemplateRequest = new Request("GET", "/_template/test_template");
|
||||||
getTemplateRequest.setOptions(allowTypesRemovalWarnings());
|
|
||||||
|
|
||||||
Map<String, Object> getTemplateResponse = entityAsMap(client().performRequest(getTemplateRequest));
|
Map<String, Object> getTemplateResponse = entityAsMap(client().performRequest(getTemplateRequest));
|
||||||
Map<String, Object> expectedTemplate = new HashMap<>();
|
Map<String, Object> expectedTemplate = new HashMap<>();
|
||||||
expectedTemplate.put("index_patterns", singletonList("evil_*"));
|
expectedTemplate.put("index_patterns", singletonList("evil_*"));
|
||||||
expectedTemplate.put("settings", singletonMap("index", singletonMap("number_of_shards", "1")));
|
expectedTemplate.put("settings", singletonMap("index", singletonMap("number_of_shards", "1")));
|
||||||
// We don't have the type in the response starting with 7.0, but we won't have it on old cluster after upgrade
|
expectedTemplate.put("mappings", singletonMap("_source", singletonMap("enabled", true)));
|
||||||
// either so look at the response to figure out the correct assertions
|
|
||||||
if (isTypeInTemplateResponse(getTemplateResponse)) {
|
|
||||||
expectedTemplate.put("mappings", singletonMap(type, singletonMap("_source", singletonMap("enabled", true))));
|
|
||||||
} else {
|
|
||||||
expectedTemplate.put("mappings", singletonMap("_source", singletonMap("enabled", true)));
|
|
||||||
}
|
|
||||||
|
|
||||||
expectedTemplate.put("order", 0);
|
expectedTemplate.put("order", 0);
|
||||||
Map<String, Object> aliases = new HashMap<>();
|
Map<String, Object> aliases = new HashMap<>();
|
||||||
|
@ -1198,13 +1182,6 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private boolean isTypeInTemplateResponse(Map<String, Object> getTemplateResponse) {
|
|
||||||
return ( (Map<String, Object>) (
|
|
||||||
(Map<String, Object>) getTemplateResponse.getOrDefault("test_template", emptyMap())
|
|
||||||
).get("mappings")).get("_source") == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO tests for upgrades after shrink. We've had trouble with shrink in the past.
|
// TODO tests for upgrades after shrink. We've had trouble with shrink in the past.
|
||||||
|
|
||||||
private void indexRandomDocuments(
|
private void indexRandomDocuments(
|
||||||
|
@ -1217,9 +1194,6 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
logger.debug("Indexing document [{}]", i);
|
logger.debug("Indexing document [{}]", i);
|
||||||
Request createDocument = new Request("POST", "/" + index + "/" + type + "/" + i);
|
Request createDocument = new Request("POST", "/" + index + "/" + type + "/" + i);
|
||||||
if (isRunningAgainstAncientCluster() == false) {
|
|
||||||
createDocument.setOptions(expectWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE));
|
|
||||||
}
|
|
||||||
createDocument.setJsonEntity(Strings.toString(docSupplier.apply(i)));
|
createDocument.setJsonEntity(Strings.toString(docSupplier.apply(i)));
|
||||||
client().performRequest(createDocument);
|
client().performRequest(createDocument);
|
||||||
if (rarely()) {
|
if (rarely()) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ teardown:
|
||||||
bulk:
|
bulk:
|
||||||
refresh: true
|
refresh: true
|
||||||
body:
|
body:
|
||||||
- '{"index": {"_index": "single_doc_index", "_type": "test_type"}}'
|
- '{"index": {"_index": "single_doc_index"}}'
|
||||||
- '{"f1": "local_cluster", "sort_field": 0}'
|
- '{"f1": "local_cluster", "sort_field": 0}'
|
||||||
- do:
|
- do:
|
||||||
search:
|
search:
|
||||||
|
|
|
@ -205,12 +205,11 @@ public class IndexingIT extends AbstractRollingTestCase {
|
||||||
private void bulk(String index, String valueSuffix, int count) throws IOException {
|
private void bulk(String index, String valueSuffix, int count) throws IOException {
|
||||||
StringBuilder b = new StringBuilder();
|
StringBuilder b = new StringBuilder();
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
b.append("{\"index\": {\"_index\": \"").append(index).append("\", \"_type\": \"_doc\"}}\n");
|
b.append("{\"index\": {\"_index\": \"").append(index).append("\"}}\n");
|
||||||
b.append("{\"f1\": \"v").append(i).append(valueSuffix).append("\", \"f2\": ").append(i).append("}\n");
|
b.append("{\"f1\": \"v").append(i).append(valueSuffix).append("\", \"f2\": ").append(i).append("}\n");
|
||||||
}
|
}
|
||||||
Request bulk = new Request("POST", "/_bulk");
|
Request bulk = new Request("POST", "/_bulk");
|
||||||
bulk.addParameter("refresh", "true");
|
bulk.addParameter("refresh", "true");
|
||||||
bulk.setOptions(expectWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE));
|
|
||||||
bulk.setJsonEntity(b.toString());
|
bulk.setJsonEntity(b.toString());
|
||||||
client().performRequest(bulk);
|
client().performRequest(bulk);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,6 @@
|
||||||
"docs": [
|
"docs": [
|
||||||
{
|
{
|
||||||
"_index": "index",
|
"_index": "index",
|
||||||
"_type": "type",
|
|
||||||
"_id": "id",
|
"_id": "id",
|
||||||
"_source": {
|
"_source": {
|
||||||
"foo": "bar"
|
"foo": "bar"
|
||||||
|
|
|
@ -1,120 +0,0 @@
|
||||||
---
|
|
||||||
"Array of objects":
|
|
||||||
- do:
|
|
||||||
bulk:
|
|
||||||
refresh: true
|
|
||||||
body:
|
|
||||||
- index:
|
|
||||||
_index: test_index
|
|
||||||
_type: test_type
|
|
||||||
_id: test_id
|
|
||||||
- f1: v1
|
|
||||||
f2: 42
|
|
||||||
- index:
|
|
||||||
_index: test_index
|
|
||||||
_type: test_type
|
|
||||||
_id: test_id2
|
|
||||||
- f1: v2
|
|
||||||
f2: 47
|
|
||||||
|
|
||||||
- do:
|
|
||||||
count:
|
|
||||||
index: test_index
|
|
||||||
|
|
||||||
- match: {count: 2}
|
|
||||||
|
|
||||||
---
|
|
||||||
"Empty _id":
|
|
||||||
- do:
|
|
||||||
bulk:
|
|
||||||
refresh: true
|
|
||||||
body:
|
|
||||||
- index:
|
|
||||||
_index: test
|
|
||||||
_type: type
|
|
||||||
_id: ''
|
|
||||||
- f: 1
|
|
||||||
- index:
|
|
||||||
_index: test
|
|
||||||
_type: type
|
|
||||||
_id: id
|
|
||||||
- f: 2
|
|
||||||
- index:
|
|
||||||
_index: test
|
|
||||||
_type: type
|
|
||||||
- f: 3
|
|
||||||
- match: { errors: true }
|
|
||||||
- match: { items.0.index.status: 400 }
|
|
||||||
- match: { items.0.index.error.type: illegal_argument_exception }
|
|
||||||
- match: { items.0.index.error.reason: if _id is specified it must not be empty }
|
|
||||||
- match: { items.1.index.result: created }
|
|
||||||
- match: { items.2.index.result: created }
|
|
||||||
|
|
||||||
- do:
|
|
||||||
count:
|
|
||||||
index: test
|
|
||||||
|
|
||||||
- match: { count: 2 }
|
|
||||||
|
|
||||||
---
|
|
||||||
"Empty _id with op_type create":
|
|
||||||
- skip:
|
|
||||||
version: " - 7.4.99"
|
|
||||||
reason: "auto id + op type create only supported since 7.5"
|
|
||||||
|
|
||||||
- do:
|
|
||||||
bulk:
|
|
||||||
refresh: true
|
|
||||||
body:
|
|
||||||
- index:
|
|
||||||
_index: test
|
|
||||||
_type: type
|
|
||||||
_id: ''
|
|
||||||
- f: 1
|
|
||||||
- index:
|
|
||||||
_index: test
|
|
||||||
_type: type
|
|
||||||
_id: id
|
|
||||||
- f: 2
|
|
||||||
- index:
|
|
||||||
_index: test
|
|
||||||
_type: type
|
|
||||||
- f: 3
|
|
||||||
- create:
|
|
||||||
_index: test
|
|
||||||
_type: type
|
|
||||||
- f: 4
|
|
||||||
- index:
|
|
||||||
_index: test
|
|
||||||
_type: type
|
|
||||||
op_type: create
|
|
||||||
- f: 5
|
|
||||||
- match: { errors: true }
|
|
||||||
- match: { items.0.index.status: 400 }
|
|
||||||
- match: { items.0.index.error.type: illegal_argument_exception }
|
|
||||||
- match: { items.0.index.error.reason: if _id is specified it must not be empty }
|
|
||||||
- match: { items.1.index.result: created }
|
|
||||||
- match: { items.2.index.result: created }
|
|
||||||
- match: { items.3.create.result: created }
|
|
||||||
- match: { items.4.create.result: created }
|
|
||||||
|
|
||||||
- do:
|
|
||||||
count:
|
|
||||||
index: test
|
|
||||||
|
|
||||||
- match: { count: 4 }
|
|
||||||
|
|
||||||
---
|
|
||||||
"empty action":
|
|
||||||
- skip:
|
|
||||||
features: headers
|
|
||||||
|
|
||||||
- do:
|
|
||||||
catch: /Malformed action\/metadata line \[3\], expected FIELD_NAME but found \[END_OBJECT\]/
|
|
||||||
headers:
|
|
||||||
Content-Type: application/json
|
|
||||||
bulk:
|
|
||||||
body: |
|
|
||||||
{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}}
|
|
||||||
{"f1": "v1", "f2": 42}
|
|
||||||
{}
|
|
|
@ -1,17 +0,0 @@
|
||||||
---
|
|
||||||
"List of strings":
|
|
||||||
- do:
|
|
||||||
bulk:
|
|
||||||
refresh: true
|
|
||||||
body:
|
|
||||||
- '{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}}'
|
|
||||||
- '{"f1": "v1", "f2": 42}'
|
|
||||||
- '{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id2"}}'
|
|
||||||
- '{"f1": "v2", "f2": 47}'
|
|
||||||
|
|
||||||
- do:
|
|
||||||
count:
|
|
||||||
index: test_index
|
|
||||||
|
|
||||||
- match: {count: 2}
|
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
---
|
|
||||||
"One big string":
|
|
||||||
- do:
|
|
||||||
bulk:
|
|
||||||
refresh: true
|
|
||||||
body: |
|
|
||||||
{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}}
|
|
||||||
{"f1": "v1", "f2": 42}
|
|
||||||
{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id2"}}
|
|
||||||
{"f1": "v2", "f2": 47}
|
|
||||||
|
|
||||||
- do:
|
|
||||||
count:
|
|
||||||
index: test_index
|
|
||||||
|
|
||||||
- match: {count: 2}
|
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
---
|
|
||||||
"refresh=true immediately makes changes are visible in search":
|
|
||||||
- do:
|
|
||||||
bulk:
|
|
||||||
refresh: true
|
|
||||||
body: |
|
|
||||||
{"index": {"_index": "bulk_50_refresh_1", "_type": "test_type", "_id": "bulk_50_refresh_id1"}}
|
|
||||||
{"f1": "v1", "f2": 42}
|
|
||||||
{"index": {"_index": "bulk_50_refresh_1", "_type": "test_type", "_id": "bulk_50_refresh_id2"}}
|
|
||||||
{"f1": "v2", "f2": 47}
|
|
||||||
|
|
||||||
- do:
|
|
||||||
count:
|
|
||||||
index: bulk_50_refresh_1
|
|
||||||
- match: {count: 2}
|
|
||||||
|
|
||||||
---
|
|
||||||
"refresh=empty string immediately makes changes are visible in search":
|
|
||||||
- do:
|
|
||||||
bulk:
|
|
||||||
refresh: ""
|
|
||||||
body: |
|
|
||||||
{"index": {"_index": "bulk_50_refresh_2", "_type": "test_type", "_id": "bulk_50_refresh_id3"}}
|
|
||||||
{"f1": "v1", "f2": 42}
|
|
||||||
{"index": {"_index": "bulk_50_refresh_2", "_type": "test_type", "_id": "bulk_50_refresh_id4"}}
|
|
||||||
{"f1": "v2", "f2": 47}
|
|
||||||
|
|
||||||
- do:
|
|
||||||
count:
|
|
||||||
index: bulk_50_refresh_2
|
|
||||||
- match: {count: 2}
|
|
||||||
|
|
||||||
|
|
||||||
---
|
|
||||||
"refresh=wait_for waits until changes are visible in search":
|
|
||||||
- do:
|
|
||||||
bulk:
|
|
||||||
refresh: wait_for
|
|
||||||
body: |
|
|
||||||
{"index": {"_index": "bulk_50_refresh_3", "_type": "test_type", "_id": "bulk_50_refresh_id5"}}
|
|
||||||
{"f1": "v1", "f2": 42}
|
|
||||||
{"index": {"_index": "bulk_50_refresh_3", "_type": "test_type", "_id": "bulk_50_refresh_id6"}}
|
|
||||||
{"f1": "v2", "f2": 47}
|
|
||||||
|
|
||||||
- do:
|
|
||||||
count:
|
|
||||||
index: bulk_50_refresh_3
|
|
||||||
- match: {count: 2}
|
|
|
@ -8,11 +8,11 @@
|
||||||
bulk:
|
bulk:
|
||||||
refresh: true
|
refresh: true
|
||||||
body: |
|
body: |
|
||||||
{"index": {"_index": "test_1", "_type": "_doc", "_id": 1}}
|
{"index": {"_index": "test_1", "_id": 1}}
|
||||||
{ "foo": "bar" }
|
{ "foo": "bar" }
|
||||||
{"index": {"_index": "test_2", "_type": "_doc", "_id": 2}}
|
{"index": {"_index": "test_2", "_id": 2}}
|
||||||
{ "foo": "bar" }
|
{ "foo": "bar" }
|
||||||
{"index": {"_index": "test_3", "_type": "_doc", "_id": 3}}
|
{"index": {"_index": "test_3", "_id": 3}}
|
||||||
{ "foo": "bar" }
|
{ "foo": "bar" }
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
---
|
|
||||||
"Terms Query with No.of terms exceeding index.max_terms_count should FAIL":
|
|
||||||
- skip:
|
|
||||||
features: allowed_warnings
|
|
||||||
- do:
|
|
||||||
indices.create:
|
|
||||||
include_type_name: true
|
|
||||||
index: test_index
|
|
||||||
body:
|
|
||||||
settings:
|
|
||||||
number_of_shards: 1
|
|
||||||
index.max_terms_count: 2
|
|
||||||
mappings:
|
|
||||||
test_type:
|
|
||||||
properties:
|
|
||||||
user:
|
|
||||||
type: keyword
|
|
||||||
followers:
|
|
||||||
type: keyword
|
|
||||||
- do:
|
|
||||||
bulk:
|
|
||||||
refresh: true
|
|
||||||
body:
|
|
||||||
- '{"index": {"_index": "test_index", "_type": "test_type", "_id": "u1"}}'
|
|
||||||
- '{"user": "u1", "followers": ["u2", "u3"]}'
|
|
||||||
- '{"index": {"_index": "test_index", "_type": "test_type", "_id": "u2"}}'
|
|
||||||
- '{"user": "u2", "followers": ["u1", "u3", "u4"]}'
|
|
||||||
- '{"index": {"_index": "test_index", "_type": "test_type", "_id": "u3"}}'
|
|
||||||
- '{"user": "u3", "followers": ["u1"]}'
|
|
||||||
- '{"index": {"_index": "test_index", "_type": "test_type", "_id": "u4"}}'
|
|
||||||
- '{"user": "u4", "followers": ["u3"]}'
|
|
||||||
|
|
||||||
- do:
|
|
||||||
search:
|
|
||||||
rest_total_hits_as_int: true
|
|
||||||
index: test_index
|
|
||||||
body: {"query" : {"terms" : {"user" : ["u1", "u2"]}}}
|
|
||||||
- match: { hits.total: 2 }
|
|
||||||
|
|
||||||
- do:
|
|
||||||
catch: bad_request
|
|
||||||
search:
|
|
||||||
rest_total_hits_as_int: true
|
|
||||||
index: test_index
|
|
||||||
body: {"query" : {"terms" : {"user" : ["u1", "u2", "u3"]}}}
|
|
||||||
|
|
||||||
- do:
|
|
||||||
allowed_warnings:
|
|
||||||
- "Deprecated field [type] used, this field is unused and will be removed entirely"
|
|
||||||
search:
|
|
||||||
rest_total_hits_as_int: true
|
|
||||||
index: test_index
|
|
||||||
body: {"query" : {"terms" : {"user" : {"index" : "test_index", "type" : "test_type", "id" : "u1", "path" : "followers"}}}}
|
|
||||||
- match: { hits.total: 2 }
|
|
||||||
|
|
||||||
- do:
|
|
||||||
catch: bad_request
|
|
||||||
search:
|
|
||||||
rest_total_hits_as_int: true
|
|
||||||
index: test_index
|
|
||||||
body: {"query" : {"terms" : {"user" : {"index" : "test_index", "type" : "test_type", "id" : "u2", "path" : "followers"}}}}
|
|
|
@ -88,7 +88,6 @@ public class BulkIntegrationIT extends OpenSearchIntegTestCase {
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
GetMappingsResponse mappingsResponse = client().admin().indices().prepareGetMappings().get();
|
GetMappingsResponse mappingsResponse = client().admin().indices().prepareGetMappings().get();
|
||||||
assertTrue(mappingsResponse.getMappings().containsKey("logstash-2014.03.30"));
|
assertTrue(mappingsResponse.getMappings().containsKey("logstash-2014.03.30"));
|
||||||
assertTrue(mappingsResponse.getMappings().get("logstash-2014.03.30").containsKey("logs"));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +162,7 @@ public class BulkIntegrationIT extends OpenSearchIntegTestCase {
|
||||||
|
|
||||||
{
|
{
|
||||||
createSamplePipeline("pipeline");
|
createSamplePipeline("pipeline");
|
||||||
BulkRequestBuilder bulkBuilder = client().prepareBulk("test", "type1").routing("routing").pipeline("pipeline");
|
BulkRequestBuilder bulkBuilder = client().prepareBulk("test").routing("routing").pipeline("pipeline");
|
||||||
|
|
||||||
bulkBuilder.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON);
|
bulkBuilder.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON);
|
||||||
BulkResponse bulkItemResponses = bulkBuilder.get();
|
BulkResponse bulkItemResponses = bulkBuilder.get();
|
||||||
|
|
|
@ -40,14 +40,10 @@ import org.opensearch.action.index.IndexRequest;
|
||||||
import org.opensearch.client.Client;
|
import org.opensearch.client.Client;
|
||||||
import org.opensearch.client.Requests;
|
import org.opensearch.client.Requests;
|
||||||
import org.opensearch.cluster.metadata.IndexMetadata;
|
import org.opensearch.cluster.metadata.IndexMetadata;
|
||||||
import org.opensearch.common.Strings;
|
|
||||||
import org.opensearch.common.bytes.BytesArray;
|
|
||||||
import org.opensearch.common.settings.Settings;
|
import org.opensearch.common.settings.Settings;
|
||||||
import org.opensearch.common.unit.ByteSizeUnit;
|
import org.opensearch.common.unit.ByteSizeUnit;
|
||||||
import org.opensearch.common.unit.ByteSizeValue;
|
import org.opensearch.common.unit.ByteSizeValue;
|
||||||
import org.opensearch.common.unit.TimeValue;
|
import org.opensearch.common.unit.TimeValue;
|
||||||
import org.opensearch.common.xcontent.XContentType;
|
|
||||||
import org.opensearch.common.xcontent.json.JsonXContent;
|
|
||||||
import org.opensearch.test.OpenSearchIntegTestCase;
|
import org.opensearch.test.OpenSearchIntegTestCase;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -173,7 +169,6 @@ public class BulkProcessorIT extends OpenSearchIntegTestCase {
|
||||||
for (BulkItemResponse bulkItemResponse : listener.bulkItems) {
|
for (BulkItemResponse bulkItemResponse : listener.bulkItems) {
|
||||||
assertThat(bulkItemResponse.getFailureMessage(), bulkItemResponse.isFailed(), equalTo(false));
|
assertThat(bulkItemResponse.getFailureMessage(), bulkItemResponse.isFailed(), equalTo(false));
|
||||||
assertThat(bulkItemResponse.getIndex(), equalTo("test"));
|
assertThat(bulkItemResponse.getIndex(), equalTo("test"));
|
||||||
assertThat(bulkItemResponse.getType(), equalTo("test"));
|
|
||||||
// with concurrent requests > 1 we can't rely on the order of the bulk requests
|
// with concurrent requests > 1 we can't rely on the order of the bulk requests
|
||||||
assertThat(Integer.valueOf(bulkItemResponse.getId()), both(greaterThan(0)).and(lessThanOrEqualTo(numDocs)));
|
assertThat(Integer.valueOf(bulkItemResponse.getId()), both(greaterThan(0)).and(lessThanOrEqualTo(numDocs)));
|
||||||
// we do want to check that we don't get duplicate ids back
|
// we do want to check that we don't get duplicate ids back
|
||||||
|
@ -280,7 +275,6 @@ public class BulkProcessorIT extends OpenSearchIntegTestCase {
|
||||||
Set<String> readOnlyIds = new HashSet<>();
|
Set<String> readOnlyIds = new HashSet<>();
|
||||||
for (BulkItemResponse bulkItemResponse : listener.bulkItems) {
|
for (BulkItemResponse bulkItemResponse : listener.bulkItems) {
|
||||||
assertThat(bulkItemResponse.getIndex(), either(equalTo("test")).or(equalTo("test-ro")));
|
assertThat(bulkItemResponse.getIndex(), either(equalTo("test")).or(equalTo("test-ro")));
|
||||||
assertThat(bulkItemResponse.getType(), equalTo("test"));
|
|
||||||
if (bulkItemResponse.getIndex().equals("test")) {
|
if (bulkItemResponse.getIndex().equals("test")) {
|
||||||
assertThat(bulkItemResponse.isFailed(), equalTo(false));
|
assertThat(bulkItemResponse.isFailed(), equalTo(false));
|
||||||
// with concurrent requests > 1 we can't rely on the order of the bulk requests
|
// with concurrent requests > 1 we can't rely on the order of the bulk requests
|
||||||
|
@ -302,24 +296,13 @@ public class BulkProcessorIT extends OpenSearchIntegTestCase {
|
||||||
private static MultiGetRequestBuilder indexDocs(Client client, BulkProcessor processor, int numDocs) throws Exception {
|
private static MultiGetRequestBuilder indexDocs(Client client, BulkProcessor processor, int numDocs) throws Exception {
|
||||||
MultiGetRequestBuilder multiGetRequestBuilder = client.prepareMultiGet();
|
MultiGetRequestBuilder multiGetRequestBuilder = client.prepareMultiGet();
|
||||||
for (int i = 1; i <= numDocs; i++) {
|
for (int i = 1; i <= numDocs; i++) {
|
||||||
if (randomBoolean()) {
|
processor.add(
|
||||||
processor.add(
|
new IndexRequest("test", "test", Integer.toString(i)).source(
|
||||||
new IndexRequest("test", "test", Integer.toString(i)).source(
|
Requests.INDEX_CONTENT_TYPE,
|
||||||
Requests.INDEX_CONTENT_TYPE,
|
"field",
|
||||||
"field",
|
randomRealisticUnicodeOfLengthBetween(1, 30)
|
||||||
randomRealisticUnicodeOfLengthBetween(1, 30)
|
)
|
||||||
)
|
);
|
||||||
);
|
|
||||||
} else {
|
|
||||||
final String source = "{ \"index\":{\"_index\":\"test\",\"_type\":\"test\",\"_id\":\""
|
|
||||||
+ Integer.toString(i)
|
|
||||||
+ "\"} }\n"
|
|
||||||
+ Strings.toString(
|
|
||||||
JsonXContent.contentBuilder().startObject().field("field", randomRealisticUnicodeOfLengthBetween(1, 30)).endObject()
|
|
||||||
)
|
|
||||||
+ "\n";
|
|
||||||
processor.add(new BytesArray(source), null, null, XContentType.JSON);
|
|
||||||
}
|
|
||||||
multiGetRequestBuilder.add("test", Integer.toString(i));
|
multiGetRequestBuilder.add("test", Integer.toString(i));
|
||||||
}
|
}
|
||||||
return multiGetRequestBuilder;
|
return multiGetRequestBuilder;
|
||||||
|
@ -330,7 +313,6 @@ public class BulkProcessorIT extends OpenSearchIntegTestCase {
|
||||||
int i = 1;
|
int i = 1;
|
||||||
for (BulkItemResponse bulkItemResponse : bulkItemResponses) {
|
for (BulkItemResponse bulkItemResponse : bulkItemResponses) {
|
||||||
assertThat(bulkItemResponse.getIndex(), equalTo("test"));
|
assertThat(bulkItemResponse.getIndex(), equalTo("test"));
|
||||||
assertThat(bulkItemResponse.getType(), equalTo("test"));
|
|
||||||
assertThat(bulkItemResponse.getId(), equalTo(Integer.toString(i++)));
|
assertThat(bulkItemResponse.getId(), equalTo(Integer.toString(i++)));
|
||||||
assertThat(
|
assertThat(
|
||||||
"item " + i + " failed with cause: " + bulkItemResponse.getFailureMessage(),
|
"item " + i + " failed with cause: " + bulkItemResponse.getFailureMessage(),
|
||||||
|
|
|
@ -228,37 +228,31 @@ public class DocumentActionsIT extends OpenSearchIntegTestCase {
|
||||||
assertThat(bulkResponse.getItems()[0].isFailed(), equalTo(false));
|
assertThat(bulkResponse.getItems()[0].isFailed(), equalTo(false));
|
||||||
assertThat(bulkResponse.getItems()[0].getOpType(), equalTo(OpType.INDEX));
|
assertThat(bulkResponse.getItems()[0].getOpType(), equalTo(OpType.INDEX));
|
||||||
assertThat(bulkResponse.getItems()[0].getIndex(), equalTo(getConcreteIndexName()));
|
assertThat(bulkResponse.getItems()[0].getIndex(), equalTo(getConcreteIndexName()));
|
||||||
assertThat(bulkResponse.getItems()[0].getType(), equalTo("type1"));
|
|
||||||
assertThat(bulkResponse.getItems()[0].getId(), equalTo("1"));
|
assertThat(bulkResponse.getItems()[0].getId(), equalTo("1"));
|
||||||
|
|
||||||
assertThat(bulkResponse.getItems()[1].isFailed(), equalTo(false));
|
assertThat(bulkResponse.getItems()[1].isFailed(), equalTo(false));
|
||||||
assertThat(bulkResponse.getItems()[1].getOpType(), equalTo(OpType.CREATE));
|
assertThat(bulkResponse.getItems()[1].getOpType(), equalTo(OpType.CREATE));
|
||||||
assertThat(bulkResponse.getItems()[1].getIndex(), equalTo(getConcreteIndexName()));
|
assertThat(bulkResponse.getItems()[1].getIndex(), equalTo(getConcreteIndexName()));
|
||||||
assertThat(bulkResponse.getItems()[1].getType(), equalTo("type1"));
|
|
||||||
assertThat(bulkResponse.getItems()[1].getId(), equalTo("2"));
|
assertThat(bulkResponse.getItems()[1].getId(), equalTo("2"));
|
||||||
|
|
||||||
assertThat(bulkResponse.getItems()[2].isFailed(), equalTo(false));
|
assertThat(bulkResponse.getItems()[2].isFailed(), equalTo(false));
|
||||||
assertThat(bulkResponse.getItems()[2].getOpType(), equalTo(OpType.INDEX));
|
assertThat(bulkResponse.getItems()[2].getOpType(), equalTo(OpType.INDEX));
|
||||||
assertThat(bulkResponse.getItems()[2].getIndex(), equalTo(getConcreteIndexName()));
|
assertThat(bulkResponse.getItems()[2].getIndex(), equalTo(getConcreteIndexName()));
|
||||||
assertThat(bulkResponse.getItems()[2].getType(), equalTo("type1"));
|
|
||||||
String generatedId3 = bulkResponse.getItems()[2].getId();
|
String generatedId3 = bulkResponse.getItems()[2].getId();
|
||||||
|
|
||||||
assertThat(bulkResponse.getItems()[3].isFailed(), equalTo(false));
|
assertThat(bulkResponse.getItems()[3].isFailed(), equalTo(false));
|
||||||
assertThat(bulkResponse.getItems()[3].getOpType(), equalTo(OpType.CREATE));
|
assertThat(bulkResponse.getItems()[3].getOpType(), equalTo(OpType.CREATE));
|
||||||
assertThat(bulkResponse.getItems()[3].getIndex(), equalTo(getConcreteIndexName()));
|
assertThat(bulkResponse.getItems()[3].getIndex(), equalTo(getConcreteIndexName()));
|
||||||
assertThat(bulkResponse.getItems()[3].getType(), equalTo("type1"));
|
|
||||||
String generatedId4 = bulkResponse.getItems()[3].getId();
|
String generatedId4 = bulkResponse.getItems()[3].getId();
|
||||||
|
|
||||||
assertThat(bulkResponse.getItems()[4].isFailed(), equalTo(false));
|
assertThat(bulkResponse.getItems()[4].isFailed(), equalTo(false));
|
||||||
assertThat(bulkResponse.getItems()[4].getOpType(), equalTo(OpType.DELETE));
|
assertThat(bulkResponse.getItems()[4].getOpType(), equalTo(OpType.DELETE));
|
||||||
assertThat(bulkResponse.getItems()[4].getIndex(), equalTo(getConcreteIndexName()));
|
assertThat(bulkResponse.getItems()[4].getIndex(), equalTo(getConcreteIndexName()));
|
||||||
assertThat(bulkResponse.getItems()[4].getType(), equalTo("type1"));
|
|
||||||
assertThat(bulkResponse.getItems()[4].getId(), equalTo("1"));
|
assertThat(bulkResponse.getItems()[4].getId(), equalTo("1"));
|
||||||
|
|
||||||
assertThat(bulkResponse.getItems()[5].isFailed(), equalTo(true));
|
assertThat(bulkResponse.getItems()[5].isFailed(), equalTo(true));
|
||||||
assertThat(bulkResponse.getItems()[5].getOpType(), equalTo(OpType.INDEX));
|
assertThat(bulkResponse.getItems()[5].getOpType(), equalTo(OpType.INDEX));
|
||||||
assertThat(bulkResponse.getItems()[5].getIndex(), equalTo(getConcreteIndexName()));
|
assertThat(bulkResponse.getItems()[5].getIndex(), equalTo(getConcreteIndexName()));
|
||||||
assertThat(bulkResponse.getItems()[5].getType(), equalTo("type1"));
|
|
||||||
|
|
||||||
waitForRelocation(ClusterHealthStatus.GREEN);
|
waitForRelocation(ClusterHealthStatus.GREEN);
|
||||||
RefreshResponse refreshResponse = client().admin().indices().prepareRefresh("test").execute().actionGet();
|
RefreshResponse refreshResponse = client().admin().indices().prepareRefresh("test").execute().actionGet();
|
||||||
|
|
|
@ -843,7 +843,6 @@ public class SimpleIndexTemplateIT extends OpenSearchIntegTestCase {
|
||||||
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"));
|
||||||
assertThat(response.getItems()[0].getType(), equalTo("test"));
|
|
||||||
assertThat(response.getItems()[0].getId(), equalTo("test"));
|
assertThat(response.getItems()[0].getId(), equalTo("test"));
|
||||||
assertThat(response.getItems()[0].getVersion(), equalTo(1L));
|
assertThat(response.getItems()[0].getVersion(), equalTo(1L));
|
||||||
|
|
||||||
|
|
|
@ -413,7 +413,7 @@ public class GeoFilterIT extends OpenSearchIntegTestCase {
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
client().admin().indices().prepareCreate("countries").setSettings(settings).addMapping("country", xContentBuilder).get();
|
client().admin().indices().prepareCreate("countries").setSettings(settings).addMapping("country", xContentBuilder).get();
|
||||||
BulkResponse bulk = client().prepareBulk().add(bulkAction, 0, bulkAction.length, null, null, xContentBuilder.contentType()).get();
|
BulkResponse bulk = client().prepareBulk().add(bulkAction, 0, bulkAction.length, null, xContentBuilder.contentType()).get();
|
||||||
|
|
||||||
for (BulkItemResponse item : bulk.getItems()) {
|
for (BulkItemResponse item : bulk.getItems()) {
|
||||||
assertFalse("unable to index data", item.isFailed());
|
assertFalse("unable to index data", item.isFailed());
|
||||||
|
|
|
@ -83,14 +83,6 @@ public interface DocWriteRequest<T> extends IndicesRequest, Accountable {
|
||||||
*/
|
*/
|
||||||
String type();
|
String type();
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the default type supplied to a bulk
|
|
||||||
* request if this individual request's type is null
|
|
||||||
* or empty
|
|
||||||
* @return the Request
|
|
||||||
*/
|
|
||||||
T defaultTypeIfNull(String defaultType);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the id of the document for this request
|
* Get the id of the document for this request
|
||||||
* @return the id
|
* @return the id
|
||||||
|
|
|
@ -105,13 +105,7 @@ public class BulkItemRequest implements Writeable, Accountable {
|
||||||
*/
|
*/
|
||||||
public void abort(String index, Exception cause) {
|
public void abort(String index, Exception cause) {
|
||||||
if (primaryResponse == null) {
|
if (primaryResponse == null) {
|
||||||
final BulkItemResponse.Failure failure = new BulkItemResponse.Failure(
|
final BulkItemResponse.Failure failure = new BulkItemResponse.Failure(index, request.id(), Objects.requireNonNull(cause), true);
|
||||||
index,
|
|
||||||
request.type(),
|
|
||||||
request.id(),
|
|
||||||
Objects.requireNonNull(cause),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
setPrimaryResponse(new BulkItemResponse(id, request.opType(), failure));
|
setPrimaryResponse(new BulkItemResponse(id, request.opType(), failure));
|
||||||
} else {
|
} else {
|
||||||
assert primaryResponse.isFailed() && primaryResponse.getFailure().isAborted() : "response ["
|
assert primaryResponse.isFailed() && primaryResponse.getFailure().isAborted() : "response ["
|
||||||
|
|
|
@ -35,6 +35,7 @@ package org.opensearch.action.bulk;
|
||||||
import org.opensearch.ExceptionsHelper;
|
import org.opensearch.ExceptionsHelper;
|
||||||
import org.opensearch.LegacyESVersion;
|
import org.opensearch.LegacyESVersion;
|
||||||
import org.opensearch.OpenSearchException;
|
import org.opensearch.OpenSearchException;
|
||||||
|
import org.opensearch.Version;
|
||||||
import org.opensearch.action.DocWriteRequest.OpType;
|
import org.opensearch.action.DocWriteRequest.OpType;
|
||||||
import org.opensearch.action.DocWriteResponse;
|
import org.opensearch.action.DocWriteResponse;
|
||||||
import org.opensearch.action.delete.DeleteResponse;
|
import org.opensearch.action.delete.DeleteResponse;
|
||||||
|
@ -51,6 +52,7 @@ import org.opensearch.common.xcontent.StatusToXContentObject;
|
||||||
import org.opensearch.common.xcontent.ToXContentFragment;
|
import org.opensearch.common.xcontent.ToXContentFragment;
|
||||||
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.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;
|
||||||
|
@ -69,7 +71,6 @@ import static org.opensearch.common.xcontent.XContentParserUtils.throwUnknownFie
|
||||||
public class BulkItemResponse implements Writeable, StatusToXContentObject {
|
public class BulkItemResponse implements Writeable, StatusToXContentObject {
|
||||||
|
|
||||||
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 STATUS = "status";
|
private static final String STATUS = "status";
|
||||||
private static final String ERROR = "error";
|
private static final String ERROR = "error";
|
||||||
|
@ -88,7 +89,6 @@ public class BulkItemResponse implements Writeable, StatusToXContentObject {
|
||||||
builder.field(STATUS, response.status().getStatus());
|
builder.field(STATUS, response.status().getStatus());
|
||||||
} else {
|
} else {
|
||||||
builder.field(_INDEX, failure.getIndex());
|
builder.field(_INDEX, failure.getIndex());
|
||||||
builder.field(_TYPE, failure.getType());
|
|
||||||
builder.field(_ID, failure.getId());
|
builder.field(_ID, failure.getId());
|
||||||
builder.field(STATUS, failure.getStatus().getStatus());
|
builder.field(STATUS, failure.getStatus().getStatus());
|
||||||
builder.startObject(ERROR);
|
builder.startObject(ERROR);
|
||||||
|
@ -166,7 +166,7 @@ public class BulkItemResponse implements Writeable, StatusToXContentObject {
|
||||||
|
|
||||||
BulkItemResponse bulkItemResponse;
|
BulkItemResponse bulkItemResponse;
|
||||||
if (exception != null) {
|
if (exception != null) {
|
||||||
Failure failure = new Failure(builder.getShardId().getIndexName(), builder.getType(), builder.getId(), exception, status);
|
Failure failure = new Failure(builder.getShardId().getIndexName(), builder.getId(), exception, status);
|
||||||
bulkItemResponse = new BulkItemResponse(id, opType, failure);
|
bulkItemResponse = new BulkItemResponse(id, opType, failure);
|
||||||
} else {
|
} else {
|
||||||
bulkItemResponse = new BulkItemResponse(id, opType, builder.build());
|
bulkItemResponse = new BulkItemResponse(id, opType, builder.build());
|
||||||
|
@ -179,13 +179,11 @@ public class BulkItemResponse implements Writeable, StatusToXContentObject {
|
||||||
*/
|
*/
|
||||||
public static class Failure implements Writeable, ToXContentFragment {
|
public static class Failure implements Writeable, ToXContentFragment {
|
||||||
public static final String INDEX_FIELD = "index";
|
public static final String INDEX_FIELD = "index";
|
||||||
public static final String TYPE_FIELD = "type";
|
|
||||||
public static final String ID_FIELD = "id";
|
public static final String ID_FIELD = "id";
|
||||||
public static final String CAUSE_FIELD = "cause";
|
public static final String CAUSE_FIELD = "cause";
|
||||||
public static final String STATUS_FIELD = "status";
|
public static final String STATUS_FIELD = "status";
|
||||||
|
|
||||||
private final String index;
|
private final String index;
|
||||||
private final String type;
|
|
||||||
private final String id;
|
private final String id;
|
||||||
private final Exception cause;
|
private final Exception cause;
|
||||||
private final RestStatus status;
|
private final RestStatus status;
|
||||||
|
@ -196,11 +194,10 @@ public class BulkItemResponse implements Writeable, StatusToXContentObject {
|
||||||
public static final ConstructingObjectParser<Failure, Void> PARSER = new ConstructingObjectParser<>(
|
public static final ConstructingObjectParser<Failure, Void> PARSER = new ConstructingObjectParser<>(
|
||||||
"bulk_failures",
|
"bulk_failures",
|
||||||
true,
|
true,
|
||||||
a -> new Failure((String) a[0], (String) a[1], (String) a[2], (Exception) a[3], RestStatus.fromCode((int) a[4]))
|
a -> new Failure((String) a[0], (String) a[1], (Exception) a[2], RestStatus.fromCode((int) a[3]))
|
||||||
);
|
);
|
||||||
static {
|
static {
|
||||||
PARSER.declareString(constructorArg(), new ParseField(INDEX_FIELD));
|
PARSER.declareString(constructorArg(), new ParseField(INDEX_FIELD));
|
||||||
PARSER.declareString(constructorArg(), new ParseField(TYPE_FIELD));
|
|
||||||
PARSER.declareString(optionalConstructorArg(), new ParseField(ID_FIELD));
|
PARSER.declareString(optionalConstructorArg(), new ParseField(ID_FIELD));
|
||||||
PARSER.declareObject(constructorArg(), (p, c) -> OpenSearchException.fromXContent(p), new ParseField(CAUSE_FIELD));
|
PARSER.declareObject(constructorArg(), (p, c) -> OpenSearchException.fromXContent(p), new ParseField(CAUSE_FIELD));
|
||||||
PARSER.declareInt(constructorArg(), new ParseField(STATUS_FIELD));
|
PARSER.declareInt(constructorArg(), new ParseField(STATUS_FIELD));
|
||||||
|
@ -209,13 +206,12 @@ public class BulkItemResponse implements Writeable, StatusToXContentObject {
|
||||||
/**
|
/**
|
||||||
* For write failures before operation was assigned a sequence number.
|
* For write failures before operation was assigned a sequence number.
|
||||||
*
|
*
|
||||||
* use @{link {@link #Failure(String, String, String, Exception, long, long)}}
|
* use @{link {@link #Failure(String, String, Exception, long, long)}}
|
||||||
* to record operation sequence no with failure
|
* to record operation sequence no with failure
|
||||||
*/
|
*/
|
||||||
public Failure(String index, String type, String id, Exception cause) {
|
public Failure(String index, String id, Exception cause) {
|
||||||
this(
|
this(
|
||||||
index,
|
index,
|
||||||
type,
|
|
||||||
id,
|
id,
|
||||||
cause,
|
cause,
|
||||||
ExceptionsHelper.status(cause),
|
ExceptionsHelper.status(cause),
|
||||||
|
@ -225,10 +221,9 @@ public class BulkItemResponse implements Writeable, StatusToXContentObject {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Failure(String index, String type, String id, Exception cause, boolean aborted) {
|
public Failure(String index, String id, Exception cause, boolean aborted) {
|
||||||
this(
|
this(
|
||||||
index,
|
index,
|
||||||
type,
|
|
||||||
id,
|
id,
|
||||||
cause,
|
cause,
|
||||||
ExceptionsHelper.status(cause),
|
ExceptionsHelper.status(cause),
|
||||||
|
@ -238,18 +233,17 @@ public class BulkItemResponse implements Writeable, StatusToXContentObject {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Failure(String index, String type, String id, Exception cause, RestStatus status) {
|
public Failure(String index, String id, Exception cause, RestStatus status) {
|
||||||
this(index, type, id, cause, status, SequenceNumbers.UNASSIGNED_SEQ_NO, SequenceNumbers.UNASSIGNED_PRIMARY_TERM, false);
|
this(index, id, cause, status, SequenceNumbers.UNASSIGNED_SEQ_NO, SequenceNumbers.UNASSIGNED_PRIMARY_TERM, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For write failures after operation was assigned a sequence number. */
|
/** For write failures after operation was assigned a sequence number. */
|
||||||
public Failure(String index, String type, String id, Exception cause, long seqNo, long term) {
|
public Failure(String index, String id, Exception cause, long seqNo, long term) {
|
||||||
this(index, type, id, cause, ExceptionsHelper.status(cause), seqNo, term, false);
|
this(index, id, cause, ExceptionsHelper.status(cause), seqNo, term, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Failure(String index, String type, String id, Exception cause, RestStatus status, long seqNo, long term, boolean aborted) {
|
private Failure(String index, String id, Exception cause, RestStatus status, long seqNo, long term, boolean aborted) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.type = type;
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.cause = cause;
|
this.cause = cause;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
|
@ -263,7 +257,11 @@ public class BulkItemResponse implements Writeable, StatusToXContentObject {
|
||||||
*/
|
*/
|
||||||
public Failure(StreamInput in) throws IOException {
|
public Failure(StreamInput in) throws IOException {
|
||||||
index = in.readString();
|
index = in.readString();
|
||||||
type = in.readString();
|
if (in.getVersion().before(Version.V_2_0_0)) {
|
||||||
|
in.readString();
|
||||||
|
// can't make an assertion about type names here because too many tests still set their own
|
||||||
|
// types bypassing various checks
|
||||||
|
}
|
||||||
id = in.readOptionalString();
|
id = in.readOptionalString();
|
||||||
cause = in.readException();
|
cause = in.readException();
|
||||||
status = ExceptionsHelper.status(cause);
|
status = ExceptionsHelper.status(cause);
|
||||||
|
@ -279,7 +277,9 @@ public class BulkItemResponse implements Writeable, StatusToXContentObject {
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
out.writeString(index);
|
out.writeString(index);
|
||||||
out.writeString(type);
|
if (out.getVersion().before(Version.V_2_0_0)) {
|
||||||
|
out.writeString(MapperService.SINGLE_MAPPING_NAME);
|
||||||
|
}
|
||||||
out.writeOptionalString(id);
|
out.writeOptionalString(id);
|
||||||
out.writeException(cause);
|
out.writeException(cause);
|
||||||
out.writeZLong(seqNo);
|
out.writeZLong(seqNo);
|
||||||
|
@ -296,13 +296,6 @@ public class BulkItemResponse implements Writeable, StatusToXContentObject {
|
||||||
return this.index;
|
return this.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The type of the action.
|
|
||||||
*/
|
|
||||||
public String getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The id of the action.
|
* The id of the action.
|
||||||
*/
|
*/
|
||||||
|
@ -361,7 +354,6 @@ public class BulkItemResponse implements Writeable, StatusToXContentObject {
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.field(INDEX_FIELD, index);
|
builder.field(INDEX_FIELD, index);
|
||||||
builder.field(TYPE_FIELD, type);
|
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
builder.field(ID_FIELD, id);
|
builder.field(ID_FIELD, id);
|
||||||
}
|
}
|
||||||
|
@ -468,16 +460,6 @@ public class BulkItemResponse implements Writeable, StatusToXContentObject {
|
||||||
return response.getIndex();
|
return response.getIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The type of the action.
|
|
||||||
*/
|
|
||||||
public String getType() {
|
|
||||||
if (failure != null) {
|
|
||||||
return failure.getType();
|
|
||||||
}
|
|
||||||
return response.getType();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The id of the action.
|
* The id of the action.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -251,7 +251,7 @@ class BulkPrimaryExecutionContext {
|
||||||
docWriteRequest.opType(),
|
docWriteRequest.opType(),
|
||||||
// Make sure to use getCurrentItem().index() here, if you use docWriteRequest.index() it will use the
|
// Make sure to use getCurrentItem().index() here, if you use docWriteRequest.index() it will use the
|
||||||
// concrete index instead of an alias if used!
|
// concrete index instead of an alias if used!
|
||||||
new BulkItemResponse.Failure(getCurrentItem().index(), docWriteRequest.type(), docWriteRequest.id(), cause)
|
new BulkItemResponse.Failure(getCurrentItem().index(), docWriteRequest.id(), cause)
|
||||||
);
|
);
|
||||||
markAsCompleted(executionResult);
|
markAsCompleted(executionResult);
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,6 @@ class BulkPrimaryExecutionContext {
|
||||||
// concrete index instead of an alias if used!
|
// concrete index instead of an alias if used!
|
||||||
new BulkItemResponse.Failure(
|
new BulkItemResponse.Failure(
|
||||||
request.index(),
|
request.index(),
|
||||||
docWriteRequest.type(),
|
|
||||||
docWriteRequest.id(),
|
docWriteRequest.id(),
|
||||||
result.getFailure(),
|
result.getFailure(),
|
||||||
result.getSeqNo(),
|
result.getSeqNo(),
|
||||||
|
|
|
@ -106,7 +106,6 @@ public class BulkProcessor implements Closeable {
|
||||||
private TimeValue flushInterval = null;
|
private TimeValue flushInterval = null;
|
||||||
private BackoffPolicy backoffPolicy = BackoffPolicy.exponentialBackoff();
|
private BackoffPolicy backoffPolicy = BackoffPolicy.exponentialBackoff();
|
||||||
private String globalIndex;
|
private String globalIndex;
|
||||||
private String globalType;
|
|
||||||
private String globalRouting;
|
private String globalRouting;
|
||||||
private String globalPipeline;
|
private String globalPipeline;
|
||||||
|
|
||||||
|
@ -168,11 +167,6 @@ public class BulkProcessor implements Closeable {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setGlobalType(String globalType) {
|
|
||||||
this.globalType = globalType;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setGlobalRouting(String globalRouting) {
|
public Builder setGlobalRouting(String globalRouting) {
|
||||||
this.globalRouting = globalRouting;
|
this.globalRouting = globalRouting;
|
||||||
return this;
|
return this;
|
||||||
|
@ -219,7 +213,7 @@ public class BulkProcessor implements Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Supplier<BulkRequest> createBulkRequestWithGlobalDefaults() {
|
private Supplier<BulkRequest> createBulkRequestWithGlobalDefaults() {
|
||||||
return () -> new BulkRequest(globalIndex, globalType).pipeline(globalPipeline).routing(globalRouting);
|
return () -> new BulkRequest(globalIndex).pipeline(globalPipeline).routing(globalRouting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,9 +446,8 @@ public class BulkProcessor implements Closeable {
|
||||||
/**
|
/**
|
||||||
* Adds the data from the bytes to be processed by the bulk processor
|
* Adds the data from the bytes to be processed by the bulk processor
|
||||||
*/
|
*/
|
||||||
public BulkProcessor add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, XContentType xContentType)
|
public BulkProcessor add(BytesReference data, @Nullable String defaultIndex, XContentType xContentType) throws Exception {
|
||||||
throws Exception {
|
return add(data, defaultIndex, null, xContentType);
|
||||||
return add(data, defaultIndex, defaultType, null, xContentType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -463,7 +456,6 @@ public class BulkProcessor implements Closeable {
|
||||||
public BulkProcessor add(
|
public BulkProcessor add(
|
||||||
BytesReference data,
|
BytesReference data,
|
||||||
@Nullable String defaultIndex,
|
@Nullable String defaultIndex,
|
||||||
@Nullable String defaultType,
|
|
||||||
@Nullable String defaultPipeline,
|
@Nullable String defaultPipeline,
|
||||||
XContentType xContentType
|
XContentType xContentType
|
||||||
) throws Exception {
|
) throws Exception {
|
||||||
|
@ -471,7 +463,7 @@ public class BulkProcessor implements Closeable {
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
bulkRequest.add(data, defaultIndex, defaultType, null, null, defaultPipeline, null, true, xContentType);
|
bulkRequest.add(data, defaultIndex, null, null, defaultPipeline, null, true, xContentType);
|
||||||
bulkRequestToExecute = newBulkRequestIfNeeded();
|
bulkRequestToExecute = newBulkRequestIfNeeded();
|
||||||
} finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
|
@ -52,7 +52,6 @@ import org.opensearch.common.io.stream.StreamInput;
|
||||||
import org.opensearch.common.io.stream.StreamOutput;
|
import org.opensearch.common.io.stream.StreamOutput;
|
||||||
import org.opensearch.common.unit.TimeValue;
|
import org.opensearch.common.unit.TimeValue;
|
||||||
import org.opensearch.common.xcontent.XContentType;
|
import org.opensearch.common.xcontent.XContentType;
|
||||||
import org.opensearch.index.mapper.MapperService;
|
|
||||||
import org.opensearch.search.fetch.subphase.FetchSourceContext;
|
import org.opensearch.search.fetch.subphase.FetchSourceContext;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -92,7 +91,6 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques
|
||||||
private String globalPipeline;
|
private String globalPipeline;
|
||||||
private String globalRouting;
|
private String globalRouting;
|
||||||
private String globalIndex;
|
private String globalIndex;
|
||||||
private String globalType;
|
|
||||||
private Boolean globalRequireAlias;
|
private Boolean globalRequireAlias;
|
||||||
|
|
||||||
private long sizeInBytes = 0;
|
private long sizeInBytes = 0;
|
||||||
|
@ -111,15 +109,6 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques
|
||||||
this.globalIndex = globalIndex;
|
this.globalIndex = globalIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Types are in the process of being removed. Use {@link #BulkRequest(String)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public BulkRequest(@Nullable String globalIndex, @Nullable String globalType) {
|
|
||||||
this.globalIndex = globalIndex;
|
|
||||||
this.globalType = globalType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a list of requests to be executed. Either index or delete requests.
|
* Adds a list of requests to be executed. Either index or delete requests.
|
||||||
*/
|
*/
|
||||||
|
@ -246,62 +235,21 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques
|
||||||
* Adds a framed data in binary format
|
* Adds a framed data in binary format
|
||||||
*/
|
*/
|
||||||
public BulkRequest add(byte[] data, int from, int length, XContentType xContentType) throws IOException {
|
public BulkRequest add(byte[] data, int from, int length, XContentType xContentType) throws IOException {
|
||||||
return add(data, from, length, null, null, xContentType);
|
return add(data, from, length, null, xContentType);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a framed data in binary format
|
|
||||||
* @deprecated use {@link #add(byte[], int, int, String, XContentType)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public BulkRequest add(
|
|
||||||
byte[] data,
|
|
||||||
int from,
|
|
||||||
int length,
|
|
||||||
@Nullable String defaultIndex,
|
|
||||||
@Nullable String defaultType,
|
|
||||||
XContentType xContentType
|
|
||||||
) throws IOException {
|
|
||||||
return add(new BytesArray(data, from, length), defaultIndex, defaultType, xContentType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a framed data in binary format
|
* Adds a framed data in binary format
|
||||||
*/
|
*/
|
||||||
public BulkRequest add(byte[] data, int from, int length, @Nullable String defaultIndex, XContentType xContentType) throws IOException {
|
public BulkRequest add(byte[] data, int from, int length, @Nullable String defaultIndex, XContentType xContentType) throws IOException {
|
||||||
return add(new BytesArray(data, from, length), defaultIndex, MapperService.SINGLE_MAPPING_NAME, xContentType);
|
return add(new BytesArray(data, from, length), defaultIndex, xContentType);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a framed data in binary format
|
|
||||||
* @deprecated use {@link #add(BytesReference, String, XContentType)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, XContentType xContentType)
|
|
||||||
throws IOException {
|
|
||||||
return add(data, defaultIndex, defaultType, null, null, null, null, true, xContentType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a framed data in binary format
|
* Adds a framed data in binary format
|
||||||
*/
|
*/
|
||||||
public BulkRequest add(BytesReference data, @Nullable String defaultIndex, XContentType xContentType) throws IOException {
|
public BulkRequest add(BytesReference data, @Nullable String defaultIndex, XContentType xContentType) throws IOException {
|
||||||
return add(data, defaultIndex, MapperService.SINGLE_MAPPING_NAME, null, null, null, null, true, xContentType);
|
return add(data, defaultIndex, null, null, null, null, true, xContentType);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a framed data in binary format
|
|
||||||
* @deprecated use {@link #add(BytesReference, String, boolean, XContentType)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public BulkRequest add(
|
|
||||||
BytesReference data,
|
|
||||||
@Nullable String defaultIndex,
|
|
||||||
@Nullable String defaultType,
|
|
||||||
boolean allowExplicitIndex,
|
|
||||||
XContentType xContentType
|
|
||||||
) throws IOException {
|
|
||||||
return add(data, defaultIndex, defaultType, null, null, null, null, allowExplicitIndex, xContentType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -309,7 +257,7 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques
|
||||||
*/
|
*/
|
||||||
public BulkRequest add(BytesReference data, @Nullable String defaultIndex, boolean allowExplicitIndex, XContentType xContentType)
|
public BulkRequest add(BytesReference data, @Nullable String defaultIndex, boolean allowExplicitIndex, XContentType xContentType)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
return add(data, defaultIndex, MapperService.SINGLE_MAPPING_NAME, null, null, null, null, allowExplicitIndex, xContentType);
|
return add(data, defaultIndex, null, null, null, null, allowExplicitIndex, xContentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BulkRequest add(
|
public BulkRequest add(
|
||||||
|
@ -321,27 +269,12 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques
|
||||||
boolean allowExplicitIndex,
|
boolean allowExplicitIndex,
|
||||||
XContentType xContentType
|
XContentType xContentType
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
return add(
|
return add(data, defaultIndex, defaultRouting, defaultFetchSourceContext, defaultPipeline, null, allowExplicitIndex, xContentType);
|
||||||
data,
|
|
||||||
defaultIndex,
|
|
||||||
MapperService.SINGLE_MAPPING_NAME,
|
|
||||||
defaultRouting,
|
|
||||||
defaultFetchSourceContext,
|
|
||||||
defaultPipeline,
|
|
||||||
null,
|
|
||||||
allowExplicitIndex,
|
|
||||||
xContentType
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link #add(BytesReference, String, String, FetchSourceContext, String, boolean, XContentType)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public BulkRequest add(
|
public BulkRequest add(
|
||||||
BytesReference data,
|
BytesReference data,
|
||||||
@Nullable String defaultIndex,
|
@Nullable String defaultIndex,
|
||||||
@Nullable String defaultType,
|
|
||||||
@Nullable String defaultRouting,
|
@Nullable String defaultRouting,
|
||||||
@Nullable FetchSourceContext defaultFetchSourceContext,
|
@Nullable FetchSourceContext defaultFetchSourceContext,
|
||||||
@Nullable String defaultPipeline,
|
@Nullable String defaultPipeline,
|
||||||
|
@ -355,14 +288,13 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques
|
||||||
new BulkRequestParser(true).parse(
|
new BulkRequestParser(true).parse(
|
||||||
data,
|
data,
|
||||||
defaultIndex,
|
defaultIndex,
|
||||||
defaultType,
|
|
||||||
routing,
|
routing,
|
||||||
defaultFetchSourceContext,
|
defaultFetchSourceContext,
|
||||||
pipeline,
|
pipeline,
|
||||||
requireAlias,
|
requireAlias,
|
||||||
allowExplicitIndex,
|
allowExplicitIndex,
|
||||||
xContentType,
|
xContentType,
|
||||||
this::internalAdd,
|
(indexRequest, type) -> internalAdd(indexRequest),
|
||||||
this::internalAdd,
|
this::internalAdd,
|
||||||
this::add
|
this::add
|
||||||
);
|
);
|
||||||
|
@ -526,9 +458,6 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques
|
||||||
|
|
||||||
private void applyGlobalMandatoryParameters(DocWriteRequest<?> request) {
|
private void applyGlobalMandatoryParameters(DocWriteRequest<?> request) {
|
||||||
request.index(valueOrDefault(request.index(), globalIndex));
|
request.index(valueOrDefault(request.index(), globalIndex));
|
||||||
if (Strings.isNullOrEmpty(globalType) == false && MapperService.SINGLE_MAPPING_NAME.equals(globalType) == false) {
|
|
||||||
request.defaultTypeIfNull(globalType);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String valueOrDefault(String value, String globalDefault) {
|
private static String valueOrDefault(String value, String globalDefault) {
|
||||||
|
|
|
@ -46,7 +46,6 @@ import org.opensearch.client.OpenSearchClient;
|
||||||
import org.opensearch.common.Nullable;
|
import org.opensearch.common.Nullable;
|
||||||
import org.opensearch.common.unit.TimeValue;
|
import org.opensearch.common.unit.TimeValue;
|
||||||
import org.opensearch.common.xcontent.XContentType;
|
import org.opensearch.common.xcontent.XContentType;
|
||||||
import org.opensearch.index.mapper.MapperService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A bulk request holds an ordered {@link IndexRequest}s and {@link DeleteRequest}s and allows to executes
|
* A bulk request holds an ordered {@link IndexRequest}s and {@link DeleteRequest}s and allows to executes
|
||||||
|
@ -54,14 +53,6 @@ import org.opensearch.index.mapper.MapperService;
|
||||||
*/
|
*/
|
||||||
public class BulkRequestBuilder extends ActionRequestBuilder<BulkRequest, BulkResponse> implements WriteRequestBuilder<BulkRequestBuilder> {
|
public class BulkRequestBuilder extends ActionRequestBuilder<BulkRequest, BulkResponse> implements WriteRequestBuilder<BulkRequestBuilder> {
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link #BulkRequestBuilder(OpenSearchClient, BulkAction, String)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public BulkRequestBuilder(OpenSearchClient client, BulkAction action, @Nullable String globalIndex, @Nullable String globalType) {
|
|
||||||
super(client, action, new BulkRequest(globalIndex, globalType));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BulkRequestBuilder(OpenSearchClient client, BulkAction action, @Nullable String globalIndex) {
|
public BulkRequestBuilder(OpenSearchClient client, BulkAction action, @Nullable String globalIndex) {
|
||||||
super(client, action, new BulkRequest(globalIndex));
|
super(client, action, new BulkRequest(globalIndex));
|
||||||
}
|
}
|
||||||
|
@ -128,29 +119,12 @@ public class BulkRequestBuilder extends ActionRequestBuilder<BulkRequest, BulkRe
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a framed data in binary format
|
|
||||||
* @deprecated use {@link #add(byte[], int, int, String, XContentType)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public BulkRequestBuilder add(
|
|
||||||
byte[] data,
|
|
||||||
int from,
|
|
||||||
int length,
|
|
||||||
@Nullable String defaultIndex,
|
|
||||||
@Nullable String defaultType,
|
|
||||||
XContentType xContentType
|
|
||||||
) throws Exception {
|
|
||||||
request.add(data, from, length, defaultIndex, defaultType, xContentType);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a framed data in binary format
|
* Adds a framed data in binary format
|
||||||
*/
|
*/
|
||||||
public BulkRequestBuilder add(byte[] data, int from, int length, @Nullable String defaultIndex, XContentType xContentType)
|
public BulkRequestBuilder add(byte[] data, int from, int length, @Nullable String defaultIndex, XContentType xContentType)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
request.add(data, from, length, defaultIndex, MapperService.SINGLE_MAPPING_NAME, xContentType);
|
request.add(data, from, length, defaultIndex, xContentType);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ import org.opensearch.common.Nullable;
|
||||||
import org.opensearch.common.ParseField;
|
import org.opensearch.common.ParseField;
|
||||||
import org.opensearch.common.bytes.BytesArray;
|
import org.opensearch.common.bytes.BytesArray;
|
||||||
import org.opensearch.common.bytes.BytesReference;
|
import org.opensearch.common.bytes.BytesReference;
|
||||||
import org.opensearch.common.logging.DeprecationLogger;
|
|
||||||
import org.opensearch.common.lucene.uid.Versions;
|
import org.opensearch.common.lucene.uid.Versions;
|
||||||
import org.opensearch.common.xcontent.LoggingDeprecationHandler;
|
import org.opensearch.common.xcontent.LoggingDeprecationHandler;
|
||||||
import org.opensearch.common.xcontent.NamedXContentRegistry;
|
import org.opensearch.common.xcontent.NamedXContentRegistry;
|
||||||
|
@ -49,12 +48,12 @@ import org.opensearch.common.xcontent.XContentParser;
|
||||||
import org.opensearch.common.xcontent.XContentType;
|
import org.opensearch.common.xcontent.XContentType;
|
||||||
import org.opensearch.index.VersionType;
|
import org.opensearch.index.VersionType;
|
||||||
import org.opensearch.index.seqno.SequenceNumbers;
|
import org.opensearch.index.seqno.SequenceNumbers;
|
||||||
import org.opensearch.rest.action.document.RestBulkAction;
|
|
||||||
import org.opensearch.search.fetch.subphase.FetchSourceContext;
|
import org.opensearch.search.fetch.subphase.FetchSourceContext;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
@ -65,8 +64,6 @@ import static org.opensearch.index.seqno.SequenceNumbers.UNASSIGNED_PRIMARY_TERM
|
||||||
*/
|
*/
|
||||||
public final class BulkRequestParser {
|
public final class BulkRequestParser {
|
||||||
|
|
||||||
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(BulkRequestParser.class);
|
|
||||||
|
|
||||||
private static final ParseField INDEX = new ParseField("_index");
|
private static final ParseField INDEX = new ParseField("_index");
|
||||||
private static final ParseField TYPE = new ParseField("_type");
|
private static final ParseField TYPE = new ParseField("_type");
|
||||||
private static final ParseField ID = new ParseField("_id");
|
private static final ParseField ID = new ParseField("_id");
|
||||||
|
@ -81,14 +78,15 @@ public final class BulkRequestParser {
|
||||||
private static final ParseField IF_PRIMARY_TERM = new ParseField("if_primary_term");
|
private static final ParseField IF_PRIMARY_TERM = new ParseField("if_primary_term");
|
||||||
private static final ParseField REQUIRE_ALIAS = new ParseField(DocWriteRequest.REQUIRE_ALIAS);
|
private static final ParseField REQUIRE_ALIAS = new ParseField(DocWriteRequest.REQUIRE_ALIAS);
|
||||||
|
|
||||||
private final boolean warnOnTypeUsage;
|
// TODO: Remove this parameter once the BulkMonitoring endpoint has been removed
|
||||||
|
private final boolean errorOnType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new parser.
|
* Create a new parser.
|
||||||
* @param warnOnTypeUsage whether it warns upon types being explicitly specified
|
* @param errorOnType whether to allow _type information in the index line; used by BulkMonitoring
|
||||||
*/
|
*/
|
||||||
public BulkRequestParser(boolean warnOnTypeUsage) {
|
public BulkRequestParser(boolean errorOnType) {
|
||||||
this.warnOnTypeUsage = warnOnTypeUsage;
|
this.errorOnType = errorOnType;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int findNextMarker(byte marker, int from, BytesReference data) {
|
private static int findNextMarker(byte marker, int from, BytesReference data) {
|
||||||
|
@ -136,45 +134,7 @@ public final class BulkRequestParser {
|
||||||
@Nullable Boolean defaultRequireAlias,
|
@Nullable Boolean defaultRequireAlias,
|
||||||
boolean allowExplicitIndex,
|
boolean allowExplicitIndex,
|
||||||
XContentType xContentType,
|
XContentType xContentType,
|
||||||
Consumer<IndexRequest> indexRequestConsumer,
|
BiConsumer<IndexRequest, String> indexRequestConsumer,
|
||||||
Consumer<UpdateRequest> updateRequestConsumer,
|
|
||||||
Consumer<DeleteRequest> deleteRequestConsumer
|
|
||||||
) throws IOException {
|
|
||||||
parse(
|
|
||||||
data,
|
|
||||||
defaultIndex,
|
|
||||||
null,
|
|
||||||
defaultRouting,
|
|
||||||
defaultFetchSourceContext,
|
|
||||||
defaultPipeline,
|
|
||||||
defaultRequireAlias,
|
|
||||||
allowExplicitIndex,
|
|
||||||
xContentType,
|
|
||||||
indexRequestConsumer,
|
|
||||||
updateRequestConsumer,
|
|
||||||
deleteRequestConsumer
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse the provided {@code data} assuming the provided default values. Index requests
|
|
||||||
* will be passed to the {@code indexRequestConsumer}, update requests to the
|
|
||||||
* {@code updateRequestConsumer} and delete requests to the {@code deleteRequestConsumer}.
|
|
||||||
* @deprecated Use {@link #parse(BytesReference, String, String, FetchSourceContext, String, Boolean, boolean, XContentType,
|
|
||||||
* Consumer, Consumer, Consumer)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void parse(
|
|
||||||
BytesReference data,
|
|
||||||
@Nullable String defaultIndex,
|
|
||||||
@Nullable String defaultType,
|
|
||||||
@Nullable String defaultRouting,
|
|
||||||
@Nullable FetchSourceContext defaultFetchSourceContext,
|
|
||||||
@Nullable String defaultPipeline,
|
|
||||||
@Nullable Boolean defaultRequireAlias,
|
|
||||||
boolean allowExplicitIndex,
|
|
||||||
XContentType xContentType,
|
|
||||||
Consumer<IndexRequest> indexRequestConsumer,
|
|
||||||
Consumer<UpdateRequest> updateRequestConsumer,
|
Consumer<UpdateRequest> updateRequestConsumer,
|
||||||
Consumer<DeleteRequest> deleteRequestConsumer
|
Consumer<DeleteRequest> deleteRequestConsumer
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
|
@ -182,7 +142,6 @@ public final class BulkRequestParser {
|
||||||
int line = 0;
|
int line = 0;
|
||||||
int from = 0;
|
int from = 0;
|
||||||
byte marker = xContent.streamSeparator();
|
byte marker = xContent.streamSeparator();
|
||||||
boolean typesDeprecationLogged = false;
|
|
||||||
// Bulk requests can contain a lot of repeated strings for the index, pipeline and routing parameters. This map is used to
|
// Bulk requests can contain a lot of repeated strings for the index, pipeline and routing parameters. This map is used to
|
||||||
// deduplicate duplicate strings parsed for these parameters. While it does not prevent instantiating the duplicate strings, it
|
// deduplicate duplicate strings parsed for these parameters. While it does not prevent instantiating the duplicate strings, it
|
||||||
// reduces their lifetime to the lifetime of this parse call instead of the lifetime of the full bulk request.
|
// reduces their lifetime to the lifetime of this parse call instead of the lifetime of the full bulk request.
|
||||||
|
@ -231,7 +190,7 @@ public final class BulkRequestParser {
|
||||||
String action = parser.currentName();
|
String action = parser.currentName();
|
||||||
|
|
||||||
String index = defaultIndex;
|
String index = defaultIndex;
|
||||||
String type = defaultType;
|
String type = null;
|
||||||
String id = null;
|
String id = null;
|
||||||
String routing = defaultRouting;
|
String routing = defaultRouting;
|
||||||
FetchSourceContext fetchSourceContext = defaultFetchSourceContext;
|
FetchSourceContext fetchSourceContext = defaultFetchSourceContext;
|
||||||
|
@ -255,14 +214,15 @@ public final class BulkRequestParser {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (token.isValue()) {
|
} else if (token.isValue()) {
|
||||||
if (INDEX.match(currentFieldName, parser.getDeprecationHandler())) {
|
if (INDEX.match(currentFieldName, parser.getDeprecationHandler())) {
|
||||||
if (!allowExplicitIndex) {
|
if (allowExplicitIndex == false) {
|
||||||
throw new IllegalArgumentException("explicit index in bulk is not allowed");
|
throw new IllegalArgumentException("explicit index in bulk is not allowed");
|
||||||
}
|
}
|
||||||
index = stringDeduplicator.computeIfAbsent(parser.text(), Function.identity());
|
index = stringDeduplicator.computeIfAbsent(parser.text(), Function.identity());
|
||||||
} else if (TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
|
} else if (TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
|
||||||
if (warnOnTypeUsage && typesDeprecationLogged == false) {
|
if (errorOnType) {
|
||||||
deprecationLogger.deprecate("bulk_with_types", RestBulkAction.TYPES_DEPRECATION_MESSAGE);
|
throw new IllegalArgumentException(
|
||||||
typesDeprecationLogged = true;
|
"Action/metadata line [" + line + "] contains an unknown parameter [" + currentFieldName + "]"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
type = stringDeduplicator.computeIfAbsent(parser.text(), Function.identity());
|
type = stringDeduplicator.computeIfAbsent(parser.text(), Function.identity());
|
||||||
} else if (ID.match(currentFieldName, parser.getDeprecationHandler())) {
|
} else if (ID.match(currentFieldName, parser.getDeprecationHandler())) {
|
||||||
|
@ -333,7 +293,8 @@ public final class BulkRequestParser {
|
||||||
|
|
||||||
if ("delete".equals(action)) {
|
if ("delete".equals(action)) {
|
||||||
deleteRequestConsumer.accept(
|
deleteRequestConsumer.accept(
|
||||||
new DeleteRequest(index, type, id).routing(routing)
|
new DeleteRequest(index).id(id)
|
||||||
|
.routing(routing)
|
||||||
.version(version)
|
.version(version)
|
||||||
.versionType(versionType)
|
.versionType(versionType)
|
||||||
.setIfSeqNo(ifSeqNo)
|
.setIfSeqNo(ifSeqNo)
|
||||||
|
@ -351,18 +312,21 @@ public final class BulkRequestParser {
|
||||||
if ("index".equals(action)) {
|
if ("index".equals(action)) {
|
||||||
if (opType == null) {
|
if (opType == null) {
|
||||||
indexRequestConsumer.accept(
|
indexRequestConsumer.accept(
|
||||||
new IndexRequest(index, type, id).routing(routing)
|
new IndexRequest(index).id(id)
|
||||||
|
.routing(routing)
|
||||||
.version(version)
|
.version(version)
|
||||||
.versionType(versionType)
|
.versionType(versionType)
|
||||||
.setPipeline(pipeline)
|
.setPipeline(pipeline)
|
||||||
.setIfSeqNo(ifSeqNo)
|
.setIfSeqNo(ifSeqNo)
|
||||||
.setIfPrimaryTerm(ifPrimaryTerm)
|
.setIfPrimaryTerm(ifPrimaryTerm)
|
||||||
.source(sliceTrimmingCarriageReturn(data, from, nextMarker, xContentType), xContentType)
|
.source(sliceTrimmingCarriageReturn(data, from, nextMarker, xContentType), xContentType)
|
||||||
.setRequireAlias(requireAlias)
|
.setRequireAlias(requireAlias),
|
||||||
|
type
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
indexRequestConsumer.accept(
|
indexRequestConsumer.accept(
|
||||||
new IndexRequest(index, type, id).routing(routing)
|
new IndexRequest(index).id(id)
|
||||||
|
.routing(routing)
|
||||||
.version(version)
|
.version(version)
|
||||||
.versionType(versionType)
|
.versionType(versionType)
|
||||||
.create("create".equals(opType))
|
.create("create".equals(opType))
|
||||||
|
@ -370,12 +334,14 @@ public final class BulkRequestParser {
|
||||||
.setIfSeqNo(ifSeqNo)
|
.setIfSeqNo(ifSeqNo)
|
||||||
.setIfPrimaryTerm(ifPrimaryTerm)
|
.setIfPrimaryTerm(ifPrimaryTerm)
|
||||||
.source(sliceTrimmingCarriageReturn(data, from, nextMarker, xContentType), xContentType)
|
.source(sliceTrimmingCarriageReturn(data, from, nextMarker, xContentType), xContentType)
|
||||||
.setRequireAlias(requireAlias)
|
.setRequireAlias(requireAlias),
|
||||||
|
type
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if ("create".equals(action)) {
|
} else if ("create".equals(action)) {
|
||||||
indexRequestConsumer.accept(
|
indexRequestConsumer.accept(
|
||||||
new IndexRequest(index, type, id).routing(routing)
|
new IndexRequest(index).id(id)
|
||||||
|
.routing(routing)
|
||||||
.version(version)
|
.version(version)
|
||||||
.versionType(versionType)
|
.versionType(versionType)
|
||||||
.create(true)
|
.create(true)
|
||||||
|
@ -383,7 +349,8 @@ public final class BulkRequestParser {
|
||||||
.setIfSeqNo(ifSeqNo)
|
.setIfSeqNo(ifSeqNo)
|
||||||
.setIfPrimaryTerm(ifPrimaryTerm)
|
.setIfPrimaryTerm(ifPrimaryTerm)
|
||||||
.source(sliceTrimmingCarriageReturn(data, from, nextMarker, xContentType), xContentType)
|
.source(sliceTrimmingCarriageReturn(data, from, nextMarker, xContentType), xContentType)
|
||||||
.setRequireAlias(requireAlias)
|
.setRequireAlias(requireAlias),
|
||||||
|
type
|
||||||
);
|
);
|
||||||
} else if ("update".equals(action)) {
|
} else if ("update".equals(action)) {
|
||||||
if (version != Versions.MATCH_ANY || versionType != VersionType.INTERNAL) {
|
if (version != Versions.MATCH_ANY || versionType != VersionType.INTERNAL) {
|
||||||
|
@ -391,7 +358,9 @@ public final class BulkRequestParser {
|
||||||
"Update requests do not support versioning. " + "Please use `if_seq_no` and `if_primary_term` instead"
|
"Update requests do not support versioning. " + "Please use `if_seq_no` and `if_primary_term` instead"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
UpdateRequest updateRequest = new UpdateRequest(index, type, id).routing(routing)
|
UpdateRequest updateRequest = new UpdateRequest().index(index)
|
||||||
|
.id(id)
|
||||||
|
.routing(routing)
|
||||||
.retryOnConflict(retryOnConflict)
|
.retryOnConflict(retryOnConflict)
|
||||||
.setIfSeqNo(ifSeqNo)
|
.setIfSeqNo(ifSeqNo)
|
||||||
.setIfPrimaryTerm(ifPrimaryTerm)
|
.setIfPrimaryTerm(ifPrimaryTerm)
|
||||||
|
|
|
@ -129,8 +129,6 @@ public class BulkResponse extends ActionResponse implements Iterable<BulkItemRes
|
||||||
.append(i)
|
.append(i)
|
||||||
.append("]: index [")
|
.append("]: index [")
|
||||||
.append(response.getIndex())
|
.append(response.getIndex())
|
||||||
.append("], type [")
|
|
||||||
.append(response.getType())
|
|
||||||
.append("], id [")
|
.append("], id [")
|
||||||
.append(response.getId())
|
.append(response.getId())
|
||||||
.append("], message [")
|
.append("], message [")
|
||||||
|
|
|
@ -468,10 +468,7 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
||||||
Exception e
|
Exception e
|
||||||
) {
|
) {
|
||||||
if (index.equals(request.index())) {
|
if (index.equals(request.index())) {
|
||||||
responses.set(
|
responses.set(idx, new BulkItemResponse(idx, request.opType(), new BulkItemResponse.Failure(request.index(), request.id(), e)));
|
||||||
idx,
|
|
||||||
new BulkItemResponse(idx, request.opType(), new BulkItemResponse.Failure(request.index(), request.type(), request.id(), e))
|
|
||||||
);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -575,12 +572,7 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
||||||
throw new AssertionError("request type not supported: [" + docWriteRequest.opType() + "]");
|
throw new AssertionError("request type not supported: [" + docWriteRequest.opType() + "]");
|
||||||
}
|
}
|
||||||
} catch (OpenSearchParseException | IllegalArgumentException | RoutingMissingException e) {
|
} catch (OpenSearchParseException | IllegalArgumentException | RoutingMissingException e) {
|
||||||
BulkItemResponse.Failure failure = new BulkItemResponse.Failure(
|
BulkItemResponse.Failure failure = new BulkItemResponse.Failure(concreteIndex.getName(), docWriteRequest.id(), e);
|
||||||
concreteIndex.getName(),
|
|
||||||
docWriteRequest.type(),
|
|
||||||
docWriteRequest.id(),
|
|
||||||
e
|
|
||||||
);
|
|
||||||
BulkItemResponse bulkItemResponse = new BulkItemResponse(i, docWriteRequest.opType(), failure);
|
BulkItemResponse bulkItemResponse = new BulkItemResponse(i, docWriteRequest.opType(), failure);
|
||||||
responses.set(i, bulkItemResponse);
|
responses.set(i, bulkItemResponse);
|
||||||
// make sure the request gets never processed again
|
// make sure the request gets never processed again
|
||||||
|
@ -659,7 +651,7 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
||||||
new BulkItemResponse(
|
new BulkItemResponse(
|
||||||
request.id(),
|
request.id(),
|
||||||
docWriteRequest.opType(),
|
docWriteRequest.opType(),
|
||||||
new BulkItemResponse.Failure(indexName, docWriteRequest.type(), docWriteRequest.id(), e)
|
new BulkItemResponse.Failure(indexName, docWriteRequest.id(), e)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -759,12 +751,7 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFailure(DocWriteRequest<?> request, int idx, Exception unavailableException) {
|
private void addFailure(DocWriteRequest<?> request, int idx, Exception unavailableException) {
|
||||||
BulkItemResponse.Failure failure = new BulkItemResponse.Failure(
|
BulkItemResponse.Failure failure = new BulkItemResponse.Failure(request.index(), request.id(), unavailableException);
|
||||||
request.index(),
|
|
||||||
request.type(),
|
|
||||||
request.id(),
|
|
||||||
unavailableException
|
|
||||||
);
|
|
||||||
BulkItemResponse bulkItemResponse = new BulkItemResponse(idx, request.opType(), failure);
|
BulkItemResponse bulkItemResponse = new BulkItemResponse(idx, request.opType(), failure);
|
||||||
responses.set(idx, bulkItemResponse);
|
responses.set(idx, bulkItemResponse);
|
||||||
// make sure the request gets never processed again
|
// make sure the request gets never processed again
|
||||||
|
@ -992,12 +979,7 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
||||||
// 2) Add a bulk item failure for this request
|
// 2) Add a bulk item failure for this request
|
||||||
// 3) Continue with the next request in the bulk.
|
// 3) Continue with the next request in the bulk.
|
||||||
failedSlots.set(slot);
|
failedSlots.set(slot);
|
||||||
BulkItemResponse.Failure failure = new BulkItemResponse.Failure(
|
BulkItemResponse.Failure failure = new BulkItemResponse.Failure(indexRequest.index(), indexRequest.id(), e);
|
||||||
indexRequest.index(),
|
|
||||||
indexRequest.type(),
|
|
||||||
indexRequest.id(),
|
|
||||||
e
|
|
||||||
);
|
|
||||||
itemResponses.add(new BulkItemResponse(slot, indexRequest.opType(), failure));
|
itemResponses.add(new BulkItemResponse(slot, indexRequest.opType(), failure));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -184,22 +184,6 @@ public class DeleteRequest extends ReplicatedWriteRequest<DeleteRequest>
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the default type supplied to a bulk
|
|
||||||
* request if this individual request's type is null
|
|
||||||
* or empty
|
|
||||||
*
|
|
||||||
* @deprecated Types are in the process of being removed.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@Override
|
|
||||||
public DeleteRequest defaultTypeIfNull(String defaultType) {
|
|
||||||
if (Strings.isNullOrEmpty(type)) {
|
|
||||||
type = defaultType;
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The id of the document to delete.
|
* The id of the document to delete.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -322,21 +322,6 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the default type supplied to a bulk
|
|
||||||
* request if this individual request's type is null
|
|
||||||
* or empty
|
|
||||||
* @deprecated Types are in the process of being removed.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@Override
|
|
||||||
public IndexRequest defaultTypeIfNull(String defaultType) {
|
|
||||||
if (Strings.isNullOrEmpty(type)) {
|
|
||||||
type = defaultType;
|
|
||||||
}
|
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -288,21 +288,6 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the default type supplied to a bulk
|
|
||||||
* request if this individual request's type is null
|
|
||||||
* or empty
|
|
||||||
* @deprecated Types are in the process of being removed.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@Override
|
|
||||||
public UpdateRequest defaultTypeIfNull(String defaultType) {
|
|
||||||
if (Strings.isNullOrEmpty(type)) {
|
|
||||||
type = defaultType;
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The id of the indexed document.
|
* The id of the indexed document.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -243,9 +243,9 @@ public interface Client extends OpenSearchClient, Releasable {
|
||||||
BulkRequestBuilder prepareBulk();
|
BulkRequestBuilder prepareBulk();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes a bulk of index / delete operations with default index and/or type
|
* Executes a bulk of index / delete operations with default index
|
||||||
*/
|
*/
|
||||||
BulkRequestBuilder prepareBulk(@Nullable String globalIndex, @Nullable String globalType);
|
BulkRequestBuilder prepareBulk(@Nullable String globalIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the document that was indexed from an index with a type and id.
|
* Gets the document that was indexed from an index with a type and id.
|
||||||
|
|
|
@ -512,8 +512,8 @@ public abstract class AbstractClient implements Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BulkRequestBuilder prepareBulk(@Nullable String globalIndex, @Nullable String globalType) {
|
public BulkRequestBuilder prepareBulk(@Nullable String globalIndex) {
|
||||||
return new BulkRequestBuilder(this, BulkAction.INSTANCE, globalIndex, globalType);
|
return new BulkRequestBuilder(this, BulkAction.INSTANCE, globalIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -240,7 +240,6 @@ public class BulkByScrollResponse extends ActionResponse implements ToXContentFr
|
||||||
ensureExpectedToken(Token.START_OBJECT, parser.currentToken(), parser);
|
ensureExpectedToken(Token.START_OBJECT, parser.currentToken(), parser);
|
||||||
Token token;
|
Token token;
|
||||||
String index = null;
|
String index = null;
|
||||||
String type = null;
|
|
||||||
String id = null;
|
String id = null;
|
||||||
Integer status = null;
|
Integer status = null;
|
||||||
Integer shardId = null;
|
Integer shardId = null;
|
||||||
|
@ -270,9 +269,6 @@ public class BulkByScrollResponse extends ActionResponse implements ToXContentFr
|
||||||
case Failure.INDEX_FIELD:
|
case Failure.INDEX_FIELD:
|
||||||
index = parser.text();
|
index = parser.text();
|
||||||
break;
|
break;
|
||||||
case Failure.TYPE_FIELD:
|
|
||||||
type = parser.text();
|
|
||||||
break;
|
|
||||||
case Failure.ID_FIELD:
|
case Failure.ID_FIELD:
|
||||||
id = parser.text();
|
id = parser.text();
|
||||||
break;
|
break;
|
||||||
|
@ -298,7 +294,7 @@ public class BulkByScrollResponse extends ActionResponse implements ToXContentFr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bulkExc != null) {
|
if (bulkExc != null) {
|
||||||
return new Failure(index, type, id, bulkExc, RestStatus.fromCode(status));
|
return new Failure(index, id, bulkExc, RestStatus.fromCode(status));
|
||||||
} else if (searchExc != null) {
|
} else if (searchExc != null) {
|
||||||
if (status == null) {
|
if (status == null) {
|
||||||
return new SearchFailure(searchExc, index, shardId, nodeId);
|
return new SearchFailure(searchExc, index, shardId, nodeId);
|
||||||
|
|
|
@ -38,13 +38,10 @@ import org.opensearch.action.bulk.BulkShardRequest;
|
||||||
import org.opensearch.action.support.ActiveShardCount;
|
import org.opensearch.action.support.ActiveShardCount;
|
||||||
import org.opensearch.client.Requests;
|
import org.opensearch.client.Requests;
|
||||||
import org.opensearch.client.node.NodeClient;
|
import org.opensearch.client.node.NodeClient;
|
||||||
import org.opensearch.common.logging.DeprecationLogger;
|
|
||||||
import org.opensearch.common.settings.Settings;
|
import org.opensearch.common.settings.Settings;
|
||||||
import org.opensearch.index.mapper.MapperService;
|
|
||||||
import org.opensearch.rest.BaseRestHandler;
|
import org.opensearch.rest.BaseRestHandler;
|
||||||
import org.opensearch.rest.RestRequest;
|
import org.opensearch.rest.RestRequest;
|
||||||
import org.opensearch.rest.action.RestStatusToXContentListener;
|
import org.opensearch.rest.action.RestStatusToXContentListener;
|
||||||
import org.opensearch.rest.action.search.RestSearchAction;
|
|
||||||
import org.opensearch.search.fetch.subphase.FetchSourceContext;
|
import org.opensearch.search.fetch.subphase.FetchSourceContext;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -57,18 +54,16 @@ import static org.opensearch.rest.RestRequest.Method.PUT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* { "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" }
|
* { "index" : { "_index" : "test", "_id" : "1" }
|
||||||
* { "type1" : { "field1" : "value1" } }
|
* { "type1" : { "field1" : "value1" } }
|
||||||
* { "delete" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }
|
* { "delete" : { "_index" : "test", "_id" : "2" } }
|
||||||
* { "create" : { "_index" : "test", "_type" : "type1", "_id" : "1" }
|
* { "create" : { "_index" : "test", "_id" : "1" }
|
||||||
* { "type1" : { "field1" : "value1" } }
|
* { "type1" : { "field1" : "value1" } }
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
public class RestBulkAction extends BaseRestHandler {
|
public class RestBulkAction extends BaseRestHandler {
|
||||||
|
|
||||||
private final boolean allowExplicitIndex;
|
private final boolean allowExplicitIndex;
|
||||||
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestSearchAction.class);
|
|
||||||
public static final String TYPES_DEPRECATION_MESSAGE = "[types removal]" + " Specifying types in bulk requests is deprecated.";
|
|
||||||
|
|
||||||
public RestBulkAction(Settings settings) {
|
public RestBulkAction(Settings settings) {
|
||||||
this.allowExplicitIndex = MULTI_ALLOW_EXPLICIT_INDEX.get(settings);
|
this.allowExplicitIndex = MULTI_ALLOW_EXPLICIT_INDEX.get(settings);
|
||||||
|
@ -77,15 +72,7 @@ public class RestBulkAction extends BaseRestHandler {
|
||||||
@Override
|
@Override
|
||||||
public List<Route> routes() {
|
public List<Route> routes() {
|
||||||
return unmodifiableList(
|
return unmodifiableList(
|
||||||
asList(
|
asList(new Route(POST, "/_bulk"), new Route(PUT, "/_bulk"), new Route(POST, "/{index}/_bulk"), new Route(PUT, "/{index}/_bulk"))
|
||||||
new Route(POST, "/_bulk"),
|
|
||||||
new Route(PUT, "/_bulk"),
|
|
||||||
new Route(POST, "/{index}/_bulk"),
|
|
||||||
new Route(PUT, "/{index}/_bulk"),
|
|
||||||
// Deprecated typed endpoints.
|
|
||||||
new Route(POST, "/{index}/{type}/_bulk"),
|
|
||||||
new Route(PUT, "/{index}/{type}/_bulk")
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,12 +85,6 @@ public class RestBulkAction extends BaseRestHandler {
|
||||||
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
|
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
|
||||||
BulkRequest bulkRequest = Requests.bulkRequest();
|
BulkRequest bulkRequest = Requests.bulkRequest();
|
||||||
String defaultIndex = request.param("index");
|
String defaultIndex = request.param("index");
|
||||||
String defaultType = request.param("type");
|
|
||||||
if (defaultType == null) {
|
|
||||||
defaultType = MapperService.SINGLE_MAPPING_NAME;
|
|
||||||
} else {
|
|
||||||
deprecationLogger.deprecate("bulk_with_types", RestBulkAction.TYPES_DEPRECATION_MESSAGE);
|
|
||||||
}
|
|
||||||
String defaultRouting = request.param("routing");
|
String defaultRouting = request.param("routing");
|
||||||
FetchSourceContext defaultFetchSourceContext = FetchSourceContext.parseFromRestRequest(request);
|
FetchSourceContext defaultFetchSourceContext = FetchSourceContext.parseFromRestRequest(request);
|
||||||
String defaultPipeline = request.param("pipeline");
|
String defaultPipeline = request.param("pipeline");
|
||||||
|
@ -117,7 +98,6 @@ public class RestBulkAction extends BaseRestHandler {
|
||||||
bulkRequest.add(
|
bulkRequest.add(
|
||||||
request.requiredContent(),
|
request.requiredContent(),
|
||||||
defaultIndex,
|
defaultIndex,
|
||||||
defaultType,
|
|
||||||
defaultRouting,
|
defaultRouting,
|
||||||
defaultFetchSourceContext,
|
defaultFetchSourceContext,
|
||||||
defaultPipeline,
|
defaultPipeline,
|
||||||
|
|
|
@ -882,7 +882,7 @@ public class OpenSearchExceptionTests extends OpenSearchTestCase {
|
||||||
failure = new RuntimeException("E", failureCause);
|
failure = new RuntimeException("E", failureCause);
|
||||||
|
|
||||||
expectedCause = new OpenSearchException(
|
expectedCause = new OpenSearchException(
|
||||||
"OpenSearch exception [type=routing_missing_exception, " + "reason=routing is required for [idx]/[type]/[id]]"
|
"OpenSearch exception [type=routing_missing_exception, " + "reason=routing is required for [idx]/[id]]"
|
||||||
);
|
);
|
||||||
expectedCause.addMetadata("opensearch.index", "idx");
|
expectedCause.addMetadata("opensearch.index", "idx");
|
||||||
expectedCause.addMetadata("opensearch.index_uuid", "_na_");
|
expectedCause.addMetadata("opensearch.index_uuid", "_na_");
|
||||||
|
|
|
@ -57,7 +57,7 @@ import static org.hamcrest.Matchers.containsString;
|
||||||
public class BulkItemResponseTests extends OpenSearchTestCase {
|
public class BulkItemResponseTests extends OpenSearchTestCase {
|
||||||
|
|
||||||
public void testFailureToString() {
|
public void testFailureToString() {
|
||||||
Failure failure = new Failure("index", "type", "id", new RuntimeException("test"));
|
Failure failure = new Failure("index", "id", new RuntimeException("test"));
|
||||||
String toString = failure.toString();
|
String toString = failure.toString();
|
||||||
assertThat(toString, containsString("\"type\":\"runtime_exception\""));
|
assertThat(toString, containsString("\"type\":\"runtime_exception\""));
|
||||||
assertThat(toString, containsString("\"reason\":\"test\""));
|
assertThat(toString, containsString("\"reason\":\"test\""));
|
||||||
|
@ -101,16 +101,15 @@ public class BulkItemResponseTests extends OpenSearchTestCase {
|
||||||
|
|
||||||
int itemId = randomIntBetween(0, 100);
|
int itemId = randomIntBetween(0, 100);
|
||||||
String index = randomAlphaOfLength(5);
|
String index = randomAlphaOfLength(5);
|
||||||
String type = randomAlphaOfLength(5);
|
|
||||||
String id = randomAlphaOfLength(5);
|
String id = randomAlphaOfLength(5);
|
||||||
DocWriteRequest.OpType opType = randomFrom(DocWriteRequest.OpType.values());
|
DocWriteRequest.OpType opType = randomFrom(DocWriteRequest.OpType.values());
|
||||||
|
|
||||||
final Tuple<Throwable, OpenSearchException> exceptions = randomExceptions();
|
final Tuple<Throwable, OpenSearchException> exceptions = randomExceptions();
|
||||||
|
|
||||||
Exception bulkItemCause = (Exception) exceptions.v1();
|
Exception bulkItemCause = (Exception) exceptions.v1();
|
||||||
Failure bulkItemFailure = new Failure(index, type, id, bulkItemCause);
|
Failure bulkItemFailure = new Failure(index, id, bulkItemCause);
|
||||||
BulkItemResponse bulkItemResponse = new BulkItemResponse(itemId, opType, bulkItemFailure);
|
BulkItemResponse bulkItemResponse = new BulkItemResponse(itemId, opType, bulkItemFailure);
|
||||||
Failure expectedBulkItemFailure = new Failure(index, type, id, exceptions.v2(), ExceptionsHelper.status(bulkItemCause));
|
Failure expectedBulkItemFailure = new Failure(index, id, exceptions.v2(), ExceptionsHelper.status(bulkItemCause));
|
||||||
BulkItemResponse expectedBulkItemResponse = new BulkItemResponse(itemId, opType, expectedBulkItemFailure);
|
BulkItemResponse expectedBulkItemResponse = new BulkItemResponse(itemId, opType, expectedBulkItemFailure);
|
||||||
BytesReference originalBytes = toShuffledXContent(bulkItemResponse, xContentType, ToXContent.EMPTY_PARAMS, randomBoolean());
|
BytesReference originalBytes = toShuffledXContent(bulkItemResponse, xContentType, ToXContent.EMPTY_PARAMS, randomBoolean());
|
||||||
|
|
||||||
|
@ -133,7 +132,6 @@ public class BulkItemResponseTests extends OpenSearchTestCase {
|
||||||
public static void assertBulkItemResponse(BulkItemResponse expected, BulkItemResponse actual) {
|
public static void assertBulkItemResponse(BulkItemResponse expected, BulkItemResponse actual) {
|
||||||
assertEquals(expected.getItemId(), actual.getItemId());
|
assertEquals(expected.getItemId(), actual.getItemId());
|
||||||
assertEquals(expected.getIndex(), actual.getIndex());
|
assertEquals(expected.getIndex(), actual.getIndex());
|
||||||
assertEquals(expected.getType(), actual.getType());
|
|
||||||
assertEquals(expected.getId(), actual.getId());
|
assertEquals(expected.getId(), actual.getId());
|
||||||
assertEquals(expected.getOpType(), actual.getOpType());
|
assertEquals(expected.getOpType(), actual.getOpType());
|
||||||
assertEquals(expected.getVersion(), actual.getVersion());
|
assertEquals(expected.getVersion(), actual.getVersion());
|
||||||
|
@ -144,7 +142,6 @@ public class BulkItemResponseTests extends OpenSearchTestCase {
|
||||||
BulkItemResponse.Failure actualFailure = actual.getFailure();
|
BulkItemResponse.Failure actualFailure = actual.getFailure();
|
||||||
|
|
||||||
assertEquals(expectedFailure.getIndex(), actualFailure.getIndex());
|
assertEquals(expectedFailure.getIndex(), actualFailure.getIndex());
|
||||||
assertEquals(expectedFailure.getType(), actualFailure.getType());
|
|
||||||
assertEquals(expectedFailure.getId(), actualFailure.getId());
|
assertEquals(expectedFailure.getId(), actualFailure.getId());
|
||||||
assertEquals(expectedFailure.getMessage(), actualFailure.getMessage());
|
assertEquals(expectedFailure.getMessage(), actualFailure.getMessage());
|
||||||
assertEquals(expectedFailure.getStatus(), actualFailure.getStatus());
|
assertEquals(expectedFailure.getStatus(), actualFailure.getStatus());
|
||||||
|
|
|
@ -87,7 +87,6 @@ public class BulkRequestModifierTests extends OpenSearchTestCase {
|
||||||
BulkItemResponse item = bulkResponse.getItems()[j];
|
BulkItemResponse item = bulkResponse.getItems()[j];
|
||||||
assertThat(item.isFailed(), is(true));
|
assertThat(item.isFailed(), is(true));
|
||||||
assertThat(item.getFailure().getIndex(), equalTo("_index"));
|
assertThat(item.getFailure().getIndex(), equalTo("_index"));
|
||||||
assertThat(item.getFailure().getType(), equalTo("_type"));
|
|
||||||
assertThat(item.getFailure().getId(), equalTo(String.valueOf(j)));
|
assertThat(item.getFailure().getId(), equalTo(String.valueOf(j)));
|
||||||
assertThat(item.getFailure().getMessage(), equalTo("java.lang.RuntimeException"));
|
assertThat(item.getFailure().getMessage(), equalTo("java.lang.RuntimeException"));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -35,7 +35,6 @@ package org.opensearch.action.bulk;
|
||||||
import org.opensearch.action.index.IndexRequest;
|
import org.opensearch.action.index.IndexRequest;
|
||||||
import org.opensearch.common.bytes.BytesArray;
|
import org.opensearch.common.bytes.BytesArray;
|
||||||
import org.opensearch.common.xcontent.XContentType;
|
import org.opensearch.common.xcontent.XContentType;
|
||||||
import org.opensearch.rest.action.document.RestBulkAction;
|
|
||||||
import org.opensearch.test.OpenSearchTestCase;
|
import org.opensearch.test.OpenSearchTestCase;
|
||||||
import org.hamcrest.Matchers;
|
import org.hamcrest.Matchers;
|
||||||
|
|
||||||
|
@ -50,7 +49,7 @@ public class BulkRequestParserTests extends OpenSearchTestCase {
|
||||||
BytesArray request = new BytesArray("{ \"index\":{ \"_id\": \"bar\" } }\n{}\n");
|
BytesArray request = new BytesArray("{ \"index\":{ \"_id\": \"bar\" } }\n{}\n");
|
||||||
BulkRequestParser parser = new BulkRequestParser(randomBoolean());
|
BulkRequestParser parser = new BulkRequestParser(randomBoolean());
|
||||||
final AtomicBoolean parsed = new AtomicBoolean();
|
final AtomicBoolean parsed = new AtomicBoolean();
|
||||||
parser.parse(request, "foo", null, null, null, null, false, XContentType.JSON, indexRequest -> {
|
parser.parse(request, "foo", null, null, null, null, false, XContentType.JSON, (indexRequest, type) -> {
|
||||||
assertFalse(parsed.get());
|
assertFalse(parsed.get());
|
||||||
assertEquals("foo", indexRequest.index());
|
assertEquals("foo", indexRequest.index());
|
||||||
assertEquals("bar", indexRequest.id());
|
assertEquals("bar", indexRequest.id());
|
||||||
|
@ -68,7 +67,7 @@ public class BulkRequestParserTests extends OpenSearchTestCase {
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
XContentType.JSON,
|
XContentType.JSON,
|
||||||
indexRequest -> { assertTrue(indexRequest.isRequireAlias()); },
|
(indexRequest, type) -> { assertTrue(indexRequest.isRequireAlias()); },
|
||||||
req -> fail(),
|
req -> fail(),
|
||||||
req -> fail()
|
req -> fail()
|
||||||
);
|
);
|
||||||
|
@ -83,7 +82,7 @@ public class BulkRequestParserTests extends OpenSearchTestCase {
|
||||||
null,
|
null,
|
||||||
false,
|
false,
|
||||||
XContentType.JSON,
|
XContentType.JSON,
|
||||||
indexRequest -> { assertTrue(indexRequest.isRequireAlias()); },
|
(indexRequest, type) -> { assertTrue(indexRequest.isRequireAlias()); },
|
||||||
req -> fail(),
|
req -> fail(),
|
||||||
req -> fail()
|
req -> fail()
|
||||||
);
|
);
|
||||||
|
@ -98,7 +97,7 @@ public class BulkRequestParserTests extends OpenSearchTestCase {
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
XContentType.JSON,
|
XContentType.JSON,
|
||||||
indexRequest -> { assertFalse(indexRequest.isRequireAlias()); },
|
(indexRequest, type) -> { assertFalse(indexRequest.isRequireAlias()); },
|
||||||
req -> fail(),
|
req -> fail(),
|
||||||
req -> fail()
|
req -> fail()
|
||||||
);
|
);
|
||||||
|
@ -108,12 +107,24 @@ public class BulkRequestParserTests extends OpenSearchTestCase {
|
||||||
BytesArray request = new BytesArray("{ \"delete\":{ \"_id\": \"bar\" } }\n");
|
BytesArray request = new BytesArray("{ \"delete\":{ \"_id\": \"bar\" } }\n");
|
||||||
BulkRequestParser parser = new BulkRequestParser(randomBoolean());
|
BulkRequestParser parser = new BulkRequestParser(randomBoolean());
|
||||||
final AtomicBoolean parsed = new AtomicBoolean();
|
final AtomicBoolean parsed = new AtomicBoolean();
|
||||||
parser.parse(request, "foo", null, null, null, null, false, XContentType.JSON, req -> fail(), req -> fail(), deleteRequest -> {
|
parser.parse(
|
||||||
assertFalse(parsed.get());
|
request,
|
||||||
assertEquals("foo", deleteRequest.index());
|
"foo",
|
||||||
assertEquals("bar", deleteRequest.id());
|
null,
|
||||||
parsed.set(true);
|
null,
|
||||||
});
|
null,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
XContentType.JSON,
|
||||||
|
(req, type) -> fail(),
|
||||||
|
req -> fail(),
|
||||||
|
deleteRequest -> {
|
||||||
|
assertFalse(parsed.get());
|
||||||
|
assertEquals("foo", deleteRequest.index());
|
||||||
|
assertEquals("bar", deleteRequest.id());
|
||||||
|
parsed.set(true);
|
||||||
|
}
|
||||||
|
);
|
||||||
assertTrue(parsed.get());
|
assertTrue(parsed.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +132,7 @@ public class BulkRequestParserTests extends OpenSearchTestCase {
|
||||||
BytesArray request = new BytesArray("{ \"update\":{ \"_id\": \"bar\" } }\n{}\n");
|
BytesArray request = new BytesArray("{ \"update\":{ \"_id\": \"bar\" } }\n{}\n");
|
||||||
BulkRequestParser parser = new BulkRequestParser(randomBoolean());
|
BulkRequestParser parser = new BulkRequestParser(randomBoolean());
|
||||||
final AtomicBoolean parsed = new AtomicBoolean();
|
final AtomicBoolean parsed = new AtomicBoolean();
|
||||||
parser.parse(request, "foo", null, null, null, null, false, XContentType.JSON, req -> fail(), updateRequest -> {
|
parser.parse(request, "foo", null, null, null, null, false, XContentType.JSON, (req, type) -> fail(), updateRequest -> {
|
||||||
assertFalse(parsed.get());
|
assertFalse(parsed.get());
|
||||||
assertEquals("foo", updateRequest.index());
|
assertEquals("foo", updateRequest.index());
|
||||||
assertEquals("bar", updateRequest.id());
|
assertEquals("bar", updateRequest.id());
|
||||||
|
@ -139,7 +150,7 @@ public class BulkRequestParserTests extends OpenSearchTestCase {
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
XContentType.JSON,
|
XContentType.JSON,
|
||||||
req -> fail(),
|
(req, type) -> fail(),
|
||||||
updateRequest -> { assertTrue(updateRequest.isRequireAlias()); },
|
updateRequest -> { assertTrue(updateRequest.isRequireAlias()); },
|
||||||
req -> fail()
|
req -> fail()
|
||||||
);
|
);
|
||||||
|
@ -154,7 +165,7 @@ public class BulkRequestParserTests extends OpenSearchTestCase {
|
||||||
null,
|
null,
|
||||||
false,
|
false,
|
||||||
XContentType.JSON,
|
XContentType.JSON,
|
||||||
req -> fail(),
|
(req, type) -> fail(),
|
||||||
updateRequest -> { assertTrue(updateRequest.isRequireAlias()); },
|
updateRequest -> { assertTrue(updateRequest.isRequireAlias()); },
|
||||||
req -> fail()
|
req -> fail()
|
||||||
);
|
);
|
||||||
|
@ -169,7 +180,7 @@ public class BulkRequestParserTests extends OpenSearchTestCase {
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
XContentType.JSON,
|
XContentType.JSON,
|
||||||
req -> fail(),
|
(req, type) -> fail(),
|
||||||
updateRequest -> { assertFalse(updateRequest.isRequireAlias()); },
|
updateRequest -> { assertFalse(updateRequest.isRequireAlias()); },
|
||||||
req -> fail()
|
req -> fail()
|
||||||
);
|
);
|
||||||
|
@ -189,7 +200,7 @@ public class BulkRequestParserTests extends OpenSearchTestCase {
|
||||||
null,
|
null,
|
||||||
false,
|
false,
|
||||||
XContentType.JSON,
|
XContentType.JSON,
|
||||||
indexRequest -> fail(),
|
(indexRequest, type) -> fail(),
|
||||||
req -> fail(),
|
req -> fail(),
|
||||||
req -> fail()
|
req -> fail()
|
||||||
)
|
)
|
||||||
|
@ -203,24 +214,34 @@ public class BulkRequestParserTests extends OpenSearchTestCase {
|
||||||
|
|
||||||
IllegalArgumentException ex = expectThrows(
|
IllegalArgumentException ex = expectThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> parser.parse(request, null, null, null, null, null, false, XContentType.JSON, req -> fail(), req -> fail(), req -> fail())
|
() -> parser.parse(
|
||||||
|
request,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
XContentType.JSON,
|
||||||
|
(req, type) -> fail(),
|
||||||
|
req -> fail(),
|
||||||
|
req -> fail()
|
||||||
|
)
|
||||||
);
|
);
|
||||||
assertEquals("explicit index in bulk is not allowed", ex.getMessage());
|
assertEquals("explicit index in bulk is not allowed", ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTypeWarning() throws IOException {
|
public void testTypesStillParsedForBulkMonitoring() throws IOException {
|
||||||
BytesArray request = new BytesArray("{ \"index\":{ \"_type\": \"quux\", \"_id\": \"bar\" } }\n{}\n");
|
BytesArray request = new BytesArray("{ \"index\":{ \"_type\": \"quux\", \"_id\": \"bar\" } }\n{}\n");
|
||||||
BulkRequestParser parser = new BulkRequestParser(true);
|
BulkRequestParser parser = new BulkRequestParser(false);
|
||||||
final AtomicBoolean parsed = new AtomicBoolean();
|
final AtomicBoolean parsed = new AtomicBoolean();
|
||||||
parser.parse(request, "foo", null, null, null, null, false, XContentType.JSON, indexRequest -> {
|
parser.parse(request, "foo", null, null, null, null, false, XContentType.JSON, (indexRequest, type) -> {
|
||||||
assertFalse(parsed.get());
|
assertFalse(parsed.get());
|
||||||
assertEquals("foo", indexRequest.index());
|
assertEquals("foo", indexRequest.index());
|
||||||
assertEquals("bar", indexRequest.id());
|
assertEquals("bar", indexRequest.id());
|
||||||
parsed.set(true);
|
parsed.set(true);
|
||||||
}, req -> fail(), req -> fail());
|
}, req -> fail(), req -> fail());
|
||||||
assertTrue(parsed.get());
|
assertTrue(parsed.get());
|
||||||
|
|
||||||
assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testParseDeduplicatesParameterStrings() throws IOException {
|
public void testParseDeduplicatesParameterStrings() throws IOException {
|
||||||
|
@ -230,7 +251,19 @@ public class BulkRequestParserTests extends OpenSearchTestCase {
|
||||||
);
|
);
|
||||||
BulkRequestParser parser = new BulkRequestParser(randomBoolean());
|
BulkRequestParser parser = new BulkRequestParser(randomBoolean());
|
||||||
final List<IndexRequest> indexRequests = new ArrayList<>();
|
final List<IndexRequest> indexRequests = new ArrayList<>();
|
||||||
parser.parse(request, null, null, null, null, null, true, XContentType.JSON, indexRequests::add, req -> fail(), req -> fail());
|
parser.parse(
|
||||||
|
request,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
true,
|
||||||
|
XContentType.JSON,
|
||||||
|
(indexRequest, type) -> indexRequests.add(indexRequest),
|
||||||
|
req -> fail(),
|
||||||
|
req -> fail()
|
||||||
|
);
|
||||||
assertThat(indexRequests, Matchers.hasSize(2));
|
assertThat(indexRequests, Matchers.hasSize(2));
|
||||||
final IndexRequest first = indexRequests.get(0);
|
final IndexRequest first = indexRequests.get(0);
|
||||||
final IndexRequest second = indexRequests.get(1);
|
final IndexRequest second = indexRequests.get(1);
|
||||||
|
|
|
@ -47,7 +47,6 @@ import org.opensearch.common.xcontent.XContentBuilder;
|
||||||
import org.opensearch.common.xcontent.XContentFactory;
|
import org.opensearch.common.xcontent.XContentFactory;
|
||||||
import org.opensearch.common.xcontent.XContentHelper;
|
import org.opensearch.common.xcontent.XContentHelper;
|
||||||
import org.opensearch.common.xcontent.XContentType;
|
import org.opensearch.common.xcontent.XContentType;
|
||||||
import org.opensearch.rest.action.document.RestBulkAction;
|
|
||||||
import org.opensearch.script.Script;
|
import org.opensearch.script.Script;
|
||||||
import org.opensearch.test.OpenSearchTestCase;
|
import org.opensearch.test.OpenSearchTestCase;
|
||||||
|
|
||||||
|
@ -76,12 +75,10 @@ public class BulkRequestTests extends OpenSearchTestCase {
|
||||||
assertThat(((IndexRequest) bulkRequest.requests().get(0)).source(), equalTo(new BytesArray("{ \"field1\" : \"value1\" }")));
|
assertThat(((IndexRequest) bulkRequest.requests().get(0)).source(), equalTo(new BytesArray("{ \"field1\" : \"value1\" }")));
|
||||||
assertThat(bulkRequest.requests().get(1), instanceOf(DeleteRequest.class));
|
assertThat(bulkRequest.requests().get(1), instanceOf(DeleteRequest.class));
|
||||||
assertThat(((IndexRequest) bulkRequest.requests().get(2)).source(), equalTo(new BytesArray("{ \"field1\" : \"value3\" }")));
|
assertThat(((IndexRequest) bulkRequest.requests().get(2)).source(), equalTo(new BytesArray("{ \"field1\" : \"value3\" }")));
|
||||||
// This test's JSON contains outdated references to types
|
|
||||||
assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSimpleBulkWithCarriageReturn() throws Exception {
|
public void testSimpleBulkWithCarriageReturn() throws Exception {
|
||||||
String bulkAction = "{ \"index\":{\"_index\":\"test\",\"_type\":\"type1\",\"_id\":\"1\"} }\r\n{ \"field1\" : \"value1\" }\r\n";
|
String bulkAction = "{ \"index\":{\"_index\":\"test\",\"_id\":\"1\"} }\r\n{ \"field1\" : \"value1\" }\r\n";
|
||||||
BulkRequest bulkRequest = new BulkRequest();
|
BulkRequest bulkRequest = new BulkRequest();
|
||||||
bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON);
|
bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON);
|
||||||
assertThat(bulkRequest.numberOfActions(), equalTo(1));
|
assertThat(bulkRequest.numberOfActions(), equalTo(1));
|
||||||
|
@ -92,8 +89,6 @@ public class BulkRequestTests extends OpenSearchTestCase {
|
||||||
XContentType.JSON
|
XContentType.JSON
|
||||||
).v2();
|
).v2();
|
||||||
assertEquals("value1", sourceMap.get("field1"));
|
assertEquals("value1", sourceMap.get("field1"));
|
||||||
// This test's JSON contains outdated references to types
|
|
||||||
assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSimpleBulk2() throws Exception {
|
public void testSimpleBulk2() throws Exception {
|
||||||
|
@ -119,7 +114,6 @@ public class BulkRequestTests extends OpenSearchTestCase {
|
||||||
assertThat(((UpdateRequest) bulkRequest.requests().get(0)).retryOnConflict(), equalTo(2));
|
assertThat(((UpdateRequest) bulkRequest.requests().get(0)).retryOnConflict(), equalTo(2));
|
||||||
assertThat(((UpdateRequest) bulkRequest.requests().get(0)).doc().source().utf8ToString(), equalTo("{\"field\":\"value\"}"));
|
assertThat(((UpdateRequest) bulkRequest.requests().get(0)).doc().source().utf8ToString(), equalTo("{\"field\":\"value\"}"));
|
||||||
assertThat(bulkRequest.requests().get(1).id(), equalTo("0"));
|
assertThat(bulkRequest.requests().get(1).id(), equalTo("0"));
|
||||||
assertThat(bulkRequest.requests().get(1).type(), equalTo("type1"));
|
|
||||||
assertThat(bulkRequest.requests().get(1).index(), equalTo("index1"));
|
assertThat(bulkRequest.requests().get(1).index(), equalTo("index1"));
|
||||||
Script script = ((UpdateRequest) bulkRequest.requests().get(1)).script();
|
Script script = ((UpdateRequest) bulkRequest.requests().get(1)).script();
|
||||||
assertThat(script, notNullValue());
|
assertThat(script, notNullValue());
|
||||||
|
@ -130,22 +124,18 @@ public class BulkRequestTests extends OpenSearchTestCase {
|
||||||
assertThat(scriptParams.size(), equalTo(1));
|
assertThat(scriptParams.size(), equalTo(1));
|
||||||
assertThat(scriptParams.get("param1"), equalTo(1));
|
assertThat(scriptParams.get("param1"), equalTo(1));
|
||||||
assertThat(((UpdateRequest) bulkRequest.requests().get(1)).upsertRequest().source().utf8ToString(), equalTo("{\"counter\":1}"));
|
assertThat(((UpdateRequest) bulkRequest.requests().get(1)).upsertRequest().source().utf8ToString(), equalTo("{\"counter\":1}"));
|
||||||
// This test's JSON contains outdated references to types
|
|
||||||
assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBulkAllowExplicitIndex() throws Exception {
|
public void testBulkAllowExplicitIndex() throws Exception {
|
||||||
String bulkAction1 = copyToStringFromClasspath("/org/opensearch/action/bulk/simple-bulk.json");
|
String bulkAction1 = copyToStringFromClasspath("/org/opensearch/action/bulk/simple-bulk.json");
|
||||||
Exception ex = expectThrows(
|
Exception ex = expectThrows(
|
||||||
Exception.class,
|
Exception.class,
|
||||||
() -> new BulkRequest().add(new BytesArray(bulkAction1.getBytes(StandardCharsets.UTF_8)), null, null, false, XContentType.JSON)
|
() -> new BulkRequest().add(new BytesArray(bulkAction1.getBytes(StandardCharsets.UTF_8)), null, false, XContentType.JSON)
|
||||||
);
|
);
|
||||||
assertEquals("explicit index in bulk is not allowed", ex.getMessage());
|
assertEquals("explicit index in bulk is not allowed", ex.getMessage());
|
||||||
|
|
||||||
String bulkAction = copyToStringFromClasspath("/org/opensearch/action/bulk/simple-bulk5.json");
|
String bulkAction = copyToStringFromClasspath("/org/opensearch/action/bulk/simple-bulk5.json");
|
||||||
new BulkRequest().add(new BytesArray(bulkAction.getBytes(StandardCharsets.UTF_8)), "test", null, false, XContentType.JSON);
|
new BulkRequest().add(new BytesArray(bulkAction.getBytes(StandardCharsets.UTF_8)), "test", false, XContentType.JSON);
|
||||||
// This test's JSON contains outdated references to types
|
|
||||||
assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBulkAddIterable() {
|
public void testBulkAddIterable() {
|
||||||
|
@ -169,8 +159,6 @@ public class BulkRequestTests extends OpenSearchTestCase {
|
||||||
() -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON)
|
() -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON)
|
||||||
);
|
);
|
||||||
assertThat(exc.getMessage(), containsString("Unknown key for a VALUE_STRING in [hello]"));
|
assertThat(exc.getMessage(), containsString("Unknown key for a VALUE_STRING in [hello]"));
|
||||||
// This test's JSON contains outdated references to types
|
|
||||||
assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSimpleBulk7() throws Exception {
|
public void testSimpleBulk7() throws Exception {
|
||||||
|
@ -184,8 +172,6 @@ public class BulkRequestTests extends OpenSearchTestCase {
|
||||||
exc.getMessage(),
|
exc.getMessage(),
|
||||||
containsString("Malformed action/metadata line [5], expected a simple value for field [_unknown] but found [START_ARRAY]")
|
containsString("Malformed action/metadata line [5], expected a simple value for field [_unknown] but found [START_ARRAY]")
|
||||||
);
|
);
|
||||||
// This test's JSON contains outdated references to types
|
|
||||||
assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSimpleBulk8() throws Exception {
|
public void testSimpleBulk8() throws Exception {
|
||||||
|
@ -196,8 +182,6 @@ public class BulkRequestTests extends OpenSearchTestCase {
|
||||||
() -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON)
|
() -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON)
|
||||||
);
|
);
|
||||||
assertThat(exc.getMessage(), containsString("Action/metadata line [3] contains an unknown parameter [_foo]"));
|
assertThat(exc.getMessage(), containsString("Action/metadata line [3] contains an unknown parameter [_foo]"));
|
||||||
// This test's JSON contains outdated references to types
|
|
||||||
assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSimpleBulk9() throws Exception {
|
public void testSimpleBulk9() throws Exception {
|
||||||
|
@ -218,13 +202,10 @@ public class BulkRequestTests extends OpenSearchTestCase {
|
||||||
BulkRequest bulkRequest = new BulkRequest();
|
BulkRequest bulkRequest = new BulkRequest();
|
||||||
bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON);
|
bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON);
|
||||||
assertThat(bulkRequest.numberOfActions(), equalTo(9));
|
assertThat(bulkRequest.numberOfActions(), equalTo(9));
|
||||||
// This test's JSON contains outdated references to types
|
|
||||||
assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBulkActionShouldNotContainArray() throws Exception {
|
public void testBulkActionShouldNotContainArray() throws Exception {
|
||||||
String bulkAction = "{ \"index\":{\"_index\":[\"index1\", \"index2\"],\"_type\":\"type1\",\"_id\":\"1\"} }\r\n"
|
String bulkAction = "{ \"index\":{\"_index\":[\"index1\", \"index2\"],\"_id\":\"1\"} }\r\n" + "{ \"field1\" : \"value1\" }\r\n";
|
||||||
+ "{ \"field1\" : \"value1\" }\r\n";
|
|
||||||
BulkRequest bulkRequest = new BulkRequest();
|
BulkRequest bulkRequest = new BulkRequest();
|
||||||
IllegalArgumentException exc = expectThrows(
|
IllegalArgumentException exc = expectThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -318,7 +299,6 @@ public class BulkRequestTests extends OpenSearchTestCase {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
builder.startObject("index");
|
builder.startObject("index");
|
||||||
builder.field("_index", "index");
|
builder.field("_index", "index");
|
||||||
builder.field("_type", "type");
|
|
||||||
builder.field("_id", "test");
|
builder.field("_id", "test");
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
@ -334,19 +314,16 @@ public class BulkRequestTests extends OpenSearchTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
BulkRequest bulkRequest = new BulkRequest();
|
BulkRequest bulkRequest = new BulkRequest();
|
||||||
bulkRequest.add(data, null, null, xContentType);
|
bulkRequest.add(data, null, xContentType);
|
||||||
assertEquals(1, bulkRequest.requests().size());
|
assertEquals(1, bulkRequest.requests().size());
|
||||||
DocWriteRequest<?> docWriteRequest = bulkRequest.requests().get(0);
|
DocWriteRequest<?> docWriteRequest = bulkRequest.requests().get(0);
|
||||||
assertEquals(DocWriteRequest.OpType.INDEX, docWriteRequest.opType());
|
assertEquals(DocWriteRequest.OpType.INDEX, docWriteRequest.opType());
|
||||||
assertEquals("index", docWriteRequest.index());
|
assertEquals("index", docWriteRequest.index());
|
||||||
assertEquals("type", docWriteRequest.type());
|
|
||||||
assertEquals("test", docWriteRequest.id());
|
assertEquals("test", docWriteRequest.id());
|
||||||
assertThat(docWriteRequest, instanceOf(IndexRequest.class));
|
assertThat(docWriteRequest, instanceOf(IndexRequest.class));
|
||||||
IndexRequest request = (IndexRequest) docWriteRequest;
|
IndexRequest request = (IndexRequest) docWriteRequest;
|
||||||
assertEquals(1, request.sourceAsMap().size());
|
assertEquals(1, request.sourceAsMap().size());
|
||||||
assertEquals("value", request.sourceAsMap().get("field"));
|
assertEquals("value", request.sourceAsMap().get("field"));
|
||||||
// This test's content contains outdated references to types
|
|
||||||
assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testToValidateUpsertRequestAndCASInBulkRequest() throws IOException {
|
public void testToValidateUpsertRequestAndCASInBulkRequest() throws IOException {
|
||||||
|
@ -357,7 +334,6 @@ public class BulkRequestTests extends OpenSearchTestCase {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
builder.startObject("update");
|
builder.startObject("update");
|
||||||
builder.field("_index", "index");
|
builder.field("_index", "index");
|
||||||
builder.field("_type", "type");
|
|
||||||
builder.field("_id", "id");
|
builder.field("_id", "id");
|
||||||
builder.field("if_seq_no", 1L);
|
builder.field("if_seq_no", 1L);
|
||||||
builder.field("if_primary_term", 100L);
|
builder.field("if_primary_term", 100L);
|
||||||
|
@ -372,7 +348,6 @@ public class BulkRequestTests extends OpenSearchTestCase {
|
||||||
values.put("if_seq_no", 1L);
|
values.put("if_seq_no", 1L);
|
||||||
values.put("if_primary_term", 100L);
|
values.put("if_primary_term", 100L);
|
||||||
values.put("_index", "index");
|
values.put("_index", "index");
|
||||||
values.put("_type", "type");
|
|
||||||
builder.field("upsert", values);
|
builder.field("upsert", values);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
|
@ -380,10 +355,8 @@ public class BulkRequestTests extends OpenSearchTestCase {
|
||||||
data = out.bytes();
|
data = out.bytes();
|
||||||
}
|
}
|
||||||
BulkRequest bulkRequest = new BulkRequest();
|
BulkRequest bulkRequest = new BulkRequest();
|
||||||
bulkRequest.add(data, null, null, xContentType);
|
bulkRequest.add(data, null, xContentType);
|
||||||
assertThat(bulkRequest.validate().validationErrors(), contains("upsert requests don't support `if_seq_no` and `if_primary_term`"));
|
assertThat(bulkRequest.validate().validationErrors(), contains("upsert requests don't support `if_seq_no` and `if_primary_term`"));
|
||||||
// This test's JSON contains outdated references to types
|
|
||||||
assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBulkTerminatedByNewline() throws Exception {
|
public void testBulkTerminatedByNewline() throws Exception {
|
||||||
|
@ -404,7 +377,5 @@ public class BulkRequestTests extends OpenSearchTestCase {
|
||||||
XContentType.JSON
|
XContentType.JSON
|
||||||
);
|
);
|
||||||
assertEquals(3, bulkRequestWithNewLine.numberOfActions());
|
assertEquals(3, bulkRequestWithNewLine.numberOfActions());
|
||||||
// This test's JSON contains outdated references to types
|
|
||||||
assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,17 +86,16 @@ public class BulkResponseTests extends OpenSearchTestCase {
|
||||||
expectedBulkItems[i] = new BulkItemResponse(i, opType, randomDocWriteResponses.v2());
|
expectedBulkItems[i] = new BulkItemResponse(i, opType, randomDocWriteResponses.v2());
|
||||||
} else {
|
} else {
|
||||||
String index = randomAlphaOfLength(5);
|
String index = randomAlphaOfLength(5);
|
||||||
String type = randomAlphaOfLength(5);
|
|
||||||
String id = randomAlphaOfLength(5);
|
String id = randomAlphaOfLength(5);
|
||||||
|
|
||||||
Tuple<Throwable, OpenSearchException> failures = randomExceptions();
|
Tuple<Throwable, OpenSearchException> failures = randomExceptions();
|
||||||
|
|
||||||
Exception bulkItemCause = (Exception) failures.v1();
|
Exception bulkItemCause = (Exception) failures.v1();
|
||||||
bulkItems[i] = new BulkItemResponse(i, opType, new BulkItemResponse.Failure(index, type, id, bulkItemCause));
|
bulkItems[i] = new BulkItemResponse(i, opType, new BulkItemResponse.Failure(index, id, bulkItemCause));
|
||||||
expectedBulkItems[i] = new BulkItemResponse(
|
expectedBulkItems[i] = new BulkItemResponse(
|
||||||
i,
|
i,
|
||||||
opType,
|
opType,
|
||||||
new BulkItemResponse.Failure(index, type, id, failures.v2(), ExceptionsHelper.status(bulkItemCause))
|
new BulkItemResponse.Failure(index, id, failures.v2(), ExceptionsHelper.status(bulkItemCause))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,7 +249,7 @@ public class RetryTests extends OpenSearchTestCase {
|
||||||
return new BulkItemResponse(
|
return new BulkItemResponse(
|
||||||
1,
|
1,
|
||||||
OpType.INDEX,
|
OpType.INDEX,
|
||||||
new BulkItemResponse.Failure("test", "test", "1", new OpenSearchRejectedExecutionException("pool full"))
|
new BulkItemResponse.Failure("test", "1", new OpenSearchRejectedExecutionException("pool full"))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,6 @@ import org.opensearch.common.util.concurrent.ThreadContext;
|
||||||
import org.opensearch.common.xcontent.XContentType;
|
import org.opensearch.common.xcontent.XContentType;
|
||||||
import org.opensearch.index.IndexNotFoundException;
|
import org.opensearch.index.IndexNotFoundException;
|
||||||
import org.opensearch.index.IndexingPressureService;
|
import org.opensearch.index.IndexingPressureService;
|
||||||
import org.opensearch.rest.action.document.RestBulkAction;
|
|
||||||
import org.opensearch.indices.SystemIndices;
|
import org.opensearch.indices.SystemIndices;
|
||||||
import org.opensearch.tasks.Task;
|
import org.opensearch.tasks.Task;
|
||||||
import org.opensearch.test.OpenSearchTestCase;
|
import org.opensearch.test.OpenSearchTestCase;
|
||||||
|
@ -242,8 +241,6 @@ public class TransportBulkActionTookTests extends OpenSearchTestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// This test's JSON contains outdated references to types
|
|
||||||
assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Resolver extends IndexNameExpressionResolver {
|
static class Resolver extends IndexNameExpressionResolver {
|
||||||
|
|
|
@ -186,7 +186,6 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
||||||
|
|
||||||
BulkItemResponse.Failure failure = primaryResponse.getFailure();
|
BulkItemResponse.Failure failure = primaryResponse.getFailure();
|
||||||
assertThat(failure.getIndex(), equalTo("index"));
|
assertThat(failure.getIndex(), equalTo("index"));
|
||||||
assertThat(failure.getType(), equalTo("_doc"));
|
|
||||||
assertThat(failure.getId(), equalTo("id"));
|
assertThat(failure.getId(), equalTo("id"));
|
||||||
assertThat(failure.getCause().getClass(), equalTo(VersionConflictEngineException.class));
|
assertThat(failure.getCause().getClass(), equalTo(VersionConflictEngineException.class));
|
||||||
assertThat(failure.getCause().getMessage(), containsString("version conflict, document already exists (current version [1])"));
|
assertThat(failure.getCause().getMessage(), containsString("version conflict, document already exists (current version [1])"));
|
||||||
|
@ -236,7 +235,6 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
||||||
BulkItemResponse response = result.finalResponseIfSuccessful.getResponses()[i];
|
BulkItemResponse response = result.finalResponseIfSuccessful.getResponses()[i];
|
||||||
assertThat(response.getItemId(), equalTo(i));
|
assertThat(response.getItemId(), equalTo(i));
|
||||||
assertThat(response.getIndex(), equalTo("index"));
|
assertThat(response.getIndex(), equalTo("index"));
|
||||||
assertThat(response.getType(), equalTo("_doc"));
|
|
||||||
assertThat(response.getId(), equalTo("id_" + i));
|
assertThat(response.getId(), equalTo("id_" + i));
|
||||||
assertThat(response.getOpType(), equalTo(DocWriteRequest.OpType.INDEX));
|
assertThat(response.getOpType(), equalTo(DocWriteRequest.OpType.INDEX));
|
||||||
if (response.getItemId() == rejectItem.id()) {
|
if (response.getItemId() == rejectItem.id()) {
|
||||||
|
@ -394,7 +392,6 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
||||||
assertThat(primaryResponse.getFailureMessage(), containsString("some kind of exception"));
|
assertThat(primaryResponse.getFailureMessage(), containsString("some kind of exception"));
|
||||||
BulkItemResponse.Failure failure = primaryResponse.getFailure();
|
BulkItemResponse.Failure failure = primaryResponse.getFailure();
|
||||||
assertThat(failure.getIndex(), equalTo("index"));
|
assertThat(failure.getIndex(), equalTo("index"));
|
||||||
assertThat(failure.getType(), equalTo("_doc"));
|
|
||||||
assertThat(failure.getId(), equalTo("id"));
|
assertThat(failure.getId(), equalTo("id"));
|
||||||
assertThat(failure.getCause(), equalTo(err));
|
assertThat(failure.getCause(), equalTo(err));
|
||||||
|
|
||||||
|
@ -610,7 +607,6 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
||||||
assertThat(primaryResponse.getFailureMessage(), containsString("I'm dead <(x.x)>"));
|
assertThat(primaryResponse.getFailureMessage(), containsString("I'm dead <(x.x)>"));
|
||||||
BulkItemResponse.Failure failure = primaryResponse.getFailure();
|
BulkItemResponse.Failure failure = primaryResponse.getFailure();
|
||||||
assertThat(failure.getIndex(), equalTo("index"));
|
assertThat(failure.getIndex(), equalTo("index"));
|
||||||
assertThat(failure.getType(), equalTo("_doc"));
|
|
||||||
assertThat(failure.getId(), equalTo("id"));
|
assertThat(failure.getId(), equalTo("id"));
|
||||||
assertThat(failure.getCause(), equalTo(err));
|
assertThat(failure.getCause(), equalTo(err));
|
||||||
assertThat(failure.getStatus(), equalTo(RestStatus.INTERNAL_SERVER_ERROR));
|
assertThat(failure.getStatus(), equalTo(RestStatus.INTERNAL_SERVER_ERROR));
|
||||||
|
@ -670,7 +666,6 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
||||||
assertThat(primaryResponse.getFailureMessage(), containsString("I'm conflicted <(;_;)>"));
|
assertThat(primaryResponse.getFailureMessage(), containsString("I'm conflicted <(;_;)>"));
|
||||||
BulkItemResponse.Failure failure = primaryResponse.getFailure();
|
BulkItemResponse.Failure failure = primaryResponse.getFailure();
|
||||||
assertThat(failure.getIndex(), equalTo("index"));
|
assertThat(failure.getIndex(), equalTo("index"));
|
||||||
assertThat(failure.getType(), equalTo("_doc"));
|
|
||||||
assertThat(failure.getId(), equalTo("id"));
|
assertThat(failure.getId(), equalTo("id"));
|
||||||
assertThat(failure.getCause(), equalTo(err));
|
assertThat(failure.getCause(), equalTo(err));
|
||||||
assertThat(failure.getStatus(), equalTo(RestStatus.CONFLICT));
|
assertThat(failure.getStatus(), equalTo(RestStatus.CONFLICT));
|
||||||
|
@ -833,7 +828,6 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
||||||
assertThat(primaryResponse.getFailureMessage(), containsString("oops"));
|
assertThat(primaryResponse.getFailureMessage(), containsString("oops"));
|
||||||
BulkItemResponse.Failure failure = primaryResponse.getFailure();
|
BulkItemResponse.Failure failure = primaryResponse.getFailure();
|
||||||
assertThat(failure.getIndex(), equalTo("index"));
|
assertThat(failure.getIndex(), equalTo("index"));
|
||||||
assertThat(failure.getType(), equalTo("_doc"));
|
|
||||||
assertThat(failure.getId(), equalTo("id"));
|
assertThat(failure.getId(), equalTo("id"));
|
||||||
assertThat(failure.getCause(), equalTo(err));
|
assertThat(failure.getCause(), equalTo(err));
|
||||||
assertThat(failure.getStatus(), equalTo(RestStatus.INTERNAL_SERVER_ERROR));
|
assertThat(failure.getStatus(), equalTo(RestStatus.INTERNAL_SERVER_ERROR));
|
||||||
|
@ -888,7 +882,7 @@ public class TransportShardBulkActionTests extends IndexShardTestCase {
|
||||||
new BulkItemResponse(
|
new BulkItemResponse(
|
||||||
0,
|
0,
|
||||||
randomFrom(DocWriteRequest.OpType.CREATE, DocWriteRequest.OpType.DELETE, DocWriteRequest.OpType.INDEX),
|
randomFrom(DocWriteRequest.OpType.CREATE, DocWriteRequest.OpType.DELETE, DocWriteRequest.OpType.INDEX),
|
||||||
new BulkItemResponse.Failure("index", "_doc", "1", exception, 1L, 1L)
|
new BulkItemResponse.Failure("index", "1", exception, 1L, 1L)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
BulkItemRequest[] itemRequests = new BulkItemRequest[1];
|
BulkItemRequest[] itemRequests = new BulkItemRequest[1];
|
||||||
|
|
|
@ -81,14 +81,7 @@ public class BulkByScrollResponseTests extends AbstractXContentTestCase<BulkBySc
|
||||||
private List<Failure> randomIndexingFailures() {
|
private List<Failure> randomIndexingFailures() {
|
||||||
return usually()
|
return usually()
|
||||||
? emptyList()
|
? emptyList()
|
||||||
: singletonList(
|
: singletonList(new Failure(randomSimpleString(random()), randomSimpleString(random()), new IllegalArgumentException("test")));
|
||||||
new Failure(
|
|
||||||
randomSimpleString(random()),
|
|
||||||
randomSimpleString(random()),
|
|
||||||
randomSimpleString(random()),
|
|
||||||
new IllegalArgumentException("test")
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ScrollableHitSource.SearchFailure> randomSearchFailures() {
|
private List<ScrollableHitSource.SearchFailure> randomSearchFailures() {
|
||||||
|
@ -119,7 +112,6 @@ public class BulkByScrollResponseTests extends AbstractXContentTestCase<BulkBySc
|
||||||
Failure expectedFailure = expected.getBulkFailures().get(i);
|
Failure expectedFailure = expected.getBulkFailures().get(i);
|
||||||
Failure actualFailure = actual.getBulkFailures().get(i);
|
Failure actualFailure = actual.getBulkFailures().get(i);
|
||||||
assertEquals(expectedFailure.getIndex(), actualFailure.getIndex());
|
assertEquals(expectedFailure.getIndex(), actualFailure.getIndex());
|
||||||
assertEquals(expectedFailure.getType(), actualFailure.getType());
|
|
||||||
assertEquals(expectedFailure.getId(), actualFailure.getId());
|
assertEquals(expectedFailure.getId(), actualFailure.getId());
|
||||||
assertEquals(expectedFailure.getMessage(), actualFailure.getMessage());
|
assertEquals(expectedFailure.getMessage(), actualFailure.getMessage());
|
||||||
assertEquals(expectedFailure.getStatus(), actualFailure.getStatus());
|
assertEquals(expectedFailure.getStatus(), actualFailure.getStatus());
|
||||||
|
@ -150,7 +142,6 @@ public class BulkByScrollResponseTests extends AbstractXContentTestCase<BulkBySc
|
||||||
Failure expectedFailure = expected.getBulkFailures().get(i);
|
Failure expectedFailure = expected.getBulkFailures().get(i);
|
||||||
Failure actualFailure = actual.getBulkFailures().get(i);
|
Failure actualFailure = actual.getBulkFailures().get(i);
|
||||||
assertEquals(expectedFailure.getIndex(), actualFailure.getIndex());
|
assertEquals(expectedFailure.getIndex(), actualFailure.getIndex());
|
||||||
assertEquals(expectedFailure.getType(), actualFailure.getType());
|
|
||||||
assertEquals(expectedFailure.getId(), actualFailure.getId());
|
assertEquals(expectedFailure.getId(), actualFailure.getId());
|
||||||
assertEquals(expectedFailure.getStatus(), actualFailure.getStatus());
|
assertEquals(expectedFailure.getStatus(), actualFailure.getStatus());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
{"index":{"_index":"logstash-2014.03.30","_type":"logs"}}
|
{"index":{"_index":"logstash-2014.03.30"}}
|
||||||
{"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
{"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
||||||
{"index":{"_index":"logstash-2014.03.30","_type":"logs"}}
|
{"index":{"_index":"logstash-2014.03.30"}}
|
||||||
{"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
{"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
||||||
{"index":{"_index":"logstash-2014.03.30","_type":"logs"}}
|
{"index":{"_index":"logstash-2014.03.30"}}
|
||||||
{"message":"in24.inetnebr.com--[01/Aug2/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
{"message":"in24.inetnebr.com--[01/Aug2/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
||||||
{"index":{"_index":"logstash-2014.03.30","_type":"logs"}}
|
{"index":{"_index":"logstash-2014.03.30"}}
|
||||||
{"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
{"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
||||||
{"index":{"_index":"logstash-2014.03.30","_type":"logs"}}
|
{"index":{"_index":"logstash-2014.03.30"}}
|
||||||
{"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
{"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
||||||
{"index":{"_index":"logstash-2014.03.30","_type":"logs"}}
|
{"index":{"_index":"logstash-2014.03.30"}}
|
||||||
{"message":"in24.inetnebr.com--[01/Aug2/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
{"message":"in24.inetnebr.com--[01/Aug2/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
||||||
{"index":{"_index":"logstash-2014.03.30","_type":"logs"}}
|
{"index":{"_index":"logstash-2014.03.30"}}
|
||||||
{"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
{"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
||||||
{"index":{"_index":"logstash-2014.03.30","_type":"logs"}}
|
{"index":{"_index":"logstash-2014.03.30"}}
|
||||||
{"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
{"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
||||||
{"index":{"_index":"logstash-2014.03.30","_type":"logs"}}
|
{"index":{"_index":"logstash-2014.03.30"}}
|
||||||
{"message":"in24.inetnebr.com--[01/Aug2/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
{"message":"in24.inetnebr.com--[01/Aug2/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
||||||
{"index":{"_index":"logstash-2014.03.30","_type":"logs"}}
|
{"index":{"_index":"logstash-2014.03.30"}}
|
||||||
{"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
{"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
||||||
{"index":{"_index":"logstash-2014.03.30","_type":"logs"}}
|
{"index":{"_index":"logstash-2014.03.30"}}
|
||||||
{"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
{"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
||||||
{"index":{"_index":"logstash-2014.03.30","_type":"logs"}}
|
{"index":{"_index":"logstash-2014.03.30"}}
|
||||||
{"message":"in24.inetnebr.com--[01/Aug2/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
{"message":"in24.inetnebr.com--[01/Aug2/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{ "index":{"_index":"test","_type":"type1","_id":"1"} }
|
{ "index":{"_index":"test","_id":"1"} }
|
||||||
{ "field1" : "value1" }
|
{ "field1" : "value1" }
|
||||||
{ "delete" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }
|
{ "delete" : { "_index" : "test", "_id" : "2" } }
|
||||||
{ "create" : { "_index" : "test", "_type" : "type1", "_id" : "3" } }
|
{ "create" : { "_index" : "test", "_id" : "3" } }
|
||||||
{ "field1" : "value3" }
|
{ "field1" : "value3" }
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
{ "index" : {"_index":null, "_type":"type1", "_id":"0"} }
|
{ "index" : {"_index":null, "_id":"0"} }
|
||||||
{ "field1" : "value1" }
|
{ "field1" : "value1" }
|
||||||
{ "index" : {"_index":"test", "_type":null, "_id":"0"} }
|
{ "index" : {"_index":"test", "_id":"0"} }
|
||||||
{ "field1" : "value1" }
|
{ "field1" : "value1" }
|
||||||
{ "index" : {"_index":"test", "_type":"type1", "_id":null} }
|
{ "index" : {"_index":"test", "_id":null} }
|
||||||
{ "field1" : "value1" }
|
{ "field1" : "value1" }
|
||||||
{ "delete" : {"_index":null, "_type":"type1", "_id":"0"} }
|
{ "delete" : {"_index":null, "_id":"0"} }
|
||||||
{ "delete" : {"_index":"test", "_type":null, "_id":"0"} }
|
{ "delete" : {"_index":"test", "_id":"0"} }
|
||||||
{ "delete" : {"_index":"test", "_type":"type1", "_id":null} }
|
{ "delete" : {"_index":"test", "_id":null} }
|
||||||
{ "create" : {"_index":null, "_type":"type1", "_id":"0"} }
|
{ "create" : {"_index":null, "_id":"0"} }
|
||||||
{ "field1" : "value1" }
|
{ "field1" : "value1" }
|
||||||
{ "create" : {"_index":"test", "_type":null, "_id":"0"} }
|
{ "create" : {"_index":"test", "_id":"0"} }
|
||||||
{ "field1" : "value1" }
|
{ "field1" : "value1" }
|
||||||
{ "create" : {"_index":"test", "_type":"type1", "_id":null} }
|
{ "create" : {"_index":"test", "_id":null} }
|
||||||
{ "field1" : "value1" }
|
{ "field1" : "value1" }
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{ "index":{"_index":"test","_type":"type1","_id":"1"} }
|
{ "index":{"_index":"test","_id":"1"} }
|
||||||
{ "field1" : "value1" }
|
{ "field1" : "value1" }
|
||||||
{ "delete" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }
|
{ "delete" : { "_index" : "test", "_id" : "2" } }
|
||||||
{ "create" : { "_index" : "test", "_type" : "type1", "_id" : "3" } }
|
{ "create" : { "_index" : "test", "_id" : "3" } }
|
||||||
{ "field1" : "value3" }
|
{ "field1" : "value3" }
|
|
@ -1,6 +1,6 @@
|
||||||
{ "update" : {"_id" : "1", "retry_on_conflict" : 2} }
|
{ "update" : {"_id" : "1", "retry_on_conflict" : 2} }
|
||||||
{ "doc" : {"field" : "value"} }
|
{ "doc" : {"field" : "value"} }
|
||||||
{ "update" : { "_id" : "0", "_type" : "type1", "_index" : "index1" } }
|
{ "update" : { "_id" : "0", "_index" : "index1" } }
|
||||||
{ "script" : { "source" : "counter += param1", "lang" : "javascript", "params" : {"param1" : 1}}, "upsert" : {"counter" : 1}}
|
{ "script" : { "source" : "counter += param1", "lang" : "javascript", "params" : {"param1" : 1}}, "upsert" : {"counter" : 1}}
|
||||||
{ "delete" : { "_id" : "2" } }
|
{ "delete" : { "_id" : "2" } }
|
||||||
{ "create" : { "_id" : "3" } }
|
{ "create" : { "_id" : "3" } }
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{ "index": {"_type": "type1","_id": "1"} }
|
{ "index": { "_id": "1"} }
|
||||||
{ "field1" : "value1" }
|
{ "field1" : "value1" }
|
||||||
{ "delete" : { "_type" : "type1", "_id" : "2" } }
|
{ "delete" : { "_id" : "2" } }
|
||||||
{ "create" : { "_type" : "type1", "_id" : "3" } }
|
{ "create" : { "_id" : "3" } }
|
||||||
{ "field1" : "value3" }
|
{ "field1" : "value3" }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{"index": {"_index": "test", "_type": "doc", "_source": {"hello": "world"}, "_id": 0}}
|
{"index": {"_index": "test", "_source": {"hello": "world"}, "_id": 0}}
|
||||||
{"field1": "value0"}
|
{"field1": "value0"}
|
||||||
{"index": {"_index": "test", "_type": "doc", "_id": 1}}
|
{"index": {"_index": "test", "_id": 1}}
|
||||||
{"field1": "value1"}
|
{"field1": "value1"}
|
||||||
{"index": {"_index": "test", "_type": "doc", "_id": 2}}
|
{"index": {"_index": "test", "_id": 2}}
|
||||||
{"field1": "value2"}
|
{"field1": "value2"}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{"index": {"_index": "test", "_type": "doc", "_id": 0}}
|
{"index": {"_index": "test", "_id": 0}}
|
||||||
{"field1": "value0"}
|
{"field1": "value0"}
|
||||||
{"index": {"_index": "test", "_type": "doc", "_id": 1}}
|
{"index": {"_index": "test", "_id": 1}}
|
||||||
{"field1": "value1"}
|
{"field1": "value1"}
|
||||||
{"index": {"_index": "test", "_type": "doc", "_id": 2, "_unknown": ["foo", "bar"]}}
|
{"index": {"_index": "test", "_id": 2, "_unknown": ["foo", "bar"]}}
|
||||||
{"field1": "value2"}
|
{"field1": "value2"}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{"index": {"_index": "test", "_type": "doc", "_id": 0}}
|
{"index": {"_index": "test", "_id": 0}}
|
||||||
{"field1": "value0"}
|
{"field1": "value0"}
|
||||||
{"index": {"_index": "test", "_type": "doc", "_id": 1, "_foo": "bar"}}
|
{"index": {"_index": "test", "_id": 1, "_foo": "bar"}}
|
||||||
{"field1": "value1"}
|
{"field1": "value1"}
|
||||||
{"index": {"_index": "test", "_type": "doc", "_id": 2}}
|
{"index": {"_index": "test", "_id": 2}}
|
||||||
{"field1": "value2"}
|
{"field1": "value2"}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue