Index from multi indexes with elasticsearch-PHP

here is my problem:
I have many messages data in elasticsearch db, these data are stored in the same type but different index according to the date. for example, all the messages today are stored in the message_2019-04-13 index. now i want to search all the messages sent by someone with elasticsearch-PHP:

$arr = [
    'index' => 'messages_*',
    'type' => 'doc',
    'body' => [
        'query' => [
             'bool' => [
                 'must' => [
                      ['match' => ['from_user_id' => 1]],
                      ['match' => ['from_user_type' => 'admin']],
                 ],
             ],
         ]
     ]
];
$clientBuilder = ClientBuilder::create();
$clientBuilder->setHosts('127.0.0.1');
$clientBuilder->setRetries(3);
$client = $clientBuilder->build();
$res = $client->search($arr);

But it doesnt work, how can i do?

i have read the api document and find a solution:
1.use the get mappings api to get the index list

$params = [
    'index' => 'messages_*',
    'type' => 'doc'
];
$response = $client->indices()->getMapping($params);

2.loop the index list and get the documents by the same search fields condition.
that means i have to run two circulations to gain the result. If the one i want to search have no messages in the first 10 days, i still have to search the index list from the first day. Is there a more efficient solution?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.