ElastaticSearch ---java查看es索引是否存在


java查看es索引是否存在

    /**
     * 判断指定的索引名是否存在
     *
     * @param indexName 索引名
     * @return 存在:true; 不存在:false;
     */
    public static boolean isExistsIndex(String indexName) {
        //初始化client
        TransportClient client = getClient(CLUSTER_NAME, IP, PORT);
        return client.admin().indices().exists(new IndicesExistsRequest().indices(indexName)).actionGet().isExists();
    }

以上的 client,改成项目中使用的 es client即可。如果没有现成的client,也可以参考以下:

https://www.cnblogs.com/expiator/p/15735701.html


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM