{"record":{"id":"21333f23b27de3cf","repo":"apache/seatunnel","slug":"fail-to-get-elasticsearch-field-mapping-type-so","errorCode":null,"errorMessage":"fail to get elasticsearch field {} mapping type,so give a default type text","messagePattern":"fail to get elasticsearch field (.+?) mapping type,so give a default type text","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-elasticsearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/elasticsearch/client/EsRestClient.java","lineNumber":836,"sourceCode":"                        BasicTypeDefine<EsType> type =\n                                allElasticSearchFieldTypeInfoMap.get(\n                                        fieldType.getNativeType().getOptions().get(\"path\"));\n                        if (type != null) {\n                            allElasticSearchFieldTypeInfoMap.put(fieldName, type);\n                        }\n                    }\n                });\n\n        return source.stream()\n                .collect(\n                        Collectors.toMap(\n                                Function.identity(),\n                                fieldName -> {\n                                    BasicTypeDefine<EsType> fieldType =\n                                            allElasticSearchFieldTypeInfoMap.get(fieldName);\n                                    if (fieldType == null) {\n                                        log.warn(\n                                                \"fail to get elasticsearch field {} mapping type,so give a default type text\",\n                                                fieldName);\n                                        return BasicTypeDefine.<EsType>builder()\n                                                .name(fieldName)\n                                                .columnType(\"text\")\n                                                .dataType(\"text\")\n                                                .build();\n                                    }\n                                    return fieldType;\n                                }));\n    }\n\n    /**\n     * Add a new field to an existing index\n     *\n     * @param index index name\n     * @param fieldTypeDefine field type definition\n     */\n    public void addField(String index, BasicTypeDefine<EsType> fieldTypeDefine) {","sourceCodeStart":818,"sourceCodeEnd":854,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-elasticsearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/elasticsearch/client/EsRestClient.java#L818-L854","documentation":"When building the field-type map for an Elasticsearch index, a field name referenced in the query/source was not found in the fetched index mapping. The client logs this warning and falls back to a default BasicTypeDefine of type 'text', which may cause inaccurate type mapping downstream.","triggerScenarios":"Reading from an index where a requested field is absent from the mapping (e.g. nested/object fields, fields only present in some documents, runtime fields, or alias/multi-index reads where mappings differ).","commonSituations":"Typo in source field name; reading across multiple indices with heterogeneous mappings; dynamic mapping not yet created; fields mapped only via runtime fields.","solutions":["Verify the field exists in the index mapping (GET /index/_mapping)","Fix the field name spelling in the source config","Ensure all indices in index_list share consistent mappings or declare schema explicitly via source config","Accept the fallback and explicitly map the field type using the schema/source option"],"exampleFix":"// before\nsource = [\"my_field\"] // field missing in mapping -> defaults to text\n// after\nsource {\n  MyTable {\n    schema = {\n      fields {\n        my_field = string\n      }\n    }\n  }\n}","handlingStrategy":"validation","validationCode":"// verify fields exist in mapping before reading\ncurl -s 'http://es:9200/my_index/_mapping' | jq '.my_index.mappings.properties | keys'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cross-check source field names against GET /_mapping","Declare fields explicitly via source/schema config for heterogeneous indices","Avoid relying on fallback text typing for numeric/date fields"],"tags":["elasticsearch","mapping","type-mapping"],"backgroundTag":"unexpected-response-shape","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}