Exemplo n.º 1
0
 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);
 }
Exemplo n.º 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));
     }
     $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;
 }