コード例 #1
0
 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);
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
 /**
  * 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;
 }