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

Support 'include_type_name' in RestGetIndicesAction #37149

Merged
merged 11 commits into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -92,7 +92,7 @@ setup:
- is_true: test_index.aliases
- is_true: test_index.settings
- is_true: test_index_2.settings
- is_false: test_index_2.mappings
- is_true: test_index_2.mappings
- is_true: test_index_2.aliases

---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,17 +265,22 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
}
builder.endObject();
} else {
MappingMetaData mappings = null;
for (final ObjectObjectCursor<String, MappingMetaData> typeEntry : indexMappings) {
if (typeEntry.key.equals(MapperService.DEFAULT_MAPPING) == false) {
assert mappings == null;
mappings = typeEntry.value;
}
if (mappings == null) {
// no mappings yet
builder.startObject("mappings").endObject();
} else {
builder.field("mappings", mappings.sourceAsMap());
if (indexMappings.size() == 0) {
// special case where there are no index mappings at all, we still want to output an empty object
builder.startObject("mappings").endObject();
} else {
MappingMetaData mappings = null;
for (final ObjectObjectCursor<String, MappingMetaData> typeEntry : indexMappings) {
if (typeEntry.key.equals(MapperService.DEFAULT_MAPPING) == false) {
assert mappings == null;
mappings = typeEntry.value;
}
if (mappings == null) {
cbuescher marked this conversation as resolved.
Show resolved Hide resolved
// no mappings yet
builder.startObject("mappings").endObject();
} else {
builder.field("mappings", mappings.sourceAsMap());
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ protected GetIndexResponse createBlankInstance() {

@Override
protected GetIndexResponse createTestInstance() {
return createTestInstance(false);
}

private GetIndexResponse createTestInstance(boolean randomTypeName) {
String[] indices = generateRandomStringArray(5, 5, false, false);
ImmutableOpenMap.Builder<String, ImmutableOpenMap<String, MappingMetaData>> mappings = ImmutableOpenMap.builder();
ImmutableOpenMap.Builder<String, List<AliasMetaData>> aliases = ImmutableOpenMap.builder();
Expand All @@ -86,7 +82,7 @@ private GetIndexResponse createTestInstance(boolean randomTypeName) {
for (String index: indices) {
// rarely have no types
int typeCount = rarely() ? 0 : 1;
mappings.put(index, GetMappingsResponseTests.createMappingsForIndex(typeCount, randomTypeName));
mappings.put(index, GetMappingsResponseTests.createMappingsForIndex(typeCount, false));

List<AliasMetaData> aliasMetaDataList = new ArrayList<>();
int aliasesNum = randomIntBetween(0, 3);
Expand Down