Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove type field from DocWriteRequest and associated Response objects #47671

Merged
merged 43 commits into from
Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
94d7e14
Remove types from bulk request
romseygeek Sep 23, 2019
b6f94f7
Merge remote-tracking branch 'origin/master' into types-removal/bulk-…
romseygeek Sep 23, 2019
1f538a3
tests
romseygeek Sep 23, 2019
748d1f6
tests
romseygeek Sep 23, 2019
9ba9c59
tests
romseygeek Sep 23, 2019
e63d109
tests
romseygeek Sep 24, 2019
f03a740
compilation; remove type from BulkResponse.Failure
romseygeek Sep 24, 2019
e8d9158
tests
romseygeek Sep 25, 2019
daee751
bulk monitoring
romseygeek Sep 25, 2019
842ecfd
imports
romseygeek Sep 25, 2019
d47c63a
Merge remote-tracking branch 'origin/master' into types-removal/bulk-…
romseygeek Sep 25, 2019
45c6f5e
bulk tests
romseygeek Sep 25, 2019
100019d
tests
romseygeek Sep 25, 2019
fdabe48
monitoring again
romseygeek Sep 25, 2019
9779d9b
sake
romseygeek Sep 25, 2019
4345c6a
yaml test
romseygeek Sep 26, 2019
946c313
assertions
romseygeek Sep 26, 2019
5c2950f
yaml test
romseygeek Sep 26, 2019
ca03935
wtf
romseygeek Sep 26, 2019
7863b64
Merge branch 'master' into types-removal/bulk-request-action
romseygeek Sep 26, 2019
9baf0f5
relax assertion
romseygeek Sep 26, 2019
3b13ca2
Merge remote-tracking branch 'romseygeek/types-removal/bulk-request-a…
romseygeek Sep 26, 2019
db1e223
Remove types from DocWriteRequest/IndexResponse
romseygeek Sep 26, 2019
219504f
Merge remote-tracking branch 'origin/master' into types-removal/doc-w…
romseygeek Oct 7, 2019
d5d878f
tests
romseygeek Oct 7, 2019
d280f75
test failures
romseygeek Oct 7, 2019
25a5bf4
imports
romseygeek Oct 7, 2019
b724b44
rest handler
romseygeek Oct 7, 2019
b0a0687
Merge remote-tracking branch 'origin/master' into types-removal/doc-w…
romseygeek Oct 7, 2019
9b97d95
Workaround for weird SLM failure
romseygeek Oct 8, 2019
1ab2ac1
tests
romseygeek Oct 8, 2019
64abbcc
tests
romseygeek Oct 8, 2019
4a61b4b
tests
romseygeek Oct 8, 2019
55fb4c4
Merge remote-tracking branch 'origin/master' into types-removal/doc-w…
romseygeek Oct 8, 2019
d34189f
bats
romseygeek Oct 8, 2019
75d3c8e
tests
romseygeek Oct 8, 2019
9e2d404
tests
romseygeek Oct 8, 2019
3777f10
tests
romseygeek Oct 8, 2019
e92fd44
more tests
romseygeek Oct 9, 2019
a99a0de
watcher tests
romseygeek Oct 9, 2019
ef2aa73
Merge remote-tracking branch 'origin/master' into types-removal/doc-w…
romseygeek Oct 10, 2019
ed1f3fd
Only need to check for 400 now
romseygeek Oct 10, 2019
ffdfa0e
Revert "Only need to check for 400 now"
romseygeek Oct 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC

private static class BulkRestBuilderListener extends RestBuilderListener<BulkRequest> {
private final BulkItemResponse ITEM_RESPONSE = new BulkItemResponse(1, DocWriteRequest.OpType.UPDATE,
new UpdateResponse(new ShardId("mock", "", 1), "mock_type", "1", 0L, 1L, 1L, DocWriteResponse.Result.CREATED));
new UpdateResponse(new ShardId("mock", "", 1), "1", 0L, 1L, 1L, DocWriteResponse.Result.CREATED));

private final RestRequest request;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

public class TransportNoopBulkAction extends HandledTransportAction<BulkRequest, BulkResponse> {
private static final BulkItemResponse ITEM_RESPONSE = new BulkItemResponse(1, DocWriteRequest.OpType.UPDATE,
new UpdateResponse(new ShardId("mock", "", 1), "mock_type", "1", 0L, 1L, 1L, DocWriteResponse.Result.CREATED));
new UpdateResponse(new ShardId("mock", "", 1), "1", 0L, 1L, 1L, DocWriteResponse.Result.CREATED));

@Inject
public TransportNoopBulkAction(TransportService transportService, ActionFilters actionFilters) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.rankeval.RankEvalRequest;
import org.elasticsearch.index.reindex.AbstractBulkByScrollRequest;
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
Expand Down Expand Up @@ -102,7 +101,7 @@ private RequestConverters() {
}

static Request delete(DeleteRequest deleteRequest) {
String endpoint = endpoint(deleteRequest.index(), deleteRequest.type(), deleteRequest.id());
String endpoint = endpoint(deleteRequest.index(), deleteRequest.id());
Request request = new Request(HttpDelete.METHOD_NAME, endpoint);

Params parameters = new Params();
Expand Down Expand Up @@ -170,11 +169,6 @@ static Request bulk(BulkRequest bulkRequest) throws IOException {
if (Strings.hasLength(action.index())) {
metadata.field("_index", action.index());
}
if (Strings.hasLength(action.type())) {
if (MapperService.SINGLE_MAPPING_NAME.equals(action.type()) == false) {
metadata.field("_type", action.type());
}
}
if (Strings.hasLength(action.id())) {
metadata.field("_id", action.id());
}
Expand Down Expand Up @@ -309,11 +303,9 @@ static Request index(IndexRequest indexRequest) {

String endpoint;
if (indexRequest.opType() == DocWriteRequest.OpType.CREATE) {
endpoint = indexRequest.type().equals(MapperService.SINGLE_MAPPING_NAME)
? endpoint(indexRequest.index(), "_create", indexRequest.id())
: endpoint(indexRequest.index(), indexRequest.type(), indexRequest.id(), "_create");
endpoint = endpoint(indexRequest.index(), "_create", indexRequest.id());
} else {
endpoint = endpoint(indexRequest.index(), indexRequest.type(), indexRequest.id());
endpoint = endpoint(indexRequest.index(), indexRequest.id());
}

Request request = new Request(method, endpoint);
Expand Down Expand Up @@ -341,9 +333,7 @@ static Request ping() {
}

static Request update(UpdateRequest updateRequest) throws IOException {
String endpoint = updateRequest.type().equals(MapperService.SINGLE_MAPPING_NAME)
? endpoint(updateRequest.index(), "_update", updateRequest.id())
: endpoint(updateRequest.index(), updateRequest.type(), updateRequest.id(), "_update");
String endpoint = endpoint(updateRequest.index(), "_update", updateRequest.id());
Request request = new Request(HttpPost.METHOD_NAME, endpoint);

Params parameters = new Params();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,6 @@ public void testGlobalParametersAndBulkProcessor() throws Exception {
{
final CountDownLatch latch = new CountDownLatch(1);
BulkProcessorTestListener listener = new BulkProcessorTestListener(latch);
//Check that untyped document additions inherit the global type
String localType = null;
try (BulkProcessor processor = initBulkProcessorBuilder(listener)
//let's make sure that the bulk action limit trips, one single execution will index all the documents
.setConcurrentRequests(randomIntBetween(0, 1)).setBulkActions(numDocs)
Expand All @@ -331,7 +329,7 @@ public void testGlobalParametersAndBulkProcessor() throws Exception {
.setGlobalPipeline("pipeline_id")
.build()) {

indexDocs(processor, numDocs, null, localType, "test", "pipeline_id");
indexDocs(processor, numDocs, null, "test", "pipeline_id");
latch.await();

assertThat(listener.beforeCounts.get(), equalTo(1));
Expand All @@ -356,33 +354,29 @@ private Matcher<SearchHit>[] expectedIds(int numDocs) {
.<Matcher<SearchHit>>toArray(Matcher[]::new);
}

private MultiGetRequest indexDocs(BulkProcessor processor, int numDocs, String localIndex, String localType,
private MultiGetRequest indexDocs(BulkProcessor processor, int numDocs, String localIndex,
String globalIndex, String globalPipeline) throws Exception {
MultiGetRequest multiGetRequest = new MultiGetRequest();
for (int i = 1; i <= numDocs; i++) {
if (randomBoolean()) {
processor.add(new IndexRequest(localIndex, localType, Integer.toString(i))
processor.add(new IndexRequest(localIndex).id(Integer.toString(i))
.source(XContentType.JSON, "field", randomRealisticUnicodeOfLengthBetween(1, 30)));
} else {
BytesArray data = bytesBulkRequest(localIndex, localType, i);
BytesArray data = bytesBulkRequest(localIndex, i);
processor.add(data, globalIndex, globalPipeline, XContentType.JSON);
}
multiGetRequest.add(localIndex, Integer.toString(i));
}
return multiGetRequest;
}

private static BytesArray bytesBulkRequest(String localIndex, String localType, int id) throws IOException {
private static BytesArray bytesBulkRequest(String localIndex, int id) throws IOException {
XContentBuilder action = jsonBuilder().startObject().startObject("index");

if (localIndex != null) {
action.field("_index", localIndex);
}

if (localType != null) {
action.field("_type", localType);
}

action.field("_id", Integer.toString(id));
action.endObject().endObject();

Expand All @@ -396,7 +390,7 @@ private static BytesArray bytesBulkRequest(String localIndex, String localType,
}

private MultiGetRequest indexDocs(BulkProcessor processor, int numDocs) throws Exception {
return indexDocs(processor, numDocs, "test", null, null, null);
return indexDocs(processor, numDocs, "test", null, null);
}

private static void assertResponseItems(List<BulkItemResponse> bulkItemResponses, int numDocs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void testIndexFollowing() throws Exception {
assertThat(putFollowResponse.isFollowIndexShardsAcked(), is(true));
assertThat(putFollowResponse.isIndexFollowingStarted(), is(true));

IndexRequest indexRequest = new IndexRequest("leader", "_doc")
IndexRequest indexRequest = new IndexRequest("leader")
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
.source("{}", XContentType.JSON);
highLevelClient().index(indexRequest, RequestOptions.DEFAULT);
Expand Down
Loading