mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Add compatibility with elasticsearch 1
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
"dailymotion/sdk" : "~1.5",
|
||||
"data-uri/data-uri" : "~0.1.0",
|
||||
"doctrine/orm" : "~2.4.0",
|
||||
"elasticsearch/elasticsearch" : "~0.4",
|
||||
"elasticsearch/elasticsearch" : "~1.0",
|
||||
"facebook/php-sdk" : "~3.0",
|
||||
"gedmo/doctrine-extensions" : "~2.3.0",
|
||||
"alchemy/google-plus-api-client" : "~0.6.2",
|
||||
|
17
composer.lock
generated
17
composer.lock
generated
@@ -3,7 +3,7 @@
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
|
||||
],
|
||||
"hash": "0d8e038306a0c58deac6187e6a607e71",
|
||||
"hash": "88bbe728663cb23ecfba31d240af17c3",
|
||||
"packages": [
|
||||
{
|
||||
"name": "alchemy-fr/tcpdf-clone",
|
||||
@@ -1150,16 +1150,16 @@
|
||||
},
|
||||
{
|
||||
"name": "elasticsearch/elasticsearch",
|
||||
"version": "v0.4.4",
|
||||
"version": "v1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/elasticsearch/elasticsearch-php.git",
|
||||
"reference": "53df7beea2d66b3ec41e023945e97fe0e240f72b"
|
||||
"reference": "09a81a85ab015cd1350c622bebe9111941259782"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/elasticsearch/elasticsearch-php/zipball/53df7beea2d66b3ec41e023945e97fe0e240f72b",
|
||||
"reference": "53df7beea2d66b3ec41e023945e97fe0e240f72b",
|
||||
"url": "https://api.github.com/repos/elasticsearch/elasticsearch-php/zipball/09a81a85ab015cd1350c622bebe9111941259782",
|
||||
"reference": "09a81a85ab015cd1350c622bebe9111941259782",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1172,12 +1172,13 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"athletic/athletic": "~0.1",
|
||||
"elasticsearch/elasticsearch_src": "*",
|
||||
"elasticsearch/elasticsearch_src": "dev-master",
|
||||
"mikey179/vfsstream": "~1.2",
|
||||
"mockery/mockery": "dev-master@dev",
|
||||
"phpunit/phpunit": "3.7.*",
|
||||
"satooshi/php-coveralls": "dev-master",
|
||||
"symfony/yaml": "2.4.*@dev"
|
||||
"symfony/yaml": "2.4.*@dev",
|
||||
"twig/twig": "1.*"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
@@ -1202,7 +1203,7 @@
|
||||
"elasticsearch",
|
||||
"search"
|
||||
],
|
||||
"time": "2014-01-07 22:34:33"
|
||||
"time": "2014-02-12 14:57:02"
|
||||
},
|
||||
{
|
||||
"name": "evenement/evenement",
|
||||
|
@@ -286,8 +286,9 @@ class ElasticSearchEngine implements SearchEngineInterface
|
||||
$n = 0;
|
||||
|
||||
foreach ($res['hits']['hits'] as $hit) {
|
||||
$results[] = new \record_adapter($this->app, $hit['fields']['databox_id'], $hit['fields']['record_id'], $n);
|
||||
$n++;
|
||||
$databoxId = is_array($hit['fields']['databox_id']) ? array_pop($hit['fields']['databox_id']) : $hit['fields']['databox_id'];
|
||||
$recordId = is_array($hit['fields']['record_id']) ? array_pop($hit['fields']['record_id']) : $hit['fields']['record_id'];
|
||||
$results[] = new \record_adapter($this->app, $databoxId, $recordId, $n++);
|
||||
}
|
||||
|
||||
return new SearchEngineResult($results, $query, $res['took'], $offset, $res['hits']['total'], $res['hits']['total'], null, null, $suggestions, [], $this->indexName);
|
||||
@@ -310,6 +311,7 @@ class ElasticSearchEngine implements SearchEngineInterface
|
||||
$params = $this->createQueryParams($query, $options ?: new SearchEngineOptions(), $record);
|
||||
|
||||
$res = $this->doExecute('search', $params);
|
||||
$ret = [];
|
||||
|
||||
foreach ($fields as $name => $field) {
|
||||
if (isset($res['hits']['hits'][0]['highlight']['caption.'.$name])) {
|
||||
|
@@ -246,11 +246,23 @@ class Indexer
|
||||
|
||||
$ret = $this->engine->getClient()->indices()->create($indexParams);
|
||||
|
||||
if (isset($ret['error']) || !$ret['ok']) {
|
||||
if (!$this->isResultOk($ret)) {
|
||||
throw new \RuntimeException('Unable to create index');
|
||||
}
|
||||
}
|
||||
|
||||
private function isResultOk(array $ret)
|
||||
{
|
||||
if (isset($ret['acknowledged']) && $ret['acknowledged']) {
|
||||
return true;
|
||||
}
|
||||
if (isset($ret['ok']) && $ret['ok']) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function reindexAll()
|
||||
{
|
||||
$qty = 10;
|
||||
@@ -260,7 +272,7 @@ class Indexer
|
||||
|
||||
$ret = $this->engine->getClient()->indices()->putSettings($params);
|
||||
|
||||
if (!isset($ret['ok']) || !$ret['ok']) {
|
||||
if (!$this->isResultOk($ret)) {
|
||||
$this->logger->error('Unable to set the refresh interval to 300 s. .');
|
||||
}
|
||||
|
||||
@@ -290,7 +302,7 @@ class Indexer
|
||||
|
||||
$ret = $this->engine->getClient()->indices()->putSettings($params);
|
||||
|
||||
if (!isset($ret['ok']) || !$ret['ok']) {
|
||||
if (!$this->isResultOk($ret)) {
|
||||
throw new \RuntimeException('Unable to set the refresh interval to 1 s. .');
|
||||
}
|
||||
}
|
||||
|
@@ -165,7 +165,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
||||
$this->record_id = (int) $record_id;
|
||||
|
||||
return $this->load();
|
||||
;
|
||||
}
|
||||
|
||||
protected function load()
|
||||
|
Reference in New Issue
Block a user