3

I find an interesting feature called delete by query. How do I use it with jest client?

Thanks!

Nkosi
  • 235,767
  • 35
  • 427
  • 472
Quy Tang
  • 3,929
  • 1
  • 31
  • 45

1 Answers1

8

You can use the DeleteByQuery class like shown below:

    DeleteByQuery deleteAllUserJohn = new DeleteByQuery.Builder("{\"user\":\"john\"}")
            .addIndex("users")
            .addType("user")
            .build();
    client.execute(deleteAllUserJohn);

Also note that if you're running ES 2.x or above, the Delete by query API needs to be installed from a plugin first.

./bin/plugin install delete-by-query
Val
  • 207,596
  • 13
  • 358
  • 360