From b49a5ceda558da766ccfc173be08128b8174a057 Mon Sep 17 00:00:00 2001 From: Jean-Yves Gaulier Date: Thu, 16 Jun 2016 17:57:04 +0200 Subject: [PATCH] PHRAS-1168_Backport-PHRAS-1094-to-4.0 (update php-es lib) #time 30m --- composer.json | 2 +- composer.lock | 186 +++++++++++++++--- .../Provider/SearchEngineServiceProvider.php | 10 +- .../Phrasea/SearchEngine/Elastic/Mapping.php | 2 +- 4 files changed, 174 insertions(+), 26 deletions(-) diff --git a/composer.json b/composer.json index 7cea511838..fb3ffae859 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,7 @@ "doctrine/dbal": "^2.4.0", "doctrine/migrations": "^1.0.0", "doctrine/orm": "^2.4.0", - "elasticsearch/elasticsearch": "~1.0", + "elasticsearch/elasticsearch": "~2.0", "facebook/php-sdk": "~3.0", "firebase/php-jwt": "^3.0.0", "gedmo/doctrine-extensions": "~2.3.0", diff --git a/composer.lock b/composer.lock index fca9ad411e..316a3973d4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "2616c9fc141c685253e273bdd5f86615", - "content-hash": "74a482beb3bad7804259216b8064d2fb", + "hash": "1b102f9b60789a197a29c15c52767326", + "content-hash": "b6baa316987eb18f33c731ed8bf9fcff", "packages": [ { "name": "alchemy-fr/tcpdf-clone", @@ -1744,47 +1744,44 @@ }, { "name": "elasticsearch/elasticsearch", - "version": "v1.1.0", + "version": "v2.2.0", "source": { "type": "git", "url": "https://github.com/elastic/elasticsearch-php.git", - "reference": "fd304b1c12778c9eab9b1c1a9e07d791f40bd56d" + "reference": "11ebdf2c847d0e2c4a47ac993485beb5a19d5dc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/elastic/elasticsearch-php/zipball/fd304b1c12778c9eab9b1c1a9e07d791f40bd56d", - "reference": "fd304b1c12778c9eab9b1c1a9e07d791f40bd56d", + "url": "https://api.github.com/repos/elastic/elasticsearch-php/zipball/11ebdf2c847d0e2c4a47ac993485beb5a19d5dc4", + "reference": "11ebdf2c847d0e2c4a47ac993485beb5a19d5dc4", "shasum": "" }, "require": { - "ext-curl": "*", - "guzzle/guzzle": "~3.7", - "monolog/monolog": "~1.5", - "php": ">=5.3.9", - "pimple/pimple": "~1.0", + "guzzlehttp/ringphp": "~1.0", + "php": ">=5.4", "psr/log": "~1.0" }, "require-dev": { - "athletic/athletic": "~0.1", "cpliakas/git-wrapper": "~1.0", - "mikey179/vfsstream": "~1.2", - "mockery/mockery": "dev-master@dev", - "phpunit/phpunit": "3.7.*", - "satooshi/php-coveralls": "dev-master", + "mockery/mockery": "0.9.4", + "phpunit/phpunit": "~4.7", + "sami/sami": "~3.2", "symfony/yaml": "2.4.3 as 2.4.2", "twig/twig": "1.*" }, + "suggest": { + "ext-curl": "*", + "monolog/monolog": "Allows for client-level logging and tracing" + }, "type": "library", "autoload": { - "psr-0": { - "Elasticsearch": "src/", - "Elasticsearch\\Tests": "tests/", - "Elasticsearch\\Benchmarks": "benchmarks/" + "psr-4": { + "Elasticsearch\\": "src/Elasticsearch/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "Apache 2" + "Apache-2.0" ], "authors": [ { @@ -1797,7 +1794,7 @@ "elasticsearch", "search" ], - "time": "2014-05-07 15:54:46" + "time": "2016-06-03 21:09:29" }, { "name": "evenement/evenement", @@ -2159,6 +2156,107 @@ ], "time": "2015-03-18 18:23:50" }, + { + "name": "guzzlehttp/ringphp", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/RingPHP.git", + "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/dbbb91d7f6c191e5e405e900e3102ac7f261bc0b", + "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b", + "shasum": "" + }, + "require": { + "guzzlehttp/streams": "~3.0", + "php": ">=5.4.0", + "react/promise": "~2.0" + }, + "require-dev": { + "ext-curl": "*", + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "ext-curl": "Guzzle will use specific adapters if cURL is present" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Ring\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.", + "time": "2015-05-20 03:37:09" + }, + { + "name": "guzzlehttp/streams", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/streams.git", + "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/streams/zipball/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5", + "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Stream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Provides a simple abstraction over streams of data", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "Guzzle", + "stream" + ], + "time": "2014-10-12 19:18:40" + }, { "name": "hoa/compiler", "version": "2.15.10.29", @@ -4813,6 +4911,50 @@ ], "time": "2016-04-24 00:30:41" }, + { + "name": "react/promise", + "version": "v2.4.1", + "source": { + "type": "git", + "url": "https://github.com/reactphp/promise.git", + "reference": "8025426794f1944de806618671d4fa476dc7626f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/promise/zipball/8025426794f1944de806618671d4fa476dc7626f", + "reference": "8025426794f1944de806618671d4fa476dc7626f", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "React\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com" + } + ], + "description": "A lightweight implementation of CommonJS Promises/A for PHP", + "time": "2016-05-03 17:50:52" + }, { "name": "roave/security-advisories", "version": "dev-master", diff --git a/lib/Alchemy/Phrasea/Core/Provider/SearchEngineServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/SearchEngineServiceProvider.php index d78e5f6dca..ac9bdb8c4a 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/SearchEngineServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/SearchEngineServiceProvider.php @@ -29,7 +29,7 @@ use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryContextFactory; use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryCompiler; use Alchemy\Phrasea\SearchEngine\Elastic\Structure\GlobalStructure; use Alchemy\Phrasea\SearchEngine\Elastic\Thesaurus; -use Elasticsearch\Client; +use Elasticsearch\ClientBuilder; use Hoa\Compiler; use Hoa\File; use Monolog\Handler\ErrorLogHandler; @@ -153,7 +153,13 @@ class SearchEngineServiceProvider implements ServiceProviderInterface $clientParams['logging'] = true; } - return new Client($clientParams); + $clientBuilder = ClientBuilder::create() + ->setHosts($clientParams['hosts']); + if (array_key_exists('logObject', $clientParams)) { + $clientBuilder->setLogger($clientParams['logObject']); + } + + return $clientBuilder->build(); }); $app['elasticsearch.options'] = $app->share(function($app) { diff --git a/lib/Alchemy/Phrasea/SearchEngine/Elastic/Mapping.php b/lib/Alchemy/Phrasea/SearchEngine/Elastic/Mapping.php index aad818cc95..90558d315a 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Elastic/Mapping.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Elastic/Mapping.php @@ -106,7 +106,7 @@ class Mapping unset($field['index_analyzer'], $field['search_analyzer']); break; case 'indexing': - $field['index_analyzer'] = $analyzer; + $field['analyzer'] = $analyzer; break; case 'searching': $field['search_analyzer'] = $analyzer;