Elasticsearch 使用 jest 通过查询删除[关闭]

2024-03-18

我发现一个有趣的功能叫做通过查询删除 https://www.elastic.co/guide/en/elasticsearch/plugins/current/delete-by-query-usage.html。 我该如何使用它开玩笑的客户 https://github.com/searchbox-io/Jest?

Thanks!


您可以使用DeleteByQuery class https://github.com/searchbox-io/Jest/blob/eb2d90d0504a6e3db874cc8bd14efe4913451173/jest-common/src/main/java/io/searchbox/core/DeleteByQuery.java如下图所示:

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

另请注意,如果您运行的是 ES 2.x 或更高版本,通过查询API删除 https://www.elastic.co/guide/en/elasticsearch/reference/2.0/breaking_20_removed_features.html#_delete_by_query_is_now_a_plugin需要先从插件安装。

./bin/plugin install delete-by-query
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Elasticsearch 使用 jest 通过查询删除[关闭] 的相关文章

随机推荐