Ejemplo n.º 1
0
 public function select($query)
 {
     $select = Solr::select();
     if ($this->select_build['select_filter']) {
         $select->filter($this->select_build['select_filter']['filter'], $this->select_build['select_filter']['locals']);
     }
     if ($this->select_build['select_start']) {
         $select->start($this->fieldList['select_start']);
     }
     if ($this->select_build['select_fieldlist']) {
         $select->fieldList($this->select_build['select_fieldlist']);
     }
     if ($this->select_build['select_sort']) {
         $select->sort($this->select_build['select_sort']);
     }
     if ($this->select_build['select_rows']) {
         $select->rows($this->select_build['select_rows']);
     }
     if ($this->select_build['select_format']) {
         $select->format($this->select_build['select_format']);
     }
     if ($this->select_build['select_debug']) {
         $select->debug($this->select_build['select_debug']);
     }
     $query_txt = $select->search($query);
     $this->select_build = [];
     log_message('debug', 'Solr Query: ' . var_export((array) $query_txt, true));
     return $this->solr_client->core($this->collection)->select($query_txt);
 }
Ejemplo n.º 2
0
 public function testMergeToSelect()
 {
     $group = Solr::group()->field('foo');
     $select = Solr::select()->group($group);
     $expected = 'group=true&group.field=foo';
     $this->assertSame($expected, $group->render());
     $this->assertSame($expected, $select->render());
 }
Ejemplo n.º 3
0
 public function testLocationSearch()
 {
     $field = "loc";
     $dist = "105.4";
     $lat = "45.816667";
     $lon = "15.983333";
     $actual = Solr::select()->spatialField($field)->centerPoint($lat, $lon)->distance($dist)->filterByDistance($field)->sortByDistance()->addDistanceToFieldList()->render();
     $expected = "sfield=loc&pt=45.816667%2C15.983333&d=105.4&fq=%7B%21geofilt+sfield%3Dloc%7D&sort=geodist%28%29+asc&fl=_dist_%3Ageodist%28%29";
     $this->assertEquals($expected, $actual);
 }
Ejemplo n.º 4
0
 public function testSelect()
 {
     $select = Solr::select()->search('name:frank zappa');
     $query = $select->render();
     $coreName = "foo";
     $path = "{$coreName}/select?{$query}&wt=json";
     $expected = "123";
     $mockResponse = m::mock(Response::class);
     $mockResponse->shouldReceive('getBody->getContents')->once()->andReturn($expected);
     $mockClient = m::mock(Client::class);
     $mockClient->shouldReceive('get')->once()->with($path)->andReturn($mockResponse);
     $core = new Core($mockClient, $coreName);
     $actual = $core->select($select);
     $this->assertSame(json_decode($expected), $actual);
 }
Ejemplo n.º 5
0
 public function testFactory()
 {
     $select1 = Solr::select();
     $select2 = Solr::select();
     $this->assertNotSame($select1, $select2);
     $this->assertInstanceOf(Select::class, $select1);
     $this->assertInstanceOf(Select::class, $select2);
 }