Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 735a47f

Browse files
committed
fix delete by query
1 parent f03f837 commit 735a47f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>org.nlpcn</groupId>
55
<artifactId>elasticsearch-sql</artifactId>
6-
<version>5.6.5.1</version>
6+
<version>5.6.5.2</version>
77
<packaging>jar</packaging>
88
<description>Query elasticsearch using SQL</description>
99
<name>elasticsearch-sql</name>

src/main/java/org/elasticsearch/plugin/nlpcn/executors/ElasticDefaultRestExecutor.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package org.elasticsearch.plugin.nlpcn.executors;
22

3+
import com.google.common.collect.Maps;
34
import org.elasticsearch.action.ActionFuture;
45
import org.elasticsearch.action.ActionRequest;
56
import org.elasticsearch.action.admin.indices.get.GetIndexRequest;
67
import org.elasticsearch.action.search.SearchRequest;
78
import org.elasticsearch.action.search.SearchResponse;
89
import org.elasticsearch.client.Client;
10+
import org.elasticsearch.index.reindex.BulkIndexByScrollResponseContentListener;
911
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
1012
import org.elasticsearch.plugin.nlpcn.*;
1113
import org.elasticsearch.rest.BytesRestResponse;
@@ -47,7 +49,7 @@ public void execute(Client client, Map<String, String> params, QueryAction query
4749
} else if (request instanceof SearchRequest) {
4850
client.search((SearchRequest) request, new RestStatusToXContentListener<SearchResponse>(channel));
4951
} else if (request instanceof DeleteByQueryRequest) {
50-
throw new UnsupportedOperationException("currently not support delete on elastic 2.x");
52+
requestBuilder.getBuilder().execute(new BulkIndexByScrollResponseContentListener(channel, Maps.newHashMap()));
5153
} else if (request instanceof GetIndexRequest) {
5254
requestBuilder.getBuilder().execute(new GetIndexRequestRestListener(channel, (GetIndexRequest) request));
5355
} else {
@@ -74,7 +76,7 @@ public String execute(Client client, Map<String, String> params, QueryAction que
7476
SearchResponse response = future.actionGet();
7577
return response.toString();
7678
} else if (request instanceof DeleteByQueryRequest) {
77-
throw new UnsupportedOperationException("currently not support delete on elastic 2.x");
79+
return requestBuilder.get().toString();
7880
} else if (request instanceof GetIndexRequest) {
7981
return requestBuilder.getBuilder().execute().actionGet().toString();
8082
} else {

0 commit comments

Comments
 (0)