コード例 #1
0
 public function testBuildComponentWithCollections()
 {
     $builder = new RequestBuilder();
     $request = new Request();
     $component = new Component();
     $component->addCollection('collection1', 'localhost:8983/solr/collection1');
     $component->addCollections(array('collection2' => 'localhost:8983/solr/collection2', 'collection3' => 'localhost:8983/solr/collection3'));
     $request = $builder->buildComponent($component, $request);
     $this->assertEquals(array('collection' => 'localhost:8983/solr/collection1,localhost:8983/solr/collection2,localhost:8983/solr/collection3'), $request->getParams());
 }
コード例 #2
0
 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());
 }
コード例 #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));
     }
     $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;
 }
コード例 #4
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);
 }
コード例 #5
0
 public function testSetCollections()
 {
     $this->distributedSearch->addCollections(array('collection1' => 'localhost:8983/solr/collection1', 'collection2' => 'localhost:8983/solr/collection2'));
     $this->distributedSearch->setCollections(array('collection3' => 'localhost:8983/solr/collection3', 'collection4' => 'localhost:8983/solr/collection4', 'collection5' => 'localhost:8983/solr/collection5'));
     $collections = $this->distributedSearch->getCollections();
     $this->assertEquals(3, count($collections));
     $this->assertEquals(array('collection3' => 'localhost:8983/solr/collection3', 'collection4' => 'localhost:8983/solr/collection4', 'collection5' => 'localhost:8983/solr/collection5'), $collections);
 }
コード例 #6
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;
 }