public void resolveFields(SearchContext searchContext, String indexMapping) throws StarRocksConnectorException {
        JSONObject jsonObject = new JSONObject(indexMapping);
        // the indexName use alias takes the first mapping
        Iterator<String> keys = jsonObject.keys();
        String docKey = keys.next();
        JSONObject docData = jsonObject.optJSONObject(docKey);
        JSONObject mappings = docData.optJSONObject("mappings");
        JSONObject rootSchema = mappings.optJSONObject(searchContext.type());
        JSONObject properties;
        // Elasticsearch 7.x, type was removed from ES mapping, default type is `_doc`
        // https://www.elastic.co/guide/en/elasticsearch/reference/7.0/removal-of-types.html
        // From Elasticsearch 8.x, Specifying types in requests is no longer supported,
        // The include_type_name parameter is removed
        // https://www.elastic.co/guide/en/elasticsearch/reference/7.17/removal-of-types.html
        if (rootSchema == null) {
            // 1. before 7.0, if the `type` does not exist in index, rootSchema is null
            //   this can throw exception within the `properties == null` predicate
            // 2. after or equal 8.x, type is removed from mappings
            properties = mappings.optJSONObject("properties");
        } else {
            properties = rootSchema.optJSONObject("properties");
        }
        if (properties == null) {
            throw new StarRocksConnectorException("index[" + searchContext.sourceIndex() + "] type[" + searchContext.type() +
                    "] mapping not found for the ES Cluster");
        }
        for (Column col : searchContext.columns()) {
            String colName = col.getName();
            // if column exists in StarRocks Table but no found in ES's mapping, we choose to ignore this situation?
            if (!properties.has(colName)) {
                continue;
            }
            JSONObject fieldObject = properties.optJSONObject(colName);

            resolveKeywordFields(searchContext, fieldObject, colName);
            resolveDocValuesFields(searchContext, fieldObject, colName);
        }
    }
@Test
    public void testTypeNotExist() throws Exception {
        MappingPhase mappingPhase = new MappingPhase(null);
        EsTable table = fakeEsTable("fake", "test", "not_exists", columns);
        SearchContext searchContext = new SearchContext(table);
        // type not exists
        ExceptionChecker.expectThrows(StarRocksConnectorException.class,
                () -> mappingPhase.resolveFields(searchContext, loadJsonFromFile("data/es/test_index_mapping.json")));
    }