I have an elasticsearch that is working fine and so is my php client used to query the index. However, my client works only with one index. When I try adding multiple indices in a string as shown here my code breaks.
Here is a snippet of my code:
if ($q2 == '') {
$query = $client->search([
'index' => 'trial2',
'body' => [
'from' => $from,
'size' => $size,
'query' => [
'multi_match' => [
'query' => $q,
'operator' => $op,
'fields' => ['content','file','file.extension','meta', 'path']
]
]
]
]);
$data['q'] = $q;
}
elseif ($q2 == "docx") {
$params = [
'index' => 'trial2',
'type' => '_doc',
'body' => [
'query' => [
'bool' => [
'must' => [
[ 'terms' => [ 'file.extension' => ["docx", "doc", "txt", "rtf"] ] ],
[ 'match' => [ 'content' => $q ] ],
]
]
]
]
];
$query = $client->search($params);
$data['q'] = $q;
}
I would like to query several indexes (trial2, trial3 and trial4). How do I do it?