public function testSetShards() { $this->distributedSearch->addShards(array('shard1' => 'localhost:8983/solr/shard1', 'shard2' => 'localhost:8983/solr/shard2')); $this->distributedSearch->setShards(array('shard3' => 'localhost:8983/solr/shard3', 'shard4' => 'localhost:8983/solr/shard4', 'shard5' => 'localhost:8983/solr/shard5')); $shards = $this->distributedSearch->getShards(); $this->assertEquals(3, count($shards)); $this->assertEquals(array('shard3' => 'localhost:8983/solr/shard3', 'shard4' => 'localhost:8983/solr/shard4', 'shard5' => 'localhost:8983/solr/shard5'), $shards); }
/** * Add request settings for DistributedSearch * * @param DistributedSearchComponent $component * @param Request $request * @return Request */ public function buildComponent($component, $request) { // add shards to request $shards = array_values($component->getShards()); if (count($shards)) { $request->addParam('shards', implode(',', $shards)); } $request->addParam('shards.qt', $component->getShardRequestHandler()); // add collections to request $collections = array_values($component->getCollections()); if (count($collections)) { $request->addParam('collection', implode(',', $collections)); } return $request; }
/** * Add request settings for DistributedSearch. * * @param DistributedSearchComponent $component * @param Request $request * * @return Request */ public function buildComponent($component, $request) { // add shards to request $shards = array_values($component->getShards()); if (count($shards)) { $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 $collections = array_values($component->getCollections()); if (count($collections)) { $request->addParam('collection', implode(',', $collections)); } return $request; }