Answer the question
In order to leave comments, you need to log in
How to wait for all queries to complete in Elasticsearch?
Hello.
I'll forgive my nubism, but I can't figure out the subject.
In the php script, you need to execute the bulk request and wait until it is all completed. To work with ES, their official lib is used. As I understood from the docks, you can use Future Mode for a solution . But it is not possible to apply it correctly. I use like this:
// вызов функций одну за другой
func_bulk();
func_search();
// выполнение запроса
function func_bulk()
{
$params['client'] = [
'future' => 'lazy'
];
$response = $this->elastic->bulk($params);
while ($response instanceof FutureArray) {
$response = $response->wait();
}
}
// поиск того, что сделано в func_bulk()
function func_search()
{
$params = [
'index' => 'my_index',
'type' => 'my_type',
'id' => 'my_id'
];
$response = $client->get($params);
}
func_search()
finds nothing, because Documents have not yet been indexed. If you insert a sticky type before the function sleep(5)
, it finds everything, but this is not serious. How can you wait until ES finishes its business?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question