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

Removes typed URLs from mapping APIs #41676

Merged
merged 15 commits into from
Sep 23, 2019
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 @@ -100,12 +100,9 @@
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.rest.action.admin.indices.RestCreateIndexAction;
import org.elasticsearch.rest.action.admin.indices.RestGetFieldMappingAction;
import org.elasticsearch.rest.action.admin.indices.RestGetIndexTemplateAction;
import org.elasticsearch.rest.action.admin.indices.RestGetIndicesAction;
import org.elasticsearch.rest.action.admin.indices.RestGetMappingAction;
import org.elasticsearch.rest.action.admin.indices.RestPutIndexTemplateAction;
import org.elasticsearch.rest.action.admin.indices.RestPutMappingAction;
import org.elasticsearch.rest.action.admin.indices.RestRolloverIndexAction;

import java.io.IOException;
Expand Down Expand Up @@ -541,31 +538,6 @@ public void testPutMapping() throws IOException {
getIndexResponse));
}

public void testPutMappingWithTypes() throws IOException {
String indexName = "mapping_index";
createIndex(indexName, Settings.EMPTY);

org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest putMappingRequest =
new org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest(indexName);
putMappingRequest.type("some_type");

XContentBuilder mappingBuilder = JsonXContent.contentBuilder();
mappingBuilder.startObject().startObject("properties").startObject("field");
mappingBuilder.field("type", "text");
mappingBuilder.endObject().endObject().endObject();
putMappingRequest.source(mappingBuilder);

AcknowledgedResponse putMappingResponse = execute(putMappingRequest,
highLevelClient().indices()::putMapping,
highLevelClient().indices()::putMappingAsync,
expectWarnings(RestPutMappingAction.TYPES_DEPRECATION_MESSAGE));
assertTrue(putMappingResponse.isAcknowledged());

Map<String, Object> getIndexResponse = getAsMap(indexName);
assertEquals("text", XContentMapValues.extractValue(indexName + ".mappings.properties.field.type",
getIndexResponse));
}

public void testGetMapping() throws IOException {
String indexName = "test";
createIndex(indexName, Settings.EMPTY);
Expand Down Expand Up @@ -602,44 +574,6 @@ public void testGetMapping() throws IOException {
assertThat(mappings, equalTo(expected));
}

public void testGetMappingWithTypes() throws IOException {
String indexName = "test";
createIndex(indexName, Settings.EMPTY);

PutMappingRequest putMappingRequest = new PutMappingRequest(indexName);
XContentBuilder mappingBuilder = JsonXContent.contentBuilder();
mappingBuilder.startObject().startObject("properties").startObject("field");
mappingBuilder.field("type", "text");
mappingBuilder.endObject().endObject().endObject();
putMappingRequest.source(mappingBuilder);

AcknowledgedResponse putMappingResponse = execute(putMappingRequest,
highLevelClient().indices()::putMapping,
highLevelClient().indices()::putMappingAsync);
assertTrue(putMappingResponse.isAcknowledged());

Map<String, Object> getIndexResponse = getAsMap(indexName);
assertEquals("text", XContentMapValues.extractValue(indexName + ".mappings.properties.field.type", getIndexResponse));

org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest request =
new org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest().indices(indexName);

org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse getMappingsResponse = execute(
request,
highLevelClient().indices()::getMapping,
highLevelClient().indices()::getMappingAsync,
expectWarnings(RestGetMappingAction.TYPES_DEPRECATION_MESSAGE));

Map<String, Object> mappings = getMappingsResponse.getMappings().get(indexName).get("_doc").sourceAsMap();
Map<String, String> type = new HashMap<>();
type.put("type", "text");
Map<String, Object> field = new HashMap<>();
field.put("field", type);
Map<String, Object> expected = new HashMap<>();
expected.put("properties", field);
assertThat(mappings, equalTo(expected));
}

public void testGetFieldMapping() throws IOException {
String indexName = "test";
createIndex(indexName, Settings.EMPTY);
Expand Down Expand Up @@ -673,42 +607,6 @@ public void testGetFieldMapping() throws IOException {
assertThat(fieldMappingMap, equalTo(Collections.singletonMap("field", metaData)));
}

public void testGetFieldMappingWithTypes() throws IOException {
String indexName = "test";
createIndex(indexName, Settings.EMPTY);

PutMappingRequest putMappingRequest = new PutMappingRequest(indexName);
XContentBuilder mappingBuilder = JsonXContent.contentBuilder();
mappingBuilder.startObject().startObject("properties").startObject("field");
mappingBuilder.field("type", "text");
mappingBuilder.endObject().endObject().endObject();
putMappingRequest.source(mappingBuilder);

AcknowledgedResponse putMappingResponse =
execute(putMappingRequest, highLevelClient().indices()::putMapping, highLevelClient().indices()::putMappingAsync);
assertTrue(putMappingResponse.isAcknowledged());

org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsRequest getFieldMappingsRequest =
new org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsRequest()
.indices(indexName)
.types("_doc")
.fields("field");

org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse getFieldMappingsResponse =
execute(getFieldMappingsRequest,
highLevelClient().indices()::getFieldMapping,
highLevelClient().indices()::getFieldMappingAsync,
expectWarnings(RestGetFieldMappingAction.TYPES_DEPRECATION_MESSAGE));

final Map<String, org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetaData>
fieldMappingMap = getFieldMappingsResponse.mappings().get(indexName).get("_doc");

final org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetaData metaData =
new org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetaData("field",
new BytesArray("{\"field\":{\"type\":\"text\"}}"));
assertThat(fieldMappingMap, equalTo(Collections.singletonMap("field", metaData)));
}

public void testDeleteIndex() throws IOException {
{
// Delete index if exists
Expand Down
3 changes: 0 additions & 3 deletions docs/reference/indices.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ index settings, aliases, mappings, and index templates.
* <<indices-put-mapping>>
* <<indices-get-mapping>>
* <<indices-get-field-mapping>>
* <<indices-types-exists>>

[float]
[[alias-management]]
Expand Down Expand Up @@ -102,8 +101,6 @@ include::indices/get-mapping.asciidoc[]

include::indices/get-field-mapping.asciidoc[]

include::indices/types-exists.asciidoc[]

include::indices/add-alias.asciidoc[]

include::indices/delete-alias.asciidoc[]
Expand Down
16 changes: 0 additions & 16 deletions docs/reference/indices/types-exists.asciidoc

This file was deleted.

7 changes: 7 additions & 0 deletions docs/reference/migration/migrate_8_0/mappings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
The number of completion contexts within a single completion field
has been limited to 10.

[float]
==== Removal of types

The typed REST endpoints of the Put Mapping, Get Mapping and Get Field mapping
APIs have been removed in favour of their typeless REST endpoints, since indexes
no longer contain types, these typed endpoints are obsolete.

[float]
==== Defining multi-fields within multi-fields

Expand Down
8 changes: 7 additions & 1 deletion docs/reference/redirects.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,12 @@ The `common` terms query is deprecated. Use the <<query-dsl-match-query, `match`
query>> instead. The `match` query skips blocks of documents efficiently,
without any configuration, if the total number of hits is not tracked.

[role="exclude",id="indices-types-exists"]
=== Types Exists

The types exists endpoint has been removed. See <<removal-of-types>> for
more details.

[role="exclude",id="xpack-api"]
=== X-Pack APIs

Expand Down Expand Up @@ -902,4 +908,4 @@ See <<transform-source>>.
[role="exclude",id="data-frame-transform-pivot"]
==== Pivot objects

See <<transform-pivot>>.
See <<transform-pivot>>.
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,6 @@ public void testIndexExists() throws IOException {
headTestCase("/test", singletonMap("pretty", "true"), greaterThan(0));
}

public void testTypeExists() throws IOException {
createTestDoc();
headTestCase("/test/_mapping/_doc", emptyMap(), OK.getStatus(), greaterThan(0),
"Type exists requests are deprecated, as types have been deprecated.");
headTestCase("/test/_mapping/_doc", singletonMap("pretty", "true"), OK.getStatus(), greaterThan(0),
"Type exists requests are deprecated, as types have been deprecated.");
}

public void testTypeDoesNotExist() throws IOException {
createTestDoc();
headTestCase("/test/_mapping/does-not-exist", emptyMap(), NOT_FOUND.getStatus(), greaterThan(0),
"Type exists requests are deprecated, as types have been deprecated.");
headTestCase("/text/_mapping/test,does-not-exist", emptyMap(), NOT_FOUND.getStatus(), greaterThan(0),
"Type exists requests are deprecated, as types have been deprecated.");
}

public void testAliasExists() throws IOException {
createTestDoc();
try (XContentBuilder builder = jsonBuilder()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,52 +34,6 @@
"description":"A comma-separated list of fields"
}
}
},
{
"path":"/_mapping/{type}/field/{fields}",
"methods":[
"GET"
],
"parts":{
"type":{
"type":"list",
"description":"A comma-separated list of document types",
"deprecated":true
},
"fields":{
"type":"list",
"description":"A comma-separated list of fields"
}
},
"deprecated":{
"version":"7.0.0",
"description":"Specifying types in urls has been deprecated"
}
},
{
"path":"/{index}/_mapping/{type}/field/{fields}",
"methods":[
"GET"
],
"parts":{
"index":{
"type":"list",
"description":"A comma-separated list of index names"
},
"type":{
"type":"list",
"description":"A comma-separated list of document types",
"deprecated":true
},
"fields":{
"type":"list",
"description":"A comma-separated list of fields"
}
},
"deprecated":{
"version":"7.0.0",
"description":"Specifying types in urls has been deprecated"
}
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,52 +24,10 @@
"description":"A comma-separated list of index names"
}
}
},
{
"path":"/_mapping/{type}",
"methods":[
"GET"
],
"parts":{
"type":{
"type":"list",
"description":"A comma-separated list of document types",
"deprecated":true
}
},
"deprecated":{
"version":"7.0.0",
"description":"Specifying types in urls has been deprecated"
}
},
{
"path":"/{index}/_mapping/{type}",
"methods":[
"GET"
],
"parts":{
"index":{
"type":"list",
"description":"A comma-separated list of index names"
},
"type":{
"type":"list",
"description":"A comma-separated list of document types",
"deprecated":true
}
},
"deprecated":{
"version":"7.0.0",
"description":"Specifying types in urls has been deprecated"
}
}
]
},
"params":{
"include_type_name":{
"type":"boolean",
"description":"Whether to add the type name to the response (default: false)"
},
"ignore_unavailable":{
"type":"boolean",
"description":"Whether specified concrete indices should be ignored when unavailable (missing or closed)"
Expand Down
Loading