检查索引是否存在Elasticsearch [英] Check if the index exists or not Elasticsearch

查看:1807
本文介绍了检查索引是否存在Elasticsearch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果索引存在与否,我想检查elasticsearch。如果它不存在,它应该创建索引并执行其他功能。我试图找到解决方案,但没有找到任何完美的解决方案。任何人都可以有任何解决方案来解决这个问题。

I want to check in elasticsearch if the index exists or not. If it not exists it should create the index and do other functionality. I try to find out a solution for that, but did not find any perfect solution for that. Can anyone have any solution to solve this problem.

我正在使用Elasticsearch库。

I am using Elasticsearch library.

**$client = new Elasticsearch\Client();**


推荐答案

根据索引操作源代码以下内容应该有效

As per index operations and source code the following should work

 $client = new Elasticsearch\Client();
 $indexParams['index']  = 'my_index';   
 $client->indices()->exists($indexParams);

这篇关于检查索引是否存在Elasticsearch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆