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 mapping parameter from get index mappings API #2213 #2220

Closed
Closed
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 @@ -130,7 +130,6 @@
import org.opensearch.rest.action.admin.indices.RestGetFieldMappingAction;
import org.opensearch.rest.action.admin.indices.RestGetIndexTemplateAction;
import org.opensearch.rest.action.admin.indices.RestGetIndicesAction;
import org.opensearch.rest.action.admin.indices.RestGetMappingAction;
import org.opensearch.rest.action.admin.indices.RestPutIndexTemplateAction;
import org.opensearch.rest.action.admin.indices.RestPutMappingAction;
import org.opensearch.rest.action.admin.indices.RestRolloverIndexAction;
Expand Down Expand Up @@ -646,47 +645,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.opensearch.action.admin.indices.mapping.get.GetMappingsRequest request =
new org.opensearch.action.admin.indices.mapping.get.GetMappingsRequest().indices(indexName);

org.opensearch.action.admin.indices.mapping.get.GetMappingsResponse getMappingsResponse = execute(
request,
highLevelClient().indices()::getMapping,
highLevelClient().indices()::getMappingAsync,
expectWarningsOnce(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 @@ -721,6 +679,7 @@ public void testGetFieldMapping() throws IOException {
new BytesArray("{\"field\":{\"type\":\"text\"}}")
);
assertThat(fieldMappingMap, equalTo(Collections.singletonMap("field", metadata)));

}

public void testGetFieldMappingWithTypes() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,42 +86,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

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

- do:
indices.get_mapping:
include_type_name: false
index: test_alias

- match: {test_index.mappings.properties.text.type: text}
Expand Down
Loading