感谢您的回复,中文引号是在写邮件时误加的,我试过curl命令也是可以的,但是使用Java代码,发送http请求却是不能正常删除,返回体没有报错。
这是我的java代码:
try (CloseableHttpClient httpclient = HttpClientBuilder.create().build()) {
HttpPut httpPut = new
HttpPut("http://127.0.0.1:8040/api/db/table1/_stream_load?
<http://127.0.0.1:8040/api/db/table1/_stream_load?>");
httpPut.setHeader("Authorization", "Basic " + "cm9vdDo=");
httpPut.setHeader("Expect", "100-continue");
httpPut.setHeader("columns", "id,name");
httpPut.setHeader("merge_type", "MERGE");
httpPut.setHeader("delete", "id<=>'1' and name<=>'上海'");
httpPut.setHeader("column_separator", ",");
httpPut.setEntity(new ByteArrayEntity("1,上海".getBytes()));
CloseableHttpResponse httpResponse = httpclient.execute(httpPut);
int status = httpResponse.getStatusLine().getStatusCode();
HttpEntity entity = httpResponse.getEntity();
System.out.println("status: " + status);
System.out.println("entity: " + (entity != null ?
EntityUtils.toString(entity) : ""));
}
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>
> 2022年2月7日 下午7:03,陈明雨 <[email protected]> 写道:
>
> I tested it with curl command and utf8 encoded data file.
>
>
> curl -v --location-trusted -u root: -H "column_separator:," -H "merge_type:
> MERGE" -H "columns: k1,k2" -H "delete: k1=2 and k2<=>'上海'" -T 1.txt
> http://127.0.0.1:8042/api/db1/tbl2/_stream_load
>
>
> It works fine.
>
>
> You problem may because you wrote a Chinese quota to wrap your data “中文”.
>
>
>
>
> --
>
> 此致!Best Regards
> 陈明雨 Mingyu Chen
>
> Email:
> [email protected]
>
>
>
>
>
> 在 2022-02-07 15:32:01,"nan tu" <[email protected]> 写道:
>> Hi,如题所述:
>> 如下发送http请求批量导入数据,delete条件包含中文,已知http请求头不能识别中文,有什么方式可以处理这种情况吗?
>> ... columns: id, name" -H "merge_type: MERGE" -H "delete: id='1' AND name<=>
>> ‘中文'
>> Thanks!