diff options
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Facet')
7 files changed, 0 insertions, 444 deletions
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/DateHistogramTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/DateHistogramTest.php deleted file mode 100644 index 46dcdbf9..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/DateHistogramTest.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php - -namespace Elastica\Test\Facet; - -use Elastica\Document; -use Elastica\Facet\DateHistogram; -use Elastica\Query; -use Elastica\Query\MatchAll; -use Elastica\Test\Base as BaseTest; -use Elastica\Type\Mapping; - -class DateHistogramTest extends BaseTest -{ - public function testClassHierarchy() - { - $facet = new DateHistogram('dateHist1'); - $this->assertInstanceOf('Elastica\Facet\Histogram', $facet); - $this->assertInstanceOf('Elastica\Facet\AbstractFacet', $facet); - unset($facet); - } - - public function testTest() - { - $client = $this->_getClient(); - $index = $client->getIndex('test'); - $index->create(array(), true); - $type = $index->getType('helloworld'); - - $mapping = new Mapping($type, array( - 'name' => array('type' => 'string', 'store' => 'no'), - 'dtmPosted' => array('type' => 'date', 'store' => 'no', 'format' => 'yyyy-MM-dd HH:mm:ss') - )); - $type->setMapping($mapping); - - $doc = new Document(1, array('name' => 'nicolas ruflin', 'dtmPosted' => "2011-06-23 21:53:00")); - $type->addDocument($doc); - $doc = new Document(2, array('name' => 'raul martinez jr', 'dtmPosted' => "2011-06-23 09:53:00")); - $type->addDocument($doc); - $doc = new Document(3, array('name' => 'rachelle clemente', 'dtmPosted' => "2011-07-08 08:53:00")); - $type->addDocument($doc); - $doc = new Document(4, array('name' => 'elastica search', 'dtmPosted' => "2011-07-08 01:53:00")); - $type->addDocument($doc); - - $facet = new DateHistogram('dateHist1'); - $facet->setInterval("day"); - $facet->setField("dtmPosted"); - - $query = new Query(); - $query->addFacet($facet); - $query->setQuery(new MatchAll()); - $index->refresh(); - - $response = $type->search($query); - $facets = $response->getFacets(); - - $this->assertEquals(4, $response->getTotalHits()); - $this->assertEquals(2, count($facets['dateHist1']['entries'])); - } -} diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/FilterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/FilterTest.php deleted file mode 100644 index ca6f5ba3..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/FilterTest.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php - -namespace Elastica\Test\Facet; - -use Elastica\Document; -use Elastica\Filter\Term; -use Elastica\Facet\Filter; -use Elastica\Query; -use Elastica\Test\Base as BaseTest; - -class FilterTest extends BaseTest -{ - public function testFilter() - { - $client = $this->_getClient(); - $index = $client->getIndex('test'); - $index->create(array(), true); - $type = $index->getType('helloworld'); - - $type->addDocument(new Document(1, array('color' => 'red'))); - $type->addDocument(new Document(2, array('color' => 'green'))); - $type->addDocument(new Document(3, array('color' => 'blue'))); - - $index->refresh(); - - $filter = new Term(array('color' => 'red')); - - $facet = new Filter('test'); - $facet->setFilter($filter); - - $query = new Query(); - $query->addFacet($facet); - - $resultSet = $type->search($query); - - $facets = $resultSet->getFacets(); - - $this->assertEquals(1, $facets['test']['count']); - } -} diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/GeoClusterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/GeoClusterTest.php deleted file mode 100644 index d06b58f9..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/GeoClusterTest.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php - -namespace Elastica\Test\Facet; - -use Elastica\Test\Base as BaseTest; - -class GeoClusterTest extends BaseTest{ - public function testQuery() { - $client = $this->_getClient(); - $nodes = $client->getCluster()->getNodes(); - if(!$nodes[0]->getInfo()->hasPlugin('geocluster-facet')){ - $this->markTestSkipped('geocluster-facet plugin not installed'); - } - - $index = $this->_createIndex('geocluster_test'); - $type = $index->getType('testQuery'); - $geoField = 'location'; - - $type->setMapping(new \Elastica\Type\Mapping($type, array( - $geoField => array( 'type' => 'geo_point', 'lat_lon' => true ) - ))); - - $doc = new \Elastica\Document(1, array('name' => 'item1', 'location' => array(20,20))); - $type->addDocument($doc); - - $doc = new \Elastica\Document(2, array('name' => 'item2', 'location' => array(20,20))); - $type->addDocument($doc); - - $doc = new \Elastica\Document(3, array('name' => 'item3', 'location' => array(20,20))); - $type->addDocument($doc); - - $index->refresh(); - - $facet = new \Elastica\Facet\GeoCluster('clusters'); - $facet - ->setField($geoField) - ->setFactor(1) - ->setShowIds(false); - $query = new \Elastica\Query(); - $query->setFacets(array($facet)); - - $response = $type->search($query); - $facets = $response->getFacets(); - - $this->assertEquals(1, count($facets['clusters']['clusters'])); - - $index->delete(); - } -}
\ No newline at end of file diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/QueryTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/QueryTest.php deleted file mode 100644 index ef5d7ccd..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/QueryTest.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php - -namespace Elastica\Test\Facet; - -use Elastica\Document; -use Elastica\Facet\Query as FacetQuery; -use Elastica\Query; -use Elastica\Query\Term; -use Elastica\Test\Base as BaseTest; - -class QueryTest extends BaseTest -{ - public function testFilter() - { - $client = $this->_getClient(); - $index = $client->getIndex('test'); - $index->create(array(), true); - $type = $index->getType('helloworld'); - - $type->addDocument(new Document(1, array('color' => 'red'))); - $type->addDocument(new Document(2, array('color' => 'green'))); - $type->addDocument(new Document(3, array('color' => 'blue'))); - - $index->refresh(); - - $termQuery = new Term(array('color' => 'red')); - - $facet = new FacetQuery('test'); - $facet->setQuery($termQuery); - - $query = new Query(); - $query->addFacet($facet); - - $resultSet = $type->search($query); - - $facets = $resultSet->getFacets(); - - $this->assertEquals(1, $facets['test']['count']); - } -} diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/StatisticalTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/StatisticalTest.php deleted file mode 100644 index 0b528a79..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/StatisticalTest.php +++ /dev/null @@ -1,82 +0,0 @@ -<?php - -namespace Elastica\Test\Facet; - -use Elastica\Document; -use Elastica\Facet\Statistical; -use Elastica\Query; -use Elastica\Query\MatchAll; -use Elastica\Test\Base as BaseTest; - -class StatisticalTest extends BaseTest -{ - public function testStatisticalWithSetField() - { - $client = $this->_getClient(); - $index = $client->getIndex('test'); - $index->create(array(), true); - $type = $index->getType('helloworld'); - - $doc = new Document(1, array('price' => 10)); - $type->addDocument($doc); - $doc = new Document(2, array('price' => 35)); - $type->addDocument($doc); - $doc = new Document(2, array('price' => 45)); - $type->addDocument($doc); - - $facet = new Statistical('stats'); - $facet->setField('price'); - - $query = new Query(); - $query->addFacet($facet); - $query->setQuery(new MatchAll()); - - $index->refresh(); - - $response = $type->search($query); - $facets = $response->getFacets(); - - $this->assertEquals(55, $facets['stats']['total']); - $this->assertEquals(10, $facets['stats']['min']); - $this->assertEquals(45, $facets['stats']['max']); - } - - public function testStatisticalWithSetFields() - { - $client = $this->_getClient(); - $index = $client->getIndex('test'); - $index->create(array(), true); - $type = $index->getType('helloworld'); - - $doc = new Document(1, array('price' => 10, 'price2' => 20)); - $type->addDocument($doc); - $doc = new Document(2, array('price' => 35, 'price2' => 70)); - $type->addDocument($doc); - $doc = new Document(2, array('price' => 45, 'price2' => 90)); - $type->addDocument($doc); - - $facet = new Statistical('stats'); - $facet->setFields(array('price','price2')); - - $query = new Query(); - $query->addFacet($facet); - $query->setQuery(new MatchAll()); - - $index->refresh(); - - $response = $type->search($query); - $facets = $response->getFacets(); - - $this->assertEquals(165, $facets['stats']['total']); - $this->assertEquals(10, $facets['stats']['min']); - $this->assertEquals(90, $facets['stats']['max']); - } - - /** - * @todo - */ - public function testStatisticalWithSetScript() - { - $this->markTestIncomplete('Test for setting the script value'); - } -} diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsStatsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsStatsTest.php deleted file mode 100644 index bea9b78d..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsStatsTest.php +++ /dev/null @@ -1,105 +0,0 @@ -<?php - -namespace Elastica\Test\Facet; - -use Elastica\Document; -use Elastica\Facet\TermsStats; -use Elastica\Query; -use Elastica\Query\MatchAll; -use Elastica\Test\Base as BaseTest; - -class TermsStatsTest extends BaseTest -{ - public function testOrder() - { - $client = $this->_getClient(); - $index = $client->getIndex( 'test' ); - $index->create( array( ), true ); - $type = $index->getType( 'helloworld' ); - - $doc = new Document( 1, array( 'name' => 'tom', 'paid' => 7 ) ); - $type->addDocument( $doc ); - $doc = new Document( 2, array( 'name' => 'tom', 'paid' => 2 ) ); - $type->addDocument( $doc ); - $doc = new Document( 3, array( 'name' => 'tom', 'paid' => 5 ) ); - $type->addDocument( $doc ); - $doc = new Document( 4, array( 'name' => 'mike', 'paid' => 13 ) ); - $type->addDocument( $doc ); - $doc = new Document( 5, array( 'name' => 'mike', 'paid' => 1 ) ); - $type->addDocument( $doc ); - $doc = new Document( 6, array( 'name' => 'mike', 'paid' => 15 ) ); - $type->addDocument( $doc ); - - $facet = new TermsStats( 'test' ); - $facet->setKeyField( 'name' ); - $facet->setValueField( 'paid' ); - $facet->setOrder( 'reverse_total' ); - - $query = new Query(); - $query->addFacet( $facet ); - $query->setQuery( new MatchAll() ); - - $index->refresh(); - - $response = $type->search( $query ); - $facets = $response->getFacets(); - - $this->assertEquals(14, $facets[ 'test' ][ 'terms' ][0]['total'] ); - $this->assertEquals(29, $facets[ 'test' ][ 'terms' ][1]['total'] ); - } - - public function testQuery() - { - $client = $this->_getClient(); - $index = $client->getIndex( 'test' ); - $index->create( array( ), true ); - $type = $index->getType( 'helloworld' ); - - $doc = new Document( 1, array( 'name' => 'tom', 'paid' => 7 ) ); - $type->addDocument( $doc ); - $doc = new Document( 2, array( 'name' => 'tom', 'paid' => 2 ) ); - $type->addDocument( $doc ); - $doc = new Document( 3, array( 'name' => 'tom', 'paid' => 5 ) ); - $type->addDocument( $doc ); - $doc = new Document( 4, array( 'name' => 'mike', 'paid' => 13 ) ); - $type->addDocument( $doc ); - $doc = new Document( 5, array( 'name' => 'mike', 'paid' => 1 ) ); - $type->addDocument( $doc ); - $doc = new Document( 6, array( 'name' => 'mike', 'paid' => 15 ) ); - $type->addDocument( $doc ); - - $facet = new TermsStats( 'test' ); - $facet->setKeyField( 'name' ); - $facet->setValueField( 'paid' ); - - $query = new Query(); - $query->addFacet( $facet ); - $query->setQuery( new MatchAll() ); - - $index->refresh(); - - $response = $type->search( $query ); - $facets = $response->getFacets(); - - $this->assertEquals( 2, count( $facets[ 'test' ][ 'terms' ] ) ); - foreach ($facets[ 'test' ][ 'terms' ] as $facet) { - if ($facet[ 'term' ] === 'tom') { - $this->assertEquals( 14, $facet[ 'total' ] ); - } - if ($facet[ 'term' ] === 'mike') { - $this->assertEquals( 29, $facet[ 'total' ] ); - } - } - } - - public function testSetSize() - { - $facet = new TermsStats( 'test' ); - $facet->setSize(100); - - $data = $facet->toArray(); - - $this->assertArrayHasKey('size', $data['terms_stats']); - $this->assertEquals(100, $data['terms_stats']['size']); - } -} diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsTest.php deleted file mode 100644 index e8521c5c..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsTest.php +++ /dev/null @@ -1,69 +0,0 @@ -<?php - -namespace Elastica\Test\Facet; - -use Elastica\Document; -use Elastica\Facet\Terms; -use Elastica\Query; -use Elastica\Query\MatchAll; -use Elastica\Test\Base as BaseTest; - -class TermsTest extends BaseTest -{ - public function testQuery() - { - $client = $this->_getClient(); - $index = $client->getIndex('test'); - $index->create(array(), true); - $type = $index->getType('helloworld'); - - $doc = new Document(1, array('name' => 'nicolas ruflin')); - $type->addDocument($doc); - $doc = new Document(2, array('name' => 'ruflin test')); - $type->addDocument($doc); - $doc = new Document(2, array('name' => 'nicolas helloworld')); - $type->addDocument($doc); - - $facet = new Terms('test'); - $facet->setField('name'); - - $query = new Query(); - $query->addFacet($facet); - $query->setQuery(new MatchAll()); - - $index->refresh(); - - $response = $type->search($query); - $facets = $response->getFacets(); - - $this->assertEquals(3, count($facets['test']['terms'])); - } - - public function testFacetScript() - { - $client = $this->_getClient(); - $index = $client->getIndex('test'); - $index->create(array(), true); - $type = $index->getType('helloworld'); - - $doc = new Document(1, array('name' => 'rodolfo', 'last_name' => 'moraes')); - $type->addDocument($doc); - $doc = new Document(2, array('name' => 'jose', 'last_name' => 'honjoya')); - $type->addDocument($doc); - - $facet = new Terms('test'); - $facet->setField('name'); - $facet->setScript('term + " "+doc["last_name"].value'); - - $query = new Query(); - $query->addFacet($facet); - $query->setQuery(new MatchAll()); - - $index->refresh(); - - $response = $type->search($query); - $facets = $response->getFacets(); - - $this->assertEquals(2, count($facets['test']['terms'])); - } -} |