From c18302abf429cded51fcc3d5bc3075b3bd18d6d6 Mon Sep 17 00:00:00 2001 From: Douglas Greenshields Date: Thu, 24 Dec 2015 16:13:53 +0000 Subject: [PATCH 01/20] stop allowing travis test failures for HHVM --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index cb29a5cc5..f11c4c9a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,8 +25,6 @@ after_script: vendor/bin/coveralls -v matrix: allow_failures: - php: 5.3 - - php: hhvm - php: nightly - sudo: false From f6172d869dadac8074bc37a109d55a988fedda58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Goetz?= Date: Mon, 4 Jan 2016 22:17:28 +0100 Subject: [PATCH 02/20] Allow symfony/class-loader 3.0 to be installed --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 63536dd1d..29cd8fe01 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ ], "require": { "php": ">=5.3.2", - "symfony/event-dispatcher": "~2.3" + "symfony/event-dispatcher": "~2.3|~3.0" }, "require-dev": { "phpunit/phpunit": "~3.7", From fc453b87d4a5a51ab51fc3e1fe8f137961a321fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Goetz?= Date: Mon, 4 Jan 2016 22:21:22 +0100 Subject: [PATCH 03/20] Add symfony 3.0 to the array of tested versions --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 39b13061b..c80c33133 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ env: - SYMFONY_VERSION=2.3.* - SYMFONY_VERSION=2.7.* - SYMFONY_VERSION=2.8.* + - SYMFONY_VERSION=3.0.* before_script: - bash -c "if [ $TRAVIS_PHP_VERSION != 'hhvm' ] && [ $TRAVIS_PHP_VERSION != '7.0' ] && [ $TRAVIS_PHP_VERSION != 'nightly' ]; then printf '\n\n\n\n' | pecl install pecl_http-1.7.6; fi" From a91c50bacbc2f6d89c6c757473e62b8f764338be Mon Sep 17 00:00:00 2001 From: Bas de Nooijer Date: Tue, 5 Jan 2016 07:08:17 +0100 Subject: [PATCH 04/20] Update CHANGELOG.md --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3c6b349d..513b15027 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # CHANGELOG + +## 3.6.0 + +- no longer allow failures for HHVM in continuous integration + +## 3.5.1 + +- fix backwards incompatible change in classnames + ## 3.5.0 - 2015-12-09 - improvement: lots of code style fixes From 8b18fcb604c42f455bb968437647b5834ed10a55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ste=CC=81phane=20Goetz?= Date: Tue, 5 Jan 2016 21:08:10 +0100 Subject: [PATCH 05/20] Call setDispatcher only if it exists (if it doesn't exist, it isnt needed) --- .../Solarium/Tests/Core/Client/ClientTest.php | 91 +++++++++++++------ 1 file changed, 61 insertions(+), 30 deletions(-) diff --git a/tests/Solarium/Tests/Core/Client/ClientTest.php b/tests/Solarium/Tests/Core/Client/ClientTest.php index 05070f0e4..51360190b 100644 --- a/tests/Solarium/Tests/Core/Client/ClientTest.php +++ b/tests/Solarium/Tests/Core/Client/ClientTest.php @@ -570,8 +570,10 @@ public function testCreateRequestPrePlugin() { $query = new SelectQuery(); $expectedEvent = new PreCreateRequestEvent($query); - $expectedEvent->setDispatcher($this->client->getEventDispatcher()); - $expectedEvent->setName(Events::PRE_CREATE_REQUEST); + if (method_exists($expectedEvent, 'setDispatcher')) { + $expectedEvent->setDispatcher($this->client->getEventDispatcher()); + $expectedEvent->setName(Events::PRE_CREATE_REQUEST); + } $observer = $this->getMock('Solarium\Core\Plugin\AbstractPlugin', array('preCreateRequest')); $observer->expects($this->once()) @@ -592,8 +594,10 @@ public function testCreateRequestPostPlugin() $query = new SelectQuery(); $request = $this->client->createRequest($query); $expectedEvent = new PostCreateRequestEvent($query, $request); - $expectedEvent->setDispatcher($this->client->getEventDispatcher()); - $expectedEvent->setName(Events::POST_CREATE_REQUEST); + if (method_exists($expectedEvent, 'setDispatcher')) { + $expectedEvent->setDispatcher($this->client->getEventDispatcher()); + $expectedEvent->setName(Events::POST_CREATE_REQUEST); + } $observer = $this->getMock('Solarium\Core\Plugin\AbstractPlugin', array('postCreateRequest')); $observer->expects($this->once()) @@ -616,8 +620,10 @@ public function testCreateRequestWithOverridingPlugin() $query = new SelectQuery(); $expectedEvent = new PreCreateRequestEvent($query); - $expectedEvent->setDispatcher($this->client->getEventDispatcher()); - $expectedEvent->setName(Events::PRE_CREATE_REQUEST); + if (method_exists($expectedEvent, 'setDispatcher')) { + $expectedEvent->setDispatcher($this->client->getEventDispatcher()); + $expectedEvent->setName(Events::PRE_CREATE_REQUEST); + } $test = $this; $this->client->getEventDispatcher()->addListener( @@ -653,8 +659,10 @@ public function testCreateResultPrePlugin() $query = new SelectQuery(); $response = new Response('', array('HTTP 1.0 200 OK')); $expectedEvent = new PreCreateResultEvent($query, $response); - $expectedEvent->setDispatcher($this->client->getEventDispatcher()); - $expectedEvent->setName(Events::PRE_CREATE_RESULT); + if (method_exists($expectedEvent, 'setDispatcher')) { + $expectedEvent->setDispatcher($this->client->getEventDispatcher()); + $expectedEvent->setName(Events::PRE_CREATE_RESULT); + } $observer = $this->getMock('Solarium\Core\Plugin\AbstractPlugin', array('preCreateResult')); $observer->expects($this->once()) @@ -676,8 +684,10 @@ public function testCreateResultPostPlugin() $response = new Response('', array('HTTP 1.0 200 OK')); $result = $this->client->createResult($query, $response); $expectedEvent = new PostCreateResultEvent($query, $response, $result); - $expectedEvent->setDispatcher($this->client->getEventDispatcher()); - $expectedEvent->setName(Events::POST_CREATE_RESULT); + if (method_exists($expectedEvent, 'setDispatcher')) { + $expectedEvent->setDispatcher($this->client->getEventDispatcher()); + $expectedEvent->setName(Events::POST_CREATE_RESULT); + } $observer = $this->getMock('Solarium\Core\Plugin\AbstractPlugin', array('postCreateResult')); $observer->expects($this->once()) @@ -698,8 +708,10 @@ public function testCreateResultWithOverridingPlugin() $query = new SelectQuery(); $response = new Response('test 1234', array('HTTP 1.0 200 OK')); $expectedEvent = new PreCreateResultEvent($query, $response); - $expectedEvent->setDispatcher($this->client->getEventDispatcher()); - $expectedEvent->setName(Events::PRE_CREATE_RESULT); + if (method_exists($expectedEvent, 'setDispatcher')) { + $expectedEvent->setDispatcher($this->client->getEventDispatcher()); + $expectedEvent->setName(Events::PRE_CREATE_RESULT); + } $expectedResult = new Result($this->client, $query, $response); $test = $this; @@ -768,7 +780,7 @@ public function testExecutePrePlugin() $response = new Response('', array('HTTP 1.0 200 OK')); $result = new Result($this->client, $query, $response); $expectedEvent = new PreExecuteEvent($query); - $expectedEvent->setName(Events::PRE_EXECUTE); + $mock = $this->getMock('Solarium\Core\Client\Client', array('createRequest', 'executeRequest', 'createResult')); @@ -791,7 +803,10 @@ public function testExecutePrePlugin() $mock->getEventDispatcher()->addListener(Events::PRE_EXECUTE, array($observer, 'preExecute')); - $expectedEvent->setDispatcher($mock->getEventDispatcher()); + if (method_exists($expectedEvent, 'setDispatcher')) { + $expectedEvent->setName(Events::PRE_EXECUTE); + $expectedEvent->setDispatcher($mock->getEventDispatcher()); + } $mock->execute($query); } @@ -802,7 +817,6 @@ public function testExecutePostPlugin() $response = new Response('', array('HTTP 1.0 200 OK')); $result = new Result($this->client, $query, $response); $expectedEvent = new PostExecuteEvent($query, $result); - $expectedEvent->setName(Events::POST_EXECUTE); $mock = $this->getMock('Solarium\Core\Client\Client', array('createRequest', 'executeRequest', 'createResult')); @@ -825,7 +839,10 @@ public function testExecutePostPlugin() $mock->getEventDispatcher()->addListener(Events::POST_EXECUTE, array($observer, 'postExecute')); - $expectedEvent->setDispatcher($mock->getEventDispatcher()); + if (method_exists($expectedEvent, 'setDispatcher')) { + $expectedEvent->setName(Events::POST_EXECUTE); + $expectedEvent->setDispatcher($mock->getEventDispatcher()); + } $mock->execute($query); } @@ -836,8 +853,10 @@ public function testExecuteWithOverridingPlugin() $response = new Response('', array('HTTP 1.0 200 OK')); $expectedResult = new Result($this->client, $query, $response); $expectedEvent = new PreExecuteEvent($query); - $expectedEvent->setDispatcher($this->client->getEventDispatcher()); - $expectedEvent->setName(Events::PRE_EXECUTE); + if (method_exists($expectedEvent, 'setDispatcher')) { + $expectedEvent->setDispatcher($this->client->getEventDispatcher()); + $expectedEvent->setName(Events::PRE_EXECUTE); + } $test = $this; $this->client->getEventDispatcher()->addListener( @@ -882,8 +901,10 @@ public function testExecuteRequestPrePlugin() $endpoint = $this->client->createEndpoint('s1'); $response = new Response('', array('HTTP 1.0 200 OK')); $expectedEvent = new PreExecuteRequestEvent($request, $endpoint); - $expectedEvent->setDispatcher($this->client->getEventDispatcher()); - $expectedEvent->setName(Events::PRE_EXECUTE_REQUEST); + if (method_exists($expectedEvent, 'setDispatcher')) { + $expectedEvent->setDispatcher($this->client->getEventDispatcher()); + $expectedEvent->setName(Events::PRE_EXECUTE_REQUEST); + } $mockAdapter = $this->getMock('Solarium\Core\Client\Adapter\Http', array('execute')); $mockAdapter->expects($this->once()) @@ -910,8 +931,10 @@ public function testExecuteRequestPostPlugin() $endpoint = $this->client->createEndpoint('s1'); $response = new Response('', array('HTTP 1.0 200 OK')); $expectedEvent = new PostExecuteRequestEvent($request, $endpoint, $response); - $expectedEvent->setDispatcher($this->client->getEventDispatcher()); - $expectedEvent->setName(Events::POST_EXECUTE_REQUEST); + if (method_exists($expectedEvent, 'setDispatcher')) { + $expectedEvent->setDispatcher($this->client->getEventDispatcher()); + $expectedEvent->setName(Events::POST_EXECUTE_REQUEST); + } $mockAdapter = $this->getMock('Solarium\Core\Client\Adapter\Http', array('execute')); $mockAdapter->expects($this->any()) @@ -938,8 +961,10 @@ public function testExecuteRequestWithOverridingPlugin() $response = new Response('', array('HTTP 1.0 200 OK')); $endpoint = $this->client->createEndpoint('s1'); $expectedEvent = new PreExecuteRequestEvent($request, $endpoint); - $expectedEvent->setDispatcher($this->client->getEventDispatcher()); - $expectedEvent->setName(Events::PRE_EXECUTE_REQUEST); + if (method_exists($expectedEvent, 'setDispatcher')) { + $expectedEvent->setDispatcher($this->client->getEventDispatcher()); + $expectedEvent->setName(Events::PRE_EXECUTE_REQUEST); + } $test = $this; $this->client->getEventDispatcher()->addListener( @@ -1088,8 +1113,10 @@ public function testCreateQueryPrePlugin() $type = Client::QUERY_SELECT; $options = array('optionA' => 1, 'optionB' => 2); $expectedEvent = new PreCreateQueryEvent($type, $options); - $expectedEvent->setDispatcher($this->client->getEventDispatcher()); - $expectedEvent->setName(Events::PRE_CREATE_QUERY); + if (method_exists($expectedEvent, 'setDispatcher')) { + $expectedEvent->setDispatcher($this->client->getEventDispatcher()); + $expectedEvent->setName(Events::PRE_CREATE_QUERY); + } $observer = $this->getMock('Solarium\Core\Plugin\AbstractPlugin', array('preCreateQuery')); $observer->expects($this->once()) @@ -1107,8 +1134,10 @@ public function testCreateQueryWithOverridingPlugin() $expectedQuery = new SelectQuery(); $expectedQuery->setQuery('test789'); $expectedEvent = new PreCreateQueryEvent($type, $options); - $expectedEvent->setDispatcher($this->client->getEventDispatcher()); - $expectedEvent->setName(Events::PRE_CREATE_QUERY); + if (method_exists($expectedEvent, 'setDispatcher')) { + $expectedEvent->setDispatcher($this->client->getEventDispatcher()); + $expectedEvent->setName(Events::PRE_CREATE_QUERY); + } $test = $this; $this->client->getEventDispatcher()->addListener( @@ -1133,8 +1162,10 @@ public function testCreateQueryPostPlugin() $options = array('optionA' => 1, 'optionB' => 2); $query = $this->client->createQuery($type, $options); $expectedEvent = new PostCreateQueryEvent($type, $options, $query); - $expectedEvent->setDispatcher($this->client->getEventDispatcher()); - $expectedEvent->setName(Events::POST_CREATE_QUERY); + if (method_exists($expectedEvent, 'setDispatcher')) { + $expectedEvent->setDispatcher($this->client->getEventDispatcher()); + $expectedEvent->setName(Events::POST_CREATE_QUERY); + } $observer = $this->getMock('Solarium\Core\Plugin\AbstractPlugin', array('postCreateQuery')); $observer->expects($this->once()) From 39a398ccde01a9bd7a96e6684b1fccd172de828e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ste=CC=81phane=20Goetz?= Date: Tue, 5 Jan 2016 21:29:21 +0100 Subject: [PATCH 06/20] Disable Symfony 3.0 for php 5.3 and 5.4 --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c80c33133..efb255ef6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ env: - SYMFONY_VERSION=2.3.* - SYMFONY_VERSION=2.7.* - SYMFONY_VERSION=2.8.* - - SYMFONY_VERSION=3.0.* + - SYMFONY_VERSION=3.0.* # Does not work with php below 5.5 before_script: - bash -c "if [ $TRAVIS_PHP_VERSION != 'hhvm' ] && [ $TRAVIS_PHP_VERSION != '7.0' ] && [ $TRAVIS_PHP_VERSION != 'nightly' ]; then printf '\n\n\n\n' | pecl install pecl_http-1.7.6; fi" @@ -24,6 +24,11 @@ script: vendor/bin/phpunit -c phpunit.xml.travis -v after_script: vendor/bin/coveralls -v matrix: + exclude: + - php: 5.3 + env: SYMFONY_VERSION=3.0.* + - php: 5.4 + env: SYMFONY_VERSION=3.0.* allow_failures: - php: 5.3 - php: hhvm From 2c1b0484c15076f05e04248bf4b642a0d8eeeafd Mon Sep 17 00:00:00 2001 From: wickedOne Date: Thu, 14 Jan 2016 14:02:52 +0100 Subject: [PATCH 07/20] added support for replicas in distributed search addition of the replicas property so the request builder can use both shards and replicas in the shard param --- .../distributed-search-component.md | 1 + .../Query/Component/DistributedSearch.php | 98 +++++++++++++++++++ .../Component/DistributedSearch.php | 8 ++ .../Query/Component/DistributedSearchTest.php | 82 ++++++++++++++++ .../Query/Component/Facet/IntervalTest.php | 88 +++++++++++++++++ .../Component/DistributedSearchTest.php | 43 ++++++++ .../RequestBuilder/Component/FacetSetTest.php | 26 +++++ 7 files changed, 346 insertions(+) create mode 100644 tests/Solarium/Tests/QueryType/Select/Query/Component/Facet/IntervalTest.php diff --git a/docs/queries/select-query/building-a-select-query/components/distributed-search-component.md b/docs/queries/select-query/building-a-select-query/components/distributed-search-component.md index 510f7551c..951e3aa87 100644 --- a/docs/queries/select-query/building-a-select-query/components/distributed-search-component.md +++ b/docs/queries/select-query/building-a-select-query/components/distributed-search-component.md @@ -8,6 +8,7 @@ Options | shards | string | null | Shards to use for request | | shardhandler | string | null | Request handler to use | | collections | string | null | A list of collections, for use with SolrCloud (available in Solarium 3.1+) | +| replicas | string | null | A list of replicas, for use with SolrCloud (available in Solarium 3.1+) | || Example diff --git a/library/Solarium/QueryType/Select/Query/Component/DistributedSearch.php b/library/Solarium/QueryType/Select/Query/Component/DistributedSearch.php index 5e6c9f05a..b4341d102 100644 --- a/library/Solarium/QueryType/Select/Query/Component/DistributedSearch.php +++ b/library/Solarium/QueryType/Select/Query/Component/DistributedSearch.php @@ -65,6 +65,13 @@ class DistributedSearch extends AbstractComponent */ protected $collections = array(); + /** + * Requests will be load balanced across replicas in this list. + * + * @var array + */ + protected $replicas = array(); + /** * Get component type. * @@ -318,6 +325,94 @@ public function getCollections() return $this->collections; } + /** + * Add a replica. + * + * @param string $key unique string + * @param string $replica The syntax is host:port/base_url + * + * @return self Provides fluent interface + * + * @link https://cwiki.apache.org/confluence/display/solr/Distributed+Requests + */ + public function addReplica($key, $replica) + { + $this->replicas[$key] = $replica; + + return $this; + } + + /** + * Add multiple replicas. + * + * @param array $replicas + * + * @return self Provides fluent interface + */ + public function addReplicas(array $replicas) + { + foreach ($replicas as $key => $replica) { + $this->addReplica($key, $replica); + } + + return $this; + } + + /** + * Remove a replica. + * + * @param string $key + * + * @return self Provides fluent interface + */ + public function removeReplica($key) + { + if (isset($this->replicas[$key])) { + unset($this->replicas[$key]); + } + + return $this; + } + + /** + * Remove all replicas. + * + * @return self Provides fluent interface + */ + public function clearReplicas() + { + $this->replicas = array(); + + return $this; + } + + /** + * Set multiple replicas. + * + * This overwrites any existing replicas + * + * @param array $replicas Associative array of collections + * + * @return self Provides fluent interface + */ + public function setReplicas(array $replicas) + { + $this->clearReplicas(); + $this->addReplicas($replicas); + + return $this; + } + + /** + * Get a list of the replicas. + * + * @return array + */ + public function getReplicas() + { + return $this->replicas; + } + /** * Initialize options. * @@ -334,6 +429,9 @@ protected function init() case 'collections': $this->setCollections($value); break; + case 'replicas': + $this->setReplicas($value); + break; } } } diff --git a/library/Solarium/QueryType/Select/RequestBuilder/Component/DistributedSearch.php b/library/Solarium/QueryType/Select/RequestBuilder/Component/DistributedSearch.php index aa5071ca8..80b9ee8f9 100644 --- a/library/Solarium/QueryType/Select/RequestBuilder/Component/DistributedSearch.php +++ b/library/Solarium/QueryType/Select/RequestBuilder/Component/DistributedSearch.php @@ -64,6 +64,14 @@ public function buildComponent($component, $request) $request->addParam('shards', implode(',', $shards)); } + $replicas = array_values($component->getReplicas()); + + if (count($replicas)) { + $value = ($request->getParam('shards')) ? $request->getParam('shards').','.implode('|', $replicas) : implode('|', $replicas); + + $request->addParam('shards', $value, true); + } + $request->addParam('shards.qt', $component->getShardRequestHandler()); // add collections to request diff --git a/tests/Solarium/Tests/QueryType/Select/Query/Component/DistributedSearchTest.php b/tests/Solarium/Tests/QueryType/Select/Query/Component/DistributedSearchTest.php index 78a8a1ea4..bc450264a 100644 --- a/tests/Solarium/Tests/QueryType/Select/Query/Component/DistributedSearchTest.php +++ b/tests/Solarium/Tests/QueryType/Select/Query/Component/DistributedSearchTest.php @@ -75,6 +75,19 @@ public function testConfigModeForCollections() $this->assertEquals($options['collections'], $this->distributedSearch->getCollections()); } + public function testConfigModeForReplicas() + { + $options = array( + 'replicas' => array( + 'replica1' => 'localhost:8983/solr/collection1', + 'replica2' => 'localhost:8983/solr/collection2', + ), + ); + + $this->distributedSearch->setOptions($options); + $this->assertEquals($options['replicas'], $this->distributedSearch->getReplicas()); + } + public function testGetType() { $this->assertEquals( @@ -242,4 +255,73 @@ public function testSetCollections() $collections ); } + + public function testAddReplica() + { + $this->distributedSearch->addReplica('replica1', 'localhost:8983/solr/replica1'); + $replicas = $this->distributedSearch->getReplicas(); + $this->assertEquals( + 'localhost:8983/solr/replica1', + $replicas['replica1'] + ); + } + + public function testRemoveReplica() + { + $this->distributedSearch->addReplica('replica1', 'localhost:8983/solr/replica1'); + $this->distributedSearch->removeReplica('replica1'); + $replicas = $this->distributedSearch->getReplicas(); + $this->assertFalse(isset($replicas['replica1'])); + } + + public function testClearReplicas() + { + $this->distributedSearch->addReplicas( + array( + 'replica1' => 'localhost:8983/solr/replica1', + 'replica2' => 'localhost:8983/solr/replica2', + ) + ); + $this->distributedSearch->clearReplicas(); + $replicas = $this->distributedSearch->getReplicas(); + $this->assertTrue(is_array($replicas)); + $this->assertEquals(0, count($replicas)); + } + + public function testAddReplicas() + { + $replicas = array( + 'replica1' => 'localhost:8983/solr/replica1', + 'replica2' => 'localhost:8983/solr/replica2', + ); + $this->distributedSearch->addReplicas($replicas); + $this->assertEquals($replicas, $this->distributedSearch->getReplicas()); + } + + public function testSetReplicas() + { + $this->distributedSearch->addReplicas( + array( + 'replica1' => 'localhost:8983/solr/replica1', + 'replica2' => 'localhost:8983/solr/replica2', + ) + ); + $this->distributedSearch->setReplicas( + array( + 'replica3' => 'localhost:8983/solr/replica3', + 'replica4' => 'localhost:8983/solr/replica4', + 'replica5' => 'localhost:8983/solr/replica5', + ) + ); + $replicas = $this->distributedSearch->getReplicas(); + $this->assertEquals(3, count($replicas)); + $this->assertEquals( + array( + 'replica3' => 'localhost:8983/solr/replica3', + 'replica4' => 'localhost:8983/solr/replica4', + 'replica5' => 'localhost:8983/solr/replica5', + ), + $replicas + ); + } } diff --git a/tests/Solarium/Tests/QueryType/Select/Query/Component/Facet/IntervalTest.php b/tests/Solarium/Tests/QueryType/Select/Query/Component/Facet/IntervalTest.php new file mode 100644 index 000000000..369711dc5 --- /dev/null +++ b/tests/Solarium/Tests/QueryType/Select/Query/Component/Facet/IntervalTest.php @@ -0,0 +1,88 @@ +facet = new Interval(); + } + + public function testConfigMode() + { + $options = array( + 'key' => 'myKey', + 'exclude' => array('e1', 'e2'), + 'set' => array('i1', 'i2'), + ); + + $this->facet->setOptions($options); + + $this->assertEquals($options['key'], $this->facet->getKey()); + $this->assertEquals($options['exclude'], $this->facet->getExcludes()); + $this->assertEquals($options['set'], $this->facet->getSet()); + } + + public function testGetType() + { + $this->assertEquals( + FacetSet::FACET_INTERVAL, + $this->facet->getType() + ); + } + + public function testSetAndGetSet() + { + $this->facet->setSet('interval1,interval2'); + $this->assertEquals(array('interval1', 'interval2'), $this->facet->getSet()); + } + + public function testEmptySet() + { + $this->assertEquals(array(), $this->facet->getSet()); + } + + public function testSetAndGetField() + { + $this->facet->setField('field1'); + $this->assertEquals('field1', $this->facet->getField()); + } +} diff --git a/tests/Solarium/Tests/QueryType/Select/RequestBuilder/Component/DistributedSearchTest.php b/tests/Solarium/Tests/QueryType/Select/RequestBuilder/Component/DistributedSearchTest.php index 7d8894e79..226ed9ded 100644 --- a/tests/Solarium/Tests/QueryType/Select/RequestBuilder/Component/DistributedSearchTest.php +++ b/tests/Solarium/Tests/QueryType/Select/RequestBuilder/Component/DistributedSearchTest.php @@ -82,4 +82,47 @@ public function testBuildComponentWithCollections() $this->assertEquals(array('collection' => $url.'1,'.$url.'2,'.$url.'3'), $request->getParams()); } + + public function testBuildComponentWithReplicas() + { + $builder = new RequestBuilder(); + $request = new Request(); + + $url = 'localhost:8983/solr/replica'; + $component = new Component(); + $component->addReplica('replica1', $url.'1'); + $component->addReplicas( + array( + 'replica2' => $url.'2', + 'replica3' => $url.'3', + ) + ); + + $request = $builder->buildComponent($component, $request); + + $this->assertEquals(array('shards' => $url.'1|'.$url.'2|'.$url.'3'), $request->getParams()); + } + + + + public function testBuildComponentWithReplicasAndShard() + { + $builder = new RequestBuilder(); + $request = new Request(); + + $url = 'localhost:8983/solr/replica'; + $component = new Component(); + $component->addShard('shard1', 'localhost:8983/solr/shard1'); + + $component->addReplicas( + array( + 'replica2' => $url.'2', + 'replica3' => $url.'3', + ) + ); + + $request = $builder->buildComponent($component, $request); + + $this->assertEquals(array('shards' => 'localhost:8983/solr/shard1,'.$url.'2|'.$url.'3'), $request->getParams()); + } } diff --git a/tests/Solarium/Tests/QueryType/Select/RequestBuilder/Component/FacetSetTest.php b/tests/Solarium/Tests/QueryType/Select/RequestBuilder/Component/FacetSetTest.php index 2fd2c33e7..f1b99117b 100644 --- a/tests/Solarium/Tests/QueryType/Select/RequestBuilder/Component/FacetSetTest.php +++ b/tests/Solarium/Tests/QueryType/Select/RequestBuilder/Component/FacetSetTest.php @@ -39,6 +39,7 @@ use Solarium\QueryType\Select\Query\Component\Facet\MultiQuery as FacetMultiQuery; use Solarium\QueryType\Select\Query\Component\Facet\Range as FacetRange; use Solarium\QueryType\Select\Query\Component\Facet\Pivot as FacetPivot; +use Solarium\QueryType\Select\Query\Component\Facet\Interval as FacetInterval; class FacetSetTest extends \PHPUnit_Framework_TestCase { @@ -259,6 +260,31 @@ public function testBuildWithContainsSettings() urldecode($request->getUri()) ); } + + public function testBuildeWithIntervalFacet() + { + $facet = new FacetInterval( + array( + 'key' => 'f1', + 'fields' => 'cat,inStock', + 'set' => array(0 => 'int1', 'one' => 'int2'), + ) + ); + + $this->component->addFacet($facet); + + $request = $this->builder->buildComponent($this->component, $this->request); + + $this->assertEquals( + null, + $request->getRawData() + ); + + $this->assertEquals( + '?facet=true&f..facet.interval.set=int1&f..facet.interval.set={!key="one"}int2', + urldecode($request->getUri()) + ); + } } class UnknownFacet extends FacetField From 24cfcbbd16ba646e68b60c0c8c597fb3f3274ef3 Mon Sep 17 00:00:00 2001 From: schausson Date: Thu, 14 Jan 2016 14:57:09 +0100 Subject: [PATCH 08/20] Added option to add multiple boostqueries to dismax parser --- .../Select/Query/Component/BoostQuery.php | 130 ++++++++++++++++ .../Select/Query/Component/DisMax.php | 144 +++++++++++++++++- .../RequestBuilder/Component/DisMax.php | 10 +- 3 files changed, 280 insertions(+), 4 deletions(-) create mode 100644 library/Solarium/QueryType/Select/Query/Component/BoostQuery.php diff --git a/library/Solarium/QueryType/Select/Query/Component/BoostQuery.php b/library/Solarium/QueryType/Select/Query/Component/BoostQuery.php new file mode 100644 index 000000000..d377cf313 --- /dev/null +++ b/library/Solarium/QueryType/Select/Query/Component/BoostQuery.php @@ -0,0 +1,130 @@ + + * @license http://github.com/basdenooijer/solarium/raw/master/COPYING + * + * @link http://www.solarium-project.org/ + */ + +/** + * @namespace + */ + +namespace Solarium\QueryType\Select\Query\Component; + +use Solarium\Core\Configurable; +use Solarium\Core\Query\Helper; + +/** + * Filterquery. + * + * @link http://wiki.apache.org/solr/CommonQueryParameters#fq + */ +class BoostQuery extends Configurable +{ + /** + * Query. + * + * @var string + */ + protected $query; + + /** + * Get key value. + * + * @return string + */ + public function getKey() + { + return $this->getOption('key'); + } + + /** + * Set key value. + * + * @param string $value + * + * @return self Provides fluent interface + */ + public function setKey($value) + { + return $this->setOption('key', $value); + } + + /** + * Set the query string. + * + * This overwrites the current value + * + * @param string $query + * @param array $bind Bind values for placeholders in the query string + * + * @return self Provides fluent interface + */ + public function setQuery($query, $bind = null) + { + if (!is_null($bind)) { + $helper = new Helper(); + $query = $helper->assemble($query, $bind); + } + + $this->query = trim($query); + + return $this; + } + + /** + * Get the query string. + * + * @return string + */ + public function getQuery() + { + return $this->query; + } + + /** + * Initialize options. + */ + protected function init() + { + foreach ($this->options as $name => $value) { + switch ($name) { + case 'key': + $this->setKey($value); + break; + case 'query': + $this->setQuery($value); + break; + } + } + } +} diff --git a/library/Solarium/QueryType/Select/Query/Component/DisMax.php b/library/Solarium/QueryType/Select/Query/Component/DisMax.php index 5c15f381e..bd373d7a9 100644 --- a/library/Solarium/QueryType/Select/Query/Component/DisMax.php +++ b/library/Solarium/QueryType/Select/Query/Component/DisMax.php @@ -40,6 +40,7 @@ namespace Solarium\QueryType\Select\Query\Component; +use Solarium\Exception\InvalidArgumentException; use Solarium\QueryType\Select\Query\Query as SelectQuery; use Solarium\QueryType\Select\RequestBuilder\Component\DisMax as RequestBuilder; @@ -59,6 +60,13 @@ class DisMax extends AbstractComponent 'queryparser' => 'dismax', ); + /** + * Boostqueries. + * + * @var BoostQuery[] + */ + protected $boostQueries = array(); + /** * Get component type. * @@ -278,17 +286,147 @@ public function getTie() */ public function setBoostQuery($boostQuery) { - return $this->setOption('boostquery', $boostQuery); + $this->clearBoostQueries(); + $this->addBoostQuery(array('key' => 0, 'query' => $boostQuery)); + + return $this; } /** * Get BoostQuery option. * + * @param string $key + * * @return string|null */ - public function getBoostQuery() + public function getBoostQuery($key = null) + { + if ($key !== null) { + if (array_key_exists($key, $this->boostQueries)) { + return $this->boostQueries[$key]->getQuery(); + } + } else if (!empty($this->boostQueries)) { + /** @var BoostQuery[] $boostQueries */ + $boostQueries = array_values($this->boostQueries); + + return $boostQueries[0]->getQuery(); + } else if (array_key_exists('boostquery', $this->options)) { + return $this->options['boostquery']; + } + + return null; + } + + /** + * Add a boost query. + * + * Supports a boostquery instance or a config array, in that case a new + * boostquery instance wil be created based on the options. + * + * @throws InvalidArgumentException + * + * @param BoostQuery|array $boostQuery + * + * @return self Provides fluent interface + */ + public function addBoostQuery($boostQuery) + { + if (is_array($boostQuery)) { + $boostQuery = new BoostQuery($boostQuery); + } + + $key = $boostQuery->getKey(); + + if (0 === strlen($key)) { + throw new InvalidArgumentException('A filterquery must have a key value'); + } + + //double add calls for the same BQ are ignored, but non-unique keys cause an exception + if (array_key_exists($key, $this->boostQueries) && $this->boostQueries[$key] !== $boostQuery) { + throw new InvalidArgumentException('A filterquery must have a unique key value within a query'); + } else { + $this->boostQueries[$key] = $boostQuery; + } + + return $this; + } + + /** + * Add multiple boostqueries. + * + * @param array $boostQueries + * + * @return self Provides fluent interface + */ + public function addBoostQueries(array $boostQueries) + { + foreach ($boostQueries as $key => $boostQuery) { + // in case of a config array: add key to config + if (is_array($boostQuery) && !isset($boostQuery['key'])) { + $boostQuery['key'] = $key; + } + + $this->addBoostQuery($boostQuery); + } + + return $this; + } + + /** + * Get all boostqueries. + * + * @return BoostQuery[] + */ + public function getBoostQueries() + { + return $this->boostQueries; + } + + /** + * Remove a single filterquery. + * + * You can remove a filterquery by passing its key, or by passing the filterquery instance + * + * @param string|BoostQuery $boostQuery + * + * @return self Provides fluent interface + */ + public function removeBoostQuery($boostQuery) + { + if (is_object($boostQuery)) { + $boostQuery = $boostQuery->getKey(); + } + + if (isset($this->boostQueries[$boostQuery])) { + unset($this->boostQueries[$boostQuery]); + } + + return $this; + } + + /** + * Remove all filterqueries. + * + * @return self Provides fluent interface + */ + public function clearBoostQueries() + { + $this->boostQueries = array(); + + return $this; + } + + /** + * Set multiple filterqueries. + * + * This overwrites any existing filterqueries + * + * @param array $boostQueries + */ + public function setBoostQueries($boostQueries) { - return $this->getOption('boostquery'); + $this->clearBoostQueries(); + $this->addBoostQueries($boostQueries); } /** diff --git a/library/Solarium/QueryType/Select/RequestBuilder/Component/DisMax.php b/library/Solarium/QueryType/Select/RequestBuilder/Component/DisMax.php index 3e44d4ad0..c607bef9c 100644 --- a/library/Solarium/QueryType/Select/RequestBuilder/Component/DisMax.php +++ b/library/Solarium/QueryType/Select/RequestBuilder/Component/DisMax.php @@ -68,7 +68,15 @@ public function buildComponent($component, $request) $request->addParam('ps', $component->getPhraseSlop()); $request->addParam('qs', $component->getQueryPhraseSlop()); $request->addParam('tie', $component->getTie()); - $request->addParam('bq', $component->getBoostQuery()); + + // add boostqueries to request + $boostQueries = $component->getBoostQueries(); + if (count($boostQueries) !== 0) { + foreach ($boostQueries as $boostQuery) { + $request->addParam('bq', $boostQuery->getQuery()); + } + } + $request->addParam('bf', $component->getBoostFunctions()); return $request; From 27e65b3a5740293b68b8ce4c99237cef8a4f259c Mon Sep 17 00:00:00 2001 From: schausson Date: Thu, 14 Jan 2016 15:36:20 +0100 Subject: [PATCH 09/20] Added option to add multiple boostqueries to edismax parser --- .../Select/RequestBuilder/Component/EdisMax.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/library/Solarium/QueryType/Select/RequestBuilder/Component/EdisMax.php b/library/Solarium/QueryType/Select/RequestBuilder/Component/EdisMax.php index b25230fd2..64cbadcd9 100644 --- a/library/Solarium/QueryType/Select/RequestBuilder/Component/EdisMax.php +++ b/library/Solarium/QueryType/Select/RequestBuilder/Component/EdisMax.php @@ -72,7 +72,15 @@ public function buildComponent($component, $request) $request->addParam('ps3', $component->getPhraseTrigramSlop()); $request->addParam('qs', $component->getQueryPhraseSlop()); $request->addParam('tie', $component->getTie()); - $request->addParam('bq', $component->getBoostQuery()); + + // add boostqueries to request + $boostQueries = $component->getBoostQueries(); + if (count($boostQueries) !== 0) { + foreach ($boostQueries as $boostQuery) { + $request->addParam('bq', $boostQuery->getQuery()); + } + } + $request->addParam('bf', $component->getBoostFunctions()); $request->addParam('boost', $component->getBoostFunctionsMult()); $request->addParam('uf', $component->getUserFields()); From 27247bb8251efbfe566136053ad3940b124b2ff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0rfan=20Evrens?= Date: Fri, 15 Jan 2016 11:45:29 +0200 Subject: [PATCH 10/20] Fixed some types. --- docs/getting-started.md | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index a6e5b0704..a81d86342 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -25,11 +25,13 @@ See [](https://packagist.org) for other packages. - Add Solarium to your composer.json file. It should look something like this: -`  {` -`      "require": {` -`          "solarium/solarium": "2.4.0"` -`      }` -`  }` +```json +{ + "require": { + "solarium/solarium": "2.4.0" + } +} +``` - Run composer install @@ -37,13 +39,13 @@ See [](https://packagist.org) for other packages. **Only if you don't use composer:** you need to use a PSR-0 autoloader, or the supplied autoloader: ```php -``` - Also you need to make sure the the Symfony Event Dispatcher component is available. ### Checking the availability -To check your installation you can do a Solarium version check with the following code. If everything works you should see the version of Solarium you downloaded. To test Solr communication you can use a ping query (you might need some configuration to get the ping working, more on that later) ```php +To check your installation you can do a Solarium version check with the following code. If everything works you should see the version of Solarium you downloaded. To test Solr communication you can use a ping query (you might need some configuration to get the ping working, more on that later) + +```php ](http://github.com/basdenooijer/solarium/issues) \ No newline at end of file +If examples for some Solarium functionality are missing please request them by opening an issue in the issue tracker: [](http://github.com/basdenooijer/solarium/issues) From b6e753c8ec6e24f88baf83a1e8a0b511d75665bd Mon Sep 17 00:00:00 2001 From: schausson Date: Mon, 18 Jan 2016 11:23:46 +0100 Subject: [PATCH 11/20] Fixed typo in comments (filterquery instead of boostquery) --- .../QueryType/Select/Query/Component/DisMax.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/library/Solarium/QueryType/Select/Query/Component/DisMax.php b/library/Solarium/QueryType/Select/Query/Component/DisMax.php index bd373d7a9..db22b80e9 100644 --- a/library/Solarium/QueryType/Select/Query/Component/DisMax.php +++ b/library/Solarium/QueryType/Select/Query/Component/DisMax.php @@ -338,12 +338,12 @@ public function addBoostQuery($boostQuery) $key = $boostQuery->getKey(); if (0 === strlen($key)) { - throw new InvalidArgumentException('A filterquery must have a key value'); + throw new InvalidArgumentException('A boostquery must have a key value'); } //double add calls for the same BQ are ignored, but non-unique keys cause an exception if (array_key_exists($key, $this->boostQueries) && $this->boostQueries[$key] !== $boostQuery) { - throw new InvalidArgumentException('A filterquery must have a unique key value within a query'); + throw new InvalidArgumentException('A boostquery must have a unique key value within a query'); } else { $this->boostQueries[$key] = $boostQuery; } @@ -383,9 +383,9 @@ public function getBoostQueries() } /** - * Remove a single filterquery. + * Remove a single boostquery. * - * You can remove a filterquery by passing its key, or by passing the filterquery instance + * You can remove a boostquery by passing its key, or by passing the boostquery instance * * @param string|BoostQuery $boostQuery * @@ -405,7 +405,7 @@ public function removeBoostQuery($boostQuery) } /** - * Remove all filterqueries. + * Remove all boostqueries. * * @return self Provides fluent interface */ @@ -417,9 +417,9 @@ public function clearBoostQueries() } /** - * Set multiple filterqueries. + * Set multiple boostqueries. * - * This overwrites any existing filterqueries + * This overwrites any existing boostqueries * * @param array $boostQueries */ From d94979aa3ccc83e7dbdbd5499d206e94aef98138 Mon Sep 17 00:00:00 2001 From: schausson Date: Mon, 18 Jan 2016 11:26:47 +0100 Subject: [PATCH 12/20] Added unit tests for QueryType\Select\Query\Component\BoostQuery, based on FilterQueryTest. Added unit tests for QueryType\Select\Query\Component\DisMax::addBoostQuery, addBoostQueries. --- .../Select/Query/Component/BoostQueryTest.php | 70 ++++++++++++++ .../Select/Query/Component/DisMaxTest.php | 96 +++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 tests/Solarium/Tests/QueryType/Select/Query/Component/BoostQueryTest.php diff --git a/tests/Solarium/Tests/QueryType/Select/Query/Component/BoostQueryTest.php b/tests/Solarium/Tests/QueryType/Select/Query/Component/BoostQueryTest.php new file mode 100644 index 000000000..ed755b365 --- /dev/null +++ b/tests/Solarium/Tests/QueryType/Select/Query/Component/BoostQueryTest.php @@ -0,0 +1,70 @@ +boostQuery = new BoostQuery; + } + + public function testConfigMode() + { + $fq = new BoostQuery(array('key' => 'k1', 'query'=> 'id:[10 TO 20]')); + + $this->assertEquals('k1', $fq->getKey()); + $this->assertEquals('id:[10 TO 20]', $fq->getQuery()); + } + + public function testSetAndGetKey() + { + $this->boostQuery->setKey('testkey'); + $this->assertEquals('testkey', $this->boostQuery->getKey()); + } + + public function testSetAndGetQuery() + { + $this->boostQuery->setQuery('category:1'); + $this->assertEquals('category:1', $this->boostQuery->getQuery()); + } + + public function testSetAndGetQueryWithBind() + { + $this->boostQuery->setQuery('id:%1%', array(678)); + $this->assertEquals('id:678', $this->boostQuery->getQuery()); + } +} diff --git a/tests/Solarium/Tests/QueryType/Select/Query/Component/DisMaxTest.php b/tests/Solarium/Tests/QueryType/Select/Query/Component/DisMaxTest.php index 1c41d4b77..7e254e610 100644 --- a/tests/Solarium/Tests/QueryType/Select/Query/Component/DisMaxTest.php +++ b/tests/Solarium/Tests/QueryType/Select/Query/Component/DisMaxTest.php @@ -31,6 +31,7 @@ namespace Solarium\Tests\QueryType\Select\Query\Component; +use Solarium\QueryType\Select\Query\Component\BoostQuery; use Solarium\QueryType\Select\Query\Component\DisMax; use Solarium\QueryType\Select\Query\Query; @@ -195,6 +196,101 @@ public function testSetAndGetBoostQuery() ); } + public function testAddBoostQueryWithArray() + { + $query = 'cat:1^3'; + $key = 'cat'; + + $this->disMax->addBoostQuery(array('query' => $query, 'key' => $key)); + + $this->assertEquals( + $query, + $this->disMax->getBoostQuery($key) + ); + } + + public function testAddBoostQueryWithObject() + { + $query = 'cat:1^3'; + $key = 'cat'; + + $bq = new BoostQuery(); + $bq -> setKey($key); + $bq -> setQuery($query); + + $this->disMax->addBoostQuery($bq); + + $this->assertEquals( + $query, + $this->disMax->getBoostQuery($key) + ); + } + + public function testAddBoostQueryWithoutKey() + { + $bq = new BoostQuery; + $bq->setQuery('category:1'); + + $this->setExpectedException('Solarium\Exception\InvalidArgumentException'); + $this->disMax->addBoostQuery($bq); + } + + public function testAddBoostQueryWithUsedKey() + { + $bq1 = new BoostQuery; + $bq1->setKey('bq1')->setQuery('category:1'); + + $bq2 = new BoostQuery; + $bq2->setKey('bq1')->setQuery('category:2'); + + $this->disMax->addBoostQuery($bq1); + $this->setExpectedException('Solarium\Exception\InvalidArgumentException'); + $this->disMax->addBoostQuery($bq2); + } + + public function testAddBoostQueriesWithInnerKeys() + { + $bqs = array( + array('key' => 'key1', 'query' => 'cat:1'), + array('key' => 'key2', 'query' => 'cat:2') + ); + + $this->disMax->addBoostQueries($bqs); + + $bqs2 = array(); + + foreach ($bqs as $bq) { + $bqs2[$bq['key']] = new BoostQuery($bq); + } + + $this->assertEquals( + $bqs2, + $this->disMax->getBoostQueries() + ); + } + + public function testAddBoostQueriesWithOuterKeys() + { + $bqs = array( + 'key1' => array('query' => 'cat:1'), + 'key2' => array('query' => 'cat:2') + ); + + $this->disMax->addBoostQueries($bqs); + + $bqs2 = array(); + + foreach ($bqs as $key => $bq) { + $bq['key'] = $key; + $bqs2[$key] = new BoostQuery($bq); + } + + $this->assertEquals( + $bqs2, + $this->disMax->getBoostQueries() + ); + } + public function testSetAndGetBoostFunctions() { $value = 'funcA(arg1,arg2)^1.2 funcB(arg3,arg4)^2.2'; From f72cc437a2b8a1fbb6650b702b72f5401bcee92d Mon Sep 17 00:00:00 2001 From: Bas de Nooijer Date: Thu, 21 Jan 2016 07:37:33 +0100 Subject: [PATCH 13/20] Fix link --- docs/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index a81d86342..eba67e3df 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -327,4 +327,4 @@ With Solarium a set of examples is included to demonstrate the usage and to test That's all! The default config file of the examples was made for the standard Solr example included with a Solr release. If you want to use a custom Solr environment you can copy the file 'config.dist.php' in the example dir to 'config.php' and correct the settings. Your environment needs to have the default Solr example schema and data for the examples to work. -If examples for some Solarium functionality are missing please request them by opening an issue in the issue tracker: [](http://github.com/basdenooijer/solarium/issues) +If examples for some Solarium functionality are missing please request them by opening an issue in the issue tracker: [](http://github.com/solariumphp/solarium/issues) From 4f5cbd05b86efbdc10f5d0912a125e10b3c552be Mon Sep 17 00:00:00 2001 From: Eric Bus Date: Thu, 4 Feb 2016 11:36:40 +0100 Subject: [PATCH 14/20] Support for percentiles value. Chcek existance of stats value before returning. --- .../QueryType/Select/Result/Stats/Result.php | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/library/Solarium/QueryType/Select/Result/Stats/Result.php b/library/Solarium/QueryType/Select/Result/Stats/Result.php index 935b0b332..e526a1a54 100644 --- a/library/Solarium/QueryType/Select/Result/Stats/Result.php +++ b/library/Solarium/QueryType/Select/Result/Stats/Result.php @@ -88,7 +88,7 @@ public function getName() */ public function getMin() { - return $this->stats['min']; + return $this->getValue('min'); } /** @@ -98,7 +98,7 @@ public function getMin() */ public function getMax() { - return $this->stats['max']; + return $this->getValue('max'); } /** @@ -108,7 +108,7 @@ public function getMax() */ public function getSum() { - return $this->stats['sum']; + return $this->getValue('sum'); } /** @@ -118,7 +118,7 @@ public function getSum() */ public function getCount() { - return $this->stats['count']; + return $this->getValue('count'); } /** @@ -128,7 +128,7 @@ public function getCount() */ public function getMissing() { - return $this->stats['missing']; + return $this->getValue('missing'); } /** @@ -138,7 +138,7 @@ public function getMissing() */ public function getSumOfSquares() { - return $this->stats['sumOfSquares']; + return $this->getValue('sumOfSquares'); } /** @@ -148,7 +148,7 @@ public function getSumOfSquares() */ public function getMean() { - return $this->stats['mean']; + return $this->getValue('mean'); } /** @@ -158,7 +158,7 @@ public function getMean() */ public function getStddev() { - return $this->stats['stddev']; + return $this->getValue('stddev'); } /** @@ -168,6 +168,26 @@ public function getStddev() */ public function getFacets() { - return $this->stats['facets']; + return $this->getValue('facets'); } + + /** + * Get percentile stats. + * + * @return array + */ + public function getPercentiles() + { + return $this->getValue('percentiles'); + } + + /** + * Get value by name. + * + * @return string + */ + protected function getValue($name) + { + return isset($this->stats['min']) ? $this->stats['min'] : null; + } } From 29ce97267731c2b6dfdcd0560cbfbcc4f7f56aaa Mon Sep 17 00:00:00 2001 From: Eric Bus Date: Thu, 4 Feb 2016 11:46:21 +0100 Subject: [PATCH 15/20] Index should be taken from $name parameter. --- library/Solarium/QueryType/Select/Result/Stats/Result.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Solarium/QueryType/Select/Result/Stats/Result.php b/library/Solarium/QueryType/Select/Result/Stats/Result.php index e526a1a54..279f3876a 100644 --- a/library/Solarium/QueryType/Select/Result/Stats/Result.php +++ b/library/Solarium/QueryType/Select/Result/Stats/Result.php @@ -188,6 +188,6 @@ public function getPercentiles() */ protected function getValue($name) { - return isset($this->stats['min']) ? $this->stats['min'] : null; + return isset($this->stats[$name]) ? $this->stats[$name] : null; } } From 006484c2b4366db81c42a41547711d37ba426212 Mon Sep 17 00:00:00 2001 From: Brian Seitel Date: Tue, 23 Feb 2016 14:57:21 -0800 Subject: [PATCH 16/20] fix typo on docs index.md It's a pretty glaring error on the main page (and thus on Google results). --- docs/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index c0957e36b..2b0fbadf6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -4,7 +4,7 @@ Solarium documentation Solarium is a Solr client library for PHP. It is developed with these goals in mind: -- Releave developers of the ‘raw communication’ with Solr, ie. setting params, building strings, hiding all this with an easy to use API, allowing you to focus on business logic. +- Relieve developers of the ‘raw communication’ with Solr, ie. setting params, building strings, hiding all this with an easy to use API, allowing you to focus on business logic. - Allow for reuse, for instance a query can be extended to modify it - Be flexible. For instance the query and result models are not tied to a specific Solr client implementation. There are multiple Solr Client adapters for Solr communication. All models can be extended by your own implementation if needed and a plugin system is available. - Be usable in any PHP application. No dependencies on other frameworks. Solarium tries to follow the Symfony 2 standard and integrates nicely with SF2, but doesn’t in rely on it. You can use Solarium just as easily in Zend Framework or any other PHP framework. @@ -37,4 +37,4 @@ foreach ($resultset as $document) { echo $document->id . PHP_EOL; echo $document->name . PHP_EOL; } -``` \ No newline at end of file +``` From e911f26dea51454702cd14edfea1698f72d080bd Mon Sep 17 00:00:00 2001 From: Calum Brodie Date: Wed, 24 Feb 2016 22:36:41 +0000 Subject: [PATCH 17/20] corrects php docblock in result-of-a-select-query/ --- .../result-of-a-select-query/result-of-a-select-query.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/queries/select-query/result-of-a-select-query/result-of-a-select-query.md b/docs/queries/select-query/result-of-a-select-query/result-of-a-select-query.md index fd8c5baed..3bd2b6f5e 100644 --- a/docs/queries/select-query/result-of-a-select-query/result-of-a-select-query.md +++ b/docs/queries/select-query/result-of-a-select-query/result-of-a-select-query.md @@ -35,7 +35,8 @@ The countable interface returns the number of documents in this resultset. This Example ------- -A basic usage example: ```php +A basic usage example: +```php Date: Tue, 8 Mar 2016 15:13:08 -0500 Subject: [PATCH 18/20] Actually use ClientInterface --- library/Solarium/Core/Client/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Solarium/Core/Client/Client.php b/library/Solarium/Core/Client/Client.php index 2583c099c..810adf029 100644 --- a/library/Solarium/Core/Client/Client.php +++ b/library/Solarium/Core/Client/Client.php @@ -78,7 +78,7 @@ * $result = $client->select($query); * */ -class Client extends Configurable +class Client extends Configurable implements ClientInterface { /** * Querytype select. From 217cc1616e49041e77129b4e68b1476d14edd682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Machulda?= Date: Sat, 12 Mar 2016 01:45:48 +0000 Subject: [PATCH 19/20] Update coveralls settings --- .coveralls.yml | 2 -- .travis.yml | 3 ++- composer.json | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.coveralls.yml b/.coveralls.yml index 1c8760a59..91600595a 100644 --- a/.coveralls.yml +++ b/.coveralls.yml @@ -1,3 +1 @@ service_name: travis-ci - -src_dir: library diff --git a/.travis.yml b/.travis.yml index 39b13061b..8562531e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,8 @@ before_script: script: vendor/bin/phpunit -c phpunit.xml.travis -v -after_script: vendor/bin/coveralls -v +after_success: + - travis_retry php vendor/bin/coveralls -v matrix: allow_failures: diff --git a/composer.json b/composer.json index 63536dd1d..324d46413 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "phpunit/phpunit": "~3.7", "squizlabs/php_codesniffer": "~1.4", "zendframework/zendframework1": "~1.12", - "satooshi/php-coveralls": "~0.6" + "satooshi/php-coveralls": "~1.0" }, "extra": { "branch-alias": { From f71a6a6727e0a28092eb7c7f9a516f5ddd73fb37 Mon Sep 17 00:00:00 2001 From: Bas de Nooijer Date: Tue, 3 May 2016 08:32:22 +0200 Subject: [PATCH 20/20] Update CHANGELOG.md --- CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 513b15027..124ff51df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,14 @@ ## 3.6.0 -- no longer allow failures for HHVM in continuous integration +- improvement: no longer allow failures for HHVM in continuous integration +- improvement: added Symfony 3.x components to CI tests for PHP 5.5+ +- added: support for replicas in distributed search +- added: support for multiple boost queries in dismax +- added: support for additional stats values like percentiles +- improvement: several typo / markup fixes in documentation +- improvement: several docblock fixes +- improvement: ClientInterface now also used for standard Client class ## 3.5.1