Hi everyone!
I am pretty new to Elasticsearch, sorry if this is too dumb or newbie.
I am having problems with Curl Timeout exceeding 60 seconds and its configuration.
Here is the error message:
FatalErrorException in CurlFactory.php line 169:
Maximum execution time of 60 seconds exceeded
I have tried:
Issue 259 on github
direct setting as params
and a couple more stuff found on stackoverflow:
Stackoverflow - set connect timeout of elasticsearch-php-client
I am integrating elasticsearch with Laravel, in a very simple way. So, here is the class I have developed for this integration. Sorry the mess there is 5.000 character limit, so I had to clean comments up:
// all variables was declared
public function __construct()
{
$this->params = array();
$this->params['hosts'] = $this->host;
$this->params['guzzleOptions']['command.request_options']['connect_timeout'] = 240; // Standard value 2.0
$this->params['guzzleOptions']['command.request_options']['timeout'] = 240; // Standard value 2.0
$this->client = \Elasticsearch\ClientBuilder::create($this->params)
->setHosts([$this->host])
->build();
}
public function index()
{
$this->destroy();
$this->create();
$this->map();
$this->indexFile('File1.pdf');
$this->indexFile('File2.pdf');
$this->indexFile('File3.pdf');
$this->indexFile('File4.pdf');
}
public function create()
{
$this->params = [
'index' => $this->index
// ,'client' => [
// 'timeout' => 0, // ten second timeout
// 'connect_timeout' => 0
// ],
];
$this->client->indices()->create($this->params);
}
public function destroy()
{
$this->params = [
'index' => $this->index
];
$this->client->indices()->delete($this->params);
}
public function map()
{
$this->params = [
'index' => $this->index,
'type' => $this->type,
'body' => [
$this->type => [
'properties' => [
'file' => [
'type' => 'attachment',
'fields' => [
'content' => [
'type' => 'string',
'term_vector' => 'with_positions_offsets',
'store' => true
]
]
]
]
]
]
];
$this->client->indices()->putMapping($this->params);
}
public function indexFile($file = null)
{
if ( empty($file) ){
return false;
}
$file = storage_path('app/' . $this->file_path . $file);
if ( is_file($file) ) {
$this->params = [
'index' => $this->index,
'type' => $this->type,
'timeout' => '5m',
// Curl timeoute Option 4
// 'client' => [
// 'timeout' => 0, // ten second timeout
// 'connect_timeout' => 0
// ],
'body' => [
'file' => [
'_content_type' => 'application/pdf',
'_name' => $file,
'_language' => 'en',
'_indexed_chars' => -1,
'_content' => base64_encode(file_get_contents($file))
]
]
];
$this->client->index($this->params);
echo 'File "' . $file . '" was indexed. <br>';
} else {
return false;
}
}
}
Same error using bulk indexing.
Has anyone faced this issue?
Thanks in advance!