我需要一个来自Elasticsearch的符合特定模式的索引名称列表。使用Kibana我可以做到这一点,但我只是想不出如何使用Elasticsearch-PHP客户端来做同样的事情。
示例:
Trying to get indices matching the name pattern "*.foo.bar"
With Kibana: GET /_cat/indices/*.foo.bar有人知道吗?我在Elasticsearch-PHP文档中没有找到任何关于这方面的东西。
发布于 2018-04-20 20:26:36
我通过反复试验找出了答案。
获取匹配模式的索引列表的方法是:
$client = ClientBuilder::create()->build();
$indices = $client->cat()->indices(array('index' => '*.foo.bar'));发布于 2019-11-13 06:05:16
在此响应(7.2)时的current docs中,您可以找到您正在查找的端点GET /_cat/indices/的文档。
因此,您可以使用以下代码获取索引:
$params = [
// Example of another param
'v' => true,
// ...
'index' => '*.foo.bar'
];
$indices = $client->cat()->indices($params);文档并没有明确说明index参数,但是您可以看到索引是如何在CatNamespace::indices()方法定义中设置的。
public function indices(array $params = [])
{
$index = $this->extractArgument($params, 'index');
...
$endpoint->setIndex($index);
...
}https://stackoverflow.com/questions/49940971
复制相似问题