Esempio n. 1
0
 public function testFactory()
 {
     $update1 = Solr::update();
     $update2 = Solr::update();
     $this->assertNotSame($update1, $update2);
     $this->assertInstanceOf(Update::class, $update1);
     $this->assertInstanceOf(Update::class, $update2);
 }
Esempio 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());
 }
Esempio 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);
 }
Esempio n. 4
0
 public function testUpdateRaw()
 {
     $coreName = "foo";
     $body = '{ "id": 1 }';
     $contentType = 'application/json';
     $update = Solr::update()->body($body)->contentType($contentType)->commit();
     $query = $update->render();
     $path = "{$coreName}/update?{$query}";
     $expected = new \stdClass();
     $headers = ['Content-Type' => 'application/json'];
     $mockClient = m::mock(Client::class);
     $mockClient->shouldReceive('post')->once()->with($path, $body, $headers)->andReturn($expected);
     $core = new Core($mockClient, $coreName);
     $actual = $core->updateRaw($update);
     $this->assertSame($expected, $actual);
 }
Esempio n. 5
0
 /**
  * @expectedException Opendi\Solr\Client\SolrException
  * @expectedExceptionMessage At least one pivot field must be specified.
  */
 public function testPivotInvalid()
 {
     Solr::facet()->pivot();
 }
Esempio n. 6
0
 public function testFactory()
 {
     $select1 = Solr::select();
     $select2 = Solr::select();
     $this->assertNotSame($select1, $select2);
     $this->assertInstanceOf(Select::class, $select1);
     $this->assertInstanceOf(Select::class, $select2);
 }
Esempio n. 7
0
 public function update()
 {
     $query = $this->build_add();
     $update = Solr::update()->body($query);
     $update->contentType('application/json');
     $update->commit();
     $update->optimize();
     $update->overwrite(true);
     $update->commitWithin(10);
     return $this->solr_client->core($this->collection)->update($update);
 }