Hi,
I'm trying to fire multiple search requests in parallel (same input but different queries) to save on execution time - running them in series seems wasteful. I'm using PHP 7.4 and ES 7.5.2 at the moment, running "regular" searches and msearches works fine using the PHP client. After some research I'd say that "async search" calls perfectly fit my needs, but I cannot get them running using the PHP client. I don't have much experience with ES so it's probably something trivial, but I can't figure out the correct syntax and/or order of operations. I understand I should first submit my request to then check on its completion using the id I have been given, but with my current code I'm not even getting that far. The only code that does not produce an immediate exception (but an endless loop) is this:
<?php
require 'vendor/autoload.php';
$es_client = Elasticsearch\ClientBuilder::create()->build();
$index_name = 'my_index';
$user_input = "some escaped user input";
$search_params = [
'index' => $index_name,
'body' => [
"query"=> [
"bool"=> [
"must"=> [
"multi_match"=> [
"query"=> $user_input,
"fields"=> ['field_x^10', 'field_y^20'],
]
],
]
]
]
];
$results = $es_client->asyncSearch($search_params);
print_r($results);
Running get() or status() tells me I'm "missing parameters for the endpoint", but that information is not helpful to me at this point. Running submit() with my $search_params tells me "Rejecting mapping update to [my_index] as the final mapping would have more than 1 type: [_doc, _async_search]".
Any help is greatly appreciated!