I am creating index with alias and I want to get index name from alias in elasticsearch
using php
client library. Below is my code to add alias in index.
$params['body'] = array(
'actions' => array(
array(
'add' => array(
'index' => 'solatiers_with_alias',
'alias' => 'solatiers_alias'
)
)
)
);
$client->indices()->updateAliases($params);
How can I retrieve index name from alias?
You can get retrieve index name by
function myfunction($value,$key)
{
if($key="index"){
echo $value;
break;
}
}
array_walk_recursive($params['body'],"myfunction");
You could do it like this:
echo $params['body']['actions'][0]['add']['index'];
There are other ways to write this with different syntax like $params->body->actions etc but mixing associative keys with numerical ones is a PITA in this case.