Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -266,7 +266,7 @@ static Request get(GetRequest getRequest) {
}

private static Request getStyleRequest(String method, GetRequest getRequest) {
Request request = new Request(method, endpoint(getRequest.index(), getRequest.type(), getRequest.id()));
Request request = new Request(method, endpoint(getRequest.index(), getRequest.id()));

Params parameters = new Params();
parameters.withPreference(getRequest.preference());
Expand All @@ -282,13 +282,7 @@ private static Request getStyleRequest(String method, GetRequest getRequest) {
}

static Request sourceExists(GetRequest getRequest) {
String optionalType = getRequest.type();
String endpoint;
if (optionalType.equals(MapperService.SINGLE_MAPPING_NAME)) {
endpoint = endpoint(getRequest.index(), "_source", getRequest.id());
} else {
endpoint = endpoint(getRequest.index(), optionalType, getRequest.id(), "_source");
}
String endpoint = endpoint(getRequest.index(), "_source", getRequest.id());
Request request = new Request(HttpHead.METHOD_NAME, endpoint);
Params parameters = new Params();
parameters.withPreference(getRequest.preference());
Expand Down Expand Up @@ -742,6 +736,10 @@ static String endpoint(String index, String type, String id) {
return new EndpointBuilder().addPathPart(index, type, id).build();
}

static String endpoint(String index, String id) {
return new EndpointBuilder().addPathPart(index, "_doc", id).build();
}

@Deprecated
static String endpoint(String index, String type, String id, String endpoint) {
return new EndpointBuilder().addPathPart(index, type, id).addPathPartAsIs(endpoint).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,11 +483,11 @@ 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, null);
}

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));
int i = 1;
Expand All @@ -505,7 +505,6 @@ private static void assertMultiGetResponse(MultiGetResponse multiGetResponse, in
int i = 1;
for (MultiGetItemResponse multiGetItemResponse : multiGetResponse) {
assertThat(multiGetItemResponse.getIndex(), equalTo("test"));
assertThat(multiGetItemResponse.getType(), equalTo("_doc"));
assertThat(multiGetItemResponse.getId(), equalTo(Integer.toString(i++)));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.rest.action.document.RestBulkAction;
import org.elasticsearch.rest.action.document.RestDeleteAction;
import org.elasticsearch.rest.action.document.RestGetAction;
import org.elasticsearch.rest.action.document.RestIndexAction;
import org.elasticsearch.rest.action.document.RestMultiGetAction;
import org.elasticsearch.rest.action.document.RestUpdateAction;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptType;
Expand Down Expand Up @@ -293,7 +291,6 @@ public void testGet() throws IOException {
}
GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync);
assertEquals("index", getResponse.getIndex());
assertEquals("_doc", getResponse.getType());
assertEquals("id", getResponse.getId());
assertTrue(getResponse.isExists());
assertFalse(getResponse.isSourceEmpty());
Expand All @@ -304,7 +301,6 @@ public void testGet() throws IOException {
GetRequest getRequest = new GetRequest("index", "does_not_exist");
GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync);
assertEquals("index", getResponse.getIndex());
assertEquals("_doc", getResponse.getType());
assertEquals("does_not_exist", getResponse.getId());
assertFalse(getResponse.isExists());
assertEquals(-1, getResponse.getVersion());
Expand All @@ -316,7 +312,6 @@ public void testGet() throws IOException {
getRequest.fetchSourceContext(new FetchSourceContext(false, Strings.EMPTY_ARRAY, Strings.EMPTY_ARRAY));
GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync);
assertEquals("index", getResponse.getIndex());
assertEquals("_doc", getResponse.getType());
assertEquals("id", getResponse.getId());
assertTrue(getResponse.isExists());
assertTrue(getResponse.isSourceEmpty());
Expand All @@ -332,7 +327,6 @@ public void testGet() throws IOException {
}
GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync);
assertEquals("index", getResponse.getIndex());
assertEquals("_doc", getResponse.getType());
assertEquals("id", getResponse.getId());
assertTrue(getResponse.isExists());
assertFalse(getResponse.isSourceEmpty());
Expand All @@ -353,21 +347,6 @@ public void testGetWithTypes() throws IOException {
highLevelClient()::indexAsync,
expectWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE)
);

GetRequest getRequest = new GetRequest("index", "type", "id");
GetResponse getResponse = execute(getRequest,
highLevelClient()::get,
highLevelClient()::getAsync,
expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE));

assertEquals("index", getResponse.getIndex());
assertEquals("type", getResponse.getType());
assertEquals("id", getResponse.getId());

assertTrue(getResponse.isExists());
assertFalse(getResponse.isSourceEmpty());
assertEquals(1L, getResponse.getVersion());
assertEquals(document, getResponse.getSourceAsString());
}

public void testMultiGet() throws IOException {
Expand All @@ -381,15 +360,13 @@ public void testMultiGet() throws IOException {
assertTrue(response.getResponses()[0].isFailed());
assertNull(response.getResponses()[0].getResponse());
assertEquals("id1", response.getResponses()[0].getFailure().getId());
assertNull(response.getResponses()[0].getFailure().getType());
assertEquals("index", response.getResponses()[0].getFailure().getIndex());
assertEquals("Elasticsearch exception [type=index_not_found_exception, reason=no such index [index]]",
response.getResponses()[0].getFailure().getFailure().getMessage());

assertTrue(response.getResponses()[1].isFailed());
assertNull(response.getResponses()[1].getResponse());
assertEquals("id2", response.getResponses()[1].getId());
assertNull(response.getResponses()[1].getType());
assertEquals("index", response.getResponses()[1].getIndex());
assertEquals("Elasticsearch exception [type=index_not_found_exception, reason=no such index [index]]",
response.getResponses()[1].getFailure().getFailure().getMessage());
Expand All @@ -413,14 +390,12 @@ public void testMultiGet() throws IOException {
assertFalse(response.getResponses()[0].isFailed());
assertNull(response.getResponses()[0].getFailure());
assertEquals("id1", response.getResponses()[0].getId());
assertEquals("_doc", response.getResponses()[0].getType());
assertEquals("index", response.getResponses()[0].getIndex());
assertEquals(Collections.singletonMap("field", "value1"), response.getResponses()[0].getResponse().getSource());

assertFalse(response.getResponses()[1].isFailed());
assertNull(response.getResponses()[1].getFailure());
assertEquals("id2", response.getResponses()[1].getId());
assertEquals("_doc", response.getResponses()[1].getType());
assertEquals("index", response.getResponses()[1].getIndex());
assertEquals(Collections.singletonMap("field", "value2"), response.getResponses()[1].getResponse().getSource());
}
Expand All @@ -437,23 +412,7 @@ public void testMultiGetWithTypes() throws IOException {
highLevelClient().bulk(bulk, expectWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE));
MultiGetRequest multiGetRequest = new MultiGetRequest();
multiGetRequest.add("index", "id1");
multiGetRequest.add("index", "type", "id2");

MultiGetResponse response = execute(multiGetRequest,
highLevelClient()::mget,
highLevelClient()::mgetAsync,
expectWarnings(RestMultiGetAction.TYPES_DEPRECATION_MESSAGE));
assertEquals(2, response.getResponses().length);

GetResponse firstResponse = response.getResponses()[0].getResponse();
assertEquals("index", firstResponse.getIndex());
assertEquals("type", firstResponse.getType());
assertEquals("id1", firstResponse.getId());

GetResponse secondResponse = response.getResponses()[1].getResponse();
assertEquals("index", secondResponse.getIndex());
assertEquals("type", secondResponse.getType());
assertEquals("id2", secondResponse.getId());
multiGetRequest.add("index", "id2");
}

public void testIndex() throws IOException {
Expand Down Expand Up @@ -972,7 +931,6 @@ public void testUrlEncode() throws IOException {
GetResponse getResponse = highLevelClient().get(getRequest, RequestOptions.DEFAULT);
assertTrue(getResponse.isExists());
assertEquals(expectedIndex, getResponse.getIndex());
assertEquals("_doc", getResponse.getType());
assertEquals("id#1", getResponse.getId());
}

Expand All @@ -990,7 +948,6 @@ public void testUrlEncode() throws IOException {
GetResponse getResponse = highLevelClient().get(getRequest, RequestOptions.DEFAULT);
assertTrue(getResponse.isExists());
assertEquals("index", getResponse.getIndex());
assertEquals("_doc", getResponse.getType());
assertEquals(docId, getResponse.getId());
}

Expand All @@ -1014,7 +971,6 @@ public void testParamsEncode() throws IOException {
GetResponse getResponse = highLevelClient().get(getRequest, RequestOptions.DEFAULT);
assertTrue(getResponse.isExists());
assertEquals("index", getResponse.getIndex());
assertEquals("_doc", getResponse.getType());
assertEquals("id", getResponse.getId());
assertEquals(routing, getResponse.getField("_routing").getValue());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,13 @@ public void testGet() {
getAndExistsTest(RequestConverters::get, HttpGet.METHOD_NAME);
}

public void testGetWithType() {
getAndExistsWithTypeTest(RequestConverters::get, HttpGet.METHOD_NAME);
}

public void testSourceExists() throws IOException {
doTestSourceExists((index, id) -> new GetRequest(index, id));
}

public void testSourceExistsWithType() throws IOException {
String type = frequently() ? randomAlphaOfLengthBetween(3, 10) : MapperService.SINGLE_MAPPING_NAME;
doTestSourceExists((index, id) -> new GetRequest(index, type, id));
doTestSourceExists((index, id) -> new GetRequest(index, id));
}

private static void doTestSourceExists(BiFunction<String, String, GetRequest> requestFunction) throws IOException {
Expand Down Expand Up @@ -197,12 +193,7 @@ private static void doTestSourceExists(BiFunction<String, String, GetRequest> re
}
Request request = RequestConverters.sourceExists(getRequest);
assertEquals(HttpHead.METHOD_NAME, request.getMethod());
String type = getRequest.type();
if (type.equals(MapperService.SINGLE_MAPPING_NAME)) {
assertEquals("/" + index + "/_source/" + id, request.getEndpoint());
} else {
assertEquals("/" + index + "/" + type + "/" + id + "/_source", request.getEndpoint());
}
assertEquals("/" + index + "/_source/" + id, request.getEndpoint());

assertEquals(expectedParams, request.getParameters());
assertNull(request.getEntity());
Expand Down Expand Up @@ -260,7 +251,6 @@ public void testMultiGet() throws IOException {
public void testMultiGetWithType() throws IOException {
MultiGetRequest multiGetRequest = new MultiGetRequest();
MultiGetRequest.Item item = new MultiGetRequest.Item(randomAlphaOfLength(4),
randomAlphaOfLength(4),
randomAlphaOfLength(4));
multiGetRequest.add(item);

Expand Down Expand Up @@ -314,10 +304,6 @@ public void testExists() {
getAndExistsTest(RequestConverters::exists, HttpHead.METHOD_NAME);
}

public void testExistsWithType() {
getAndExistsWithTypeTest(RequestConverters::exists, HttpHead.METHOD_NAME);
}

private static void getAndExistsTest(Function<GetRequest, Request> requestConverter, String method) {
String index = randomAlphaOfLengthBetween(3, 10);
String id = randomAlphaOfLengthBetween(3, 10);
Expand Down Expand Up @@ -377,12 +363,11 @@ private static void getAndExistsTest(Function<GetRequest, Request> requestConver

private static void getAndExistsWithTypeTest(Function<GetRequest, Request> requestConverter, String method) {
String index = randomAlphaOfLengthBetween(3, 10);
String type = randomAlphaOfLengthBetween(3, 10);
String id = randomAlphaOfLengthBetween(3, 10);
GetRequest getRequest = new GetRequest(index, type, id);
GetRequest getRequest = new GetRequest(index, id);

Request request = requestConverter.apply(getRequest);
assertEquals("/" + index + "/" + type + "/" + id, request.getEndpoint());
assertEquals("/" + index + "/" + id, request.getEndpoint());
assertNull(request.getEntity());
assertEquals(method, request.getMethod());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1943,7 +1943,6 @@ private MultiGetItemResponse unwrapAndAssertExample(MultiGetResponse response) {
assertThat(response.getResponses(), arrayWithSize(1));
MultiGetItemResponse item = response.getResponses()[0];
assertEquals("index", item.getIndex());
assertEquals("_doc", item.getType());
assertEquals("example_id", item.getId());
return item;
}
Expand Down
4 changes: 0 additions & 4 deletions docs/plugins/ingest-attachment.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ Returns this:
{
"found": true,
"_index": "my_index",
"_type": "_doc",
"_id": "my_id",
"_version": 1,
"_seq_no": 22,
Expand Down Expand Up @@ -142,7 +141,6 @@ Returns this:
{
"found": true,
"_index": "my_index",
"_type": "_doc",
"_id": "my_id",
"_version": 1,
"_seq_no": 35,
Expand Down Expand Up @@ -191,7 +189,6 @@ Returns this:
{
"found": true,
"_index": "my_index",
"_type": "_doc",
"_id": "my_id_2",
"_version": 1,
"_seq_no": 40,
Expand Down Expand Up @@ -284,7 +281,6 @@ Returns this:
--------------------------------------------------
{
"_index" : "my_index",
"_type" : "_doc",
"_id" : "my_id",
"_version" : 1,
"_seq_no" : 50,
Expand Down
3 changes: 1 addition & 2 deletions docs/reference/docs/concurrency-control.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ You can see the assigned sequence number and primary term in the
"successful" : 1
},
"_index" : "products",
"_type" : "_doc",
"_id" : "1567",
"_type" : "_doc",
"_version" : 1,
"_seq_no" : 362,
"_primary_term" : 2,
Expand All @@ -69,7 +69,6 @@ returns:
--------------------------------------------------
{
"_index" : "products",
"_type" : "_doc",
"_id" : "1567",
"_version" : 1,
"_seq_no" : 362,
Expand Down
6 changes: 0 additions & 6 deletions docs/reference/docs/get.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,6 @@ include::{docdir}/rest-api/common-parms.asciidoc[tag=version_type]
`_index`::
The name of the index the document belongs to.

`_type`::
The document type. {es} indices now support a single document type, `_doc`.

`_id`::
The unique identifier for the document.

Expand Down Expand Up @@ -239,7 +236,6 @@ The API returns the following result:
--------------------------------------------------
{
"_index" : "twitter",
"_type" : "_doc",
"_id" : "0",
"_version" : 1,
"_seq_no" : 10,
Expand Down Expand Up @@ -351,7 +347,6 @@ The API returns the following result:
--------------------------------------------------
{
"_index": "twitter",
"_type": "_doc",
"_id": "1",
"_version": 1,
"_seq_no" : 22,
Expand Down Expand Up @@ -393,7 +388,6 @@ The API returns the following result:
--------------------------------------------------
{
"_index": "twitter",
"_type": "_doc",
"_id": "2",
"_version": 1,
"_seq_no" : 13,
Expand Down
Loading