Caveats to Future mode
editCaveats to Future mode
editThere are a few caveats to using future mode. The biggest is also the most obvious: you need to deal with resolving the future yourself. This is usually trivial, but can sometimes introduce unexpected complications.
For example, if you resolve manually using wait()
, you may need to call wait()
several times if there were retries.
This is because each retry will introduce another layer of wrapped futures, and each needs to be resolved to get the
final result.
This is not needed if you access values via the ArrayInterface however (e.g. $response['hits']['hits']
), since
FutureArrayInterface will automatically and fully resolve the future to provide values.
Another caveat is that certain APIs will lose their "helper" functionality. For example, "exists" APIs (e.g.
$client->exists()
, $client->indices()->exists
, $client->indices->templateExists()
, etc) typically return a true
or false under normal operation.
When operated in future mode, unwrapping of the future is left to your application, which means the client can no longer inspect the response and return a simple true/false. Instead, you’ll see the raw response from Elasticsearch and will have to take action appropriately.
This also applies to ping()
.