FuYouJ opened a new issue, #7675:
URL: https://github.com/apache/seatunnel/issues/7675

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22bug%22)
 and found no similar issues.
   
   
   ### What happened
   
   When I tried to update the document in ES based on the ID, I found that the 
code would throw an error.
   Updating documents that contain ids should use bulk with index instead of 
bulk with update.
   
![QQ_1726579905484](https://github.com/user-attachments/assets/f0d1084e-29b8-45e0-862a-c721fa4150d5)
   code:
   
![QQ_1726580213634](https://github.com/user-attachments/assets/a05638ba-5cca-4ea9-8e21-839b39680de0)
   
![QQ_1726580348424](https://github.com/user-attachments/assets/4e5f2c81-2a78-4458-a99b-73994f222ea7)
   
![QQ_1726580390801](https://github.com/user-attachments/assets/adbc0f8a-3c35-4e0d-be34-482a09fe9735)
   
   
   ### SeaTunnel Version
   
   2.3.8 dev
   
   ### SeaTunnel Config
   
   ```conf
   es mapping 
   {
     "read_index1" : {
       "mappings" : {
         "properties" : {
           "c_array" : {
             "type" : "long"
           },
           "c_bigint" : {
             "type" : "long"
           },
           "c_boolean" : {
             "type" : "boolean"
           },
           "c_bytes" : {
             "type" : "text",
             "fields" : {
               "keyword" : {
                 "type" : "keyword",
                 "ignore_above" : 256
               }
             }
           },
           "c_date" : {
             "type" : "date"
           },
           "c_decimal" : {
             "type" : "float"
           },
           "c_double" : {
             "type" : "float"
           },
           "c_float" : {
             "type" : "float"
           },
           "c_int" : {
             "type" : "long"
           },
           "c_map" : {
             "properties" : {
               "key" : {
                 "type" : "long"
               }
             }
           },
           "c_smallint" : {
             "type" : "long"
           },
           "c_string" : {
             "type" : "text",
             "fields" : {
               "keyword" : {
                 "type" : "keyword",
                 "ignore_above" : 256
               }
             }
           },
           "c_timestamp" : {
             "type" : "long"
           },
           "c_tinyint" : {
             "type" : "long"
           }
         }
       }
     }
   }
   
   
   #
   # Licensed to the Apache Software Foundation (ASF) under one or more
   # contributor license agreements.  See the NOTICE file distributed with
   # this work for additional information regarding copyright ownership.
   # The ASF licenses this file to You under the Apache License, Version 2.0
   # (the "License"); you may not use this file except in compliance with
   # the License.  You may obtain a copy of the License at
   #
   #    http://www.apache.org/licenses/LICENSE-2.0
   #
   # Unless required by applicable law or agreed to in writing, software
   # distributed under the License is distributed on an "AS IS" BASIS,
   # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   # See the License for the specific language governing permissions and
   # limitations under the License.
   #
   
   ######
   ###### This config file is a demonstration of streaming processing in 
seatunnel config
   ######
   
   env {
     parallelism = 1
     job.mode = "BATCH"
     #checkpoint.interval = 10000
   }
   
   source {
     Elasticsearch {
       hosts = ["http://seatunnel-j5l.xxxxxxxxx.com:9200";]
       username = "seatunnel-j5l"
       password = "xxxxxxxxxxxx"
       tls_verify_certificate = false
       tls_verify_hostname = false
   
       index = "read_index1"
       query = {"match_all":{}}
       source=["_id","c_int"]
     }
   }
   
   transform {
   }
   
   sink {
     Elasticsearch {
       hosts = 
["http://seatunnel-j5l.public.cn-hangzhou.es-serverless.aliyuncs.com:9200";]
       username = "seatunnel-j5l"
       password = "123fu1997JIE"
       tls_verify_certificate = false
       tls_verify_hostname = false
       primary_keys = "_id"
   
       index = "write_index1"
       "schema_save_mode"="CREATE_SCHEMA_WHEN_NOT_EXIST"
       "data_save_mode"="APPEND_DATA"
     }
   }
   ```
   
   
   ### Running Command
   
   ```shell
   run with example
   ```
   
   
   ### Error Exception
   
   ```log
   Caused by: org.elasticsearch.client.ResponseException: method [POST], host 
[http://seatunnel-j5l.public.cn-hangzhou.es-serverless.aliyuncs.com:9200], URI 
[/_bulk], status line [HTTP/1.1 400 Bad Request]
   {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Field 
[_id] is a metadata field and cannot be added inside a document. Use the index 
API request parameters."}],"type":"mapper_parsing_exception","reason":"failed 
to parse field [_id] of type [_id] in document with id 'JndimZEBRF9Q93Q5GAyM'. 
Preview of field's value: 
'JndimZEBRF9Q93Q5GAyM'","caused_by":{"type":"mapper_parsing_exception","reason":"Field
 [_id] is a metadata field and cannot be added inside a document. Use the index 
API request parameters."}},"status":400}
        at 
org.elasticsearch.client.RestClient.convertResponse(RestClient.java:283)
        at 
org.elasticsearch.client.RestClient.performRequest(RestClient.java:261)
        at 
org.elasticsearch.client.RestClient.performRequest(RestClient.java:235)
        at 
org.apache.seatunnel.connectors.seatunnel.elasticsearch.client.EsRestClient.bulk(EsRestClient.java:211)
        ... 13 more
   ```
   
   
   ### Zeta or Flink or Spark Version
   
   _No response_
   
   ### Java or Scala Version
   
   _No response_
   
   ### Screenshots
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to