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 put index mappings API #2222

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,9 +130,7 @@
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;

import java.io.IOException;
Expand Down Expand Up @@ -581,32 +579,6 @@ public void testPutMapping() throws IOException {
assertEquals("text", XContentMapValues.extractValue(indexName + ".mappings.properties.field.type", getIndexResponse));
}

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

org.opensearch.action.admin.indices.mapping.put.PutMappingRequest putMappingRequest =
new org.opensearch.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,
expectWarningsOnce(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 @@ -646,47 +618,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

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

This file was deleted.

Loading