|
22 | 22 | import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
|
23 | 23 | import org.elasticsearch.action.admin.indices.get.GetIndexResponse;
|
24 | 24 | import org.elasticsearch.client.Client;
|
25 |
| -import org.elasticsearch.cluster.metadata.MappingMetaData; |
| 25 | +import org.elasticsearch.cluster.metadata.MappingMetadata; |
26 | 26 | import org.elasticsearch.common.collect.ImmutableOpenMap;
|
27 | 27 |
|
28 | 28 | import java.util.ArrayList;
|
@@ -89,33 +89,33 @@ private List<Column> loadColumns() {
|
89 | 89 | private List<Row> loadRows() {
|
90 | 90 | List<Row> rows = new ArrayList<>();
|
91 | 91 | GetIndexResponse indexResponse = (GetIndexResponse) queryResult;
|
92 |
| - ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> indexMappings = indexResponse.getMappings(); |
| 92 | + ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetadata>> indexMappings = indexResponse.getMappings(); |
93 | 93 |
|
94 | 94 | // Iterate through indices in indexMappings
|
95 |
| - for (ObjectObjectCursor<String, ImmutableOpenMap<String, MappingMetaData>> indexCursor : indexMappings) { |
| 95 | + for (ObjectObjectCursor<String, ImmutableOpenMap<String, MappingMetadata>> indexCursor : indexMappings) { |
96 | 96 | String index = indexCursor.key;
|
97 | 97 |
|
98 | 98 | // Check to see if index matches given pattern
|
99 | 99 | if (matchesPattern(index, statement.getIndexPattern())) {
|
100 |
| - ImmutableOpenMap<String, MappingMetaData> typeMapping = indexCursor.value; |
| 100 | + ImmutableOpenMap<String, MappingMetadata> typeMapping = indexCursor.value; |
101 | 101 | // Assuming ES 6.x, iterate through the only type of the index to get mapping data
|
102 |
| - for (ObjectObjectCursor<String, MappingMetaData> typeCursor : typeMapping) { |
103 |
| - MappingMetaData mappingMetaData = typeCursor.value; |
| 102 | + for (ObjectObjectCursor<String, MappingMetadata> typeCursor : typeMapping) { |
| 103 | + MappingMetadata mappingMetadata = typeCursor.value; |
104 | 104 | // Load rows for each field in the mapping
|
105 |
| - rows.addAll(loadIndexData(index, mappingMetaData.getSourceAsMap())); |
| 105 | + rows.addAll(loadIndexData(index, mappingMetadata.getSourceAsMap())); |
106 | 106 | }
|
107 | 107 | }
|
108 | 108 | }
|
109 | 109 | return rows;
|
110 | 110 | }
|
111 | 111 |
|
112 | 112 | @SuppressWarnings("unchecked")
|
113 |
| - private List<Row> loadIndexData(String index, Map<String, Object> mappingMetaData) { |
| 113 | + private List<Row> loadIndexData(String index, Map<String, Object> mappingMetadata) { |
114 | 114 | List<Row> rows = new ArrayList<>();
|
115 | 115 |
|
116 |
| - Map<String, String> flattenedMetaData = flattenMappingMetaData(mappingMetaData, "", new HashMap<>()); |
| 116 | + Map<String, String> flattenedMetadata = flattenMappingMetadata(mappingMetadata, "", new HashMap<>()); |
117 | 117 | int position = 1; // Used as an arbitrary ORDINAL_POSITION value for the time being
|
118 |
| - for (Entry<String, String> entry : flattenedMetaData.entrySet()) { |
| 118 | + for (Entry<String, String> entry : flattenedMetadata.entrySet()) { |
119 | 119 | String columnPattern = statement.getColumnPattern();
|
120 | 120 |
|
121 | 121 | // Check to see if column name matches pattern, if given
|
@@ -153,21 +153,21 @@ private Map<String, Object> loadRowData(String index, String column, String type
|
153 | 153 | * 'GetIndexRequestBuilder' that was used in the old ShowQueryAction. Since the format of the resulting meta data
|
154 | 154 | * is different, this method is being used to flatten and retrieve types.
|
155 | 155 | * <p>
|
156 |
| - * In the future, should look for a way to generalize this since Schema is currently using FieldMappingMetaData |
157 |
| - * whereas here we are using MappingMetaData. |
| 156 | + * In the future, should look for a way to generalize this since Schema is currently using FieldMappingMetadata |
| 157 | + * whereas here we are using MappingMetadata. |
158 | 158 | */
|
159 | 159 | @SuppressWarnings("unchecked")
|
160 |
| - private Map<String, String> flattenMappingMetaData(Map<String, Object> mappingMetaData, |
| 160 | + private Map<String, String> flattenMappingMetadata(Map<String, Object> mappingMetadata, |
161 | 161 | String currPath,
|
162 | 162 | Map<String, String> flattenedMapping) {
|
163 |
| - Map<String, Object> properties = (Map<String, Object>) mappingMetaData.get("properties"); |
| 163 | + Map<String, Object> properties = (Map<String, Object>) mappingMetadata.get("properties"); |
164 | 164 | for (Entry<String, Object> entry : properties.entrySet()) {
|
165 |
| - Map<String, Object> metaData = (Map<String, Object>) entry.getValue(); |
| 165 | + Map<String, Object> metadata = (Map<String, Object>) entry.getValue(); |
166 | 166 |
|
167 | 167 | String fullPath = addToPath(currPath, entry.getKey());
|
168 |
| - flattenedMapping.put(fullPath, (String) metaData.getOrDefault("type", DEFAULT_OBJECT_DATATYPE)); |
169 |
| - if (metaData.containsKey("properties")) { |
170 |
| - flattenedMapping = flattenMappingMetaData(metaData, fullPath, flattenedMapping); |
| 168 | + flattenedMapping.put(fullPath, (String) metadata.getOrDefault("type", DEFAULT_OBJECT_DATATYPE)); |
| 169 | + if (metadata.containsKey("properties")) { |
| 170 | + flattenedMapping = flattenMappingMetadata(metadata, fullPath, flattenedMapping); |
171 | 171 | }
|
172 | 172 | }
|
173 | 173 |
|
|
0 commit comments