Repository: searchbox-io/Jest
Pull request #466 (2017-03-01 15:37:38)

DeleteByQuery updated to ES 5


Patch:
diff --git a/jest-common/src/main/java/io/searchbox/core/DeleteByQuery.java b/jest-common/src/main/java/io/searchbox/core/DeleteByQuery.java
index 5416370d..76664420 100644
--- a/jest-common/src/main/java/io/searchbox/core/DeleteByQuery.java
+++ b/jest-common/src/main/java/io/searchbox/core/DeleteByQuery.java
@@ -24,7 +24,7 @@ public class DeleteByQuery extends GenericResultAbstractAction {
 
     @Override
     protected String buildURI() {
-        return super.buildURI() + "/_query";
+        return super.buildURI() + "/_delete_by_query";
     }
 
     @Override
@@ -34,7 +34,7 @@ public class DeleteByQuery extends GenericResultAbstractAction {
 
     @Override
     public String getRestMethodName() {
-        return "DELETE";
+        return "POST";
     }
 
     @Override


Test patch:
diff --git a/jest-common/src/test/java/io/searchbox/core/DeleteByQueryTest.java b/jest-common/src/test/java/io/searchbox/core/DeleteByQueryTest.java
index f659da2e..e0e2627e 100644
--- a/jest-common/src/test/java/io/searchbox/core/DeleteByQueryTest.java
+++ b/jest-common/src/test/java/io/searchbox/core/DeleteByQueryTest.java
@@ -12,33 +12,33 @@ public class DeleteByQueryTest {
 
     @Test
     public void getURIWithoutIndexAndType() {
-        assertEquals("_all/_query", new DeleteByQuery.Builder(null).build().getURI());
+        assertEquals("_all/_delete_by_query", new DeleteByQuery.Builder(null).build().getURI());
     }
 
     @Test
     public void getURIWithOnlyOneIndex() {
-        assertEquals("twitter/_query", new DeleteByQuery.Builder(null).addIndex("twitter").build().getURI());
+        assertEquals("twitter/_delete_by_query", new DeleteByQuery.Builder(null).addIndex("twitter").build().getURI());
     }
 
     @Test
     public void getURIWithOnlyMultipleType() {
-        assertEquals("_all/tweet%2Cjest/_query", new DeleteByQuery.Builder(null).addType("tweet").addType("jest").build().getURI());
+        assertEquals("_all/tweet%2Cjest/_delete_by_query", new DeleteByQuery.Builder(null).addType("tweet").addType("jest").build().getURI());
     }
 
     @Test
     public void getURIWithOneIndexAndOneType() {
-        assertEquals("twitter/tweet/_query", new DeleteByQuery.Builder(null).addIndex("twitter").addType("tweet").build().getURI());
+        assertEquals("twitter/tweet/_delete_by_query", new DeleteByQuery.Builder(null).addIndex("twitter").addType("tweet").build().getURI());
     }
 
     @Test
     public void getURIWithOnlyMultipleIndex() {
-        assertEquals("twitter%2Csearchbox/_query",
+        assertEquals("twitter%2Csearchbox/_delete_by_query",
                 new DeleteByQuery.Builder(null).addIndex("twitter").addIndex("searchbox").build().getURI());
     }
 
     @Test
     public void getURIWithMultipleIndexAndTypes() {
-        assertEquals("twitter%2Csearchbox/tweet%2Cjest/_query", new DeleteByQuery.Builder(null)
+        assertEquals("twitter%2Csearchbox/tweet%2Cjest/_delete_by_query", new DeleteByQuery.Builder(null)
                 .addIndex("twitter")
                 .addIndex("searchbox")
                 .addType("tweet")
diff --git a/jest/src/test/java/io/searchbox/core/DeleteByQueryIntegrationTest.java b/jest/src/test/java/io/searchbox/core/DeleteByQueryIntegrationTest.java
index 8dfc1571..b1524e78 100644
--- a/jest/src/test/java/io/searchbox/core/DeleteByQueryIntegrationTest.java
+++ b/jest/src/test/java/io/searchbox/core/DeleteByQueryIntegrationTest.java
@@ -46,11 +46,11 @@ public class DeleteByQueryIntegrationTest extends AbstractIntegrationTest {
 
         assertEquals(
                 0,
-                result.getJsonObject().getAsJsonObject("_indices").getAsJsonObject("twitter").get("failed").getAsInt()
+                result.getJsonObject().getAsJsonObject("_shards").get("failed").getAsInt()
         );
         assertEquals(
                 1,
-                result.getJsonObject().getAsJsonObject("_indices").getAsJsonObject("twitter").get("deleted").getAsInt()
+                result.getJsonObject().getAsJsonObject("_shards").get("successful").getAsInt()
         );
     }