diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-12-18 06:00:00 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-12-18 06:00:00 +0100 |
commit | 15e69f7b20b6596b9148030acce5b59993b95a45 (patch) | |
tree | 7b828b8920b0e222dc2a2c97dde933c9c4864fab /vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php | |
parent | 9e06a62f265e3a2aaabecc598d4bc617e06fa32d (diff) |
Update to MediaWiki 1.25.4
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php')
-rw-r--r-- | vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php new file mode 100644 index 00000000..ed6de99e --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php @@ -0,0 +1,62 @@ +<?php + +namespace Elastica\Test\Aggregation; + + +use Elastica\Aggregation\Min; +use Elastica\Aggregation\Nested; +use Elastica\Document; +use Elastica\Query; +use Elastica\Type\Mapping; + +class NestedTest extends BaseAggregationTest +{ + protected function setUp() + { + parent::setUp(); + $this->_index = $this->_createIndex("nested"); + $mapping = new Mapping(); + $mapping->setProperties(array( + "resellers" => array( + "type" => "nested", + "properties" => array( + "name" => array("type" => "string"), + "price" => array("type" => "double") + ) + ) + )); + $type = $this->_index->getType("test"); + $type->setMapping($mapping); + $docs = array( + new Document("1", array( + "resellers" => array( + "name" => "spacely sprockets", + "price" => 5.55 + ) + )), + new Document("1", array( + "resellers" => array( + "name" => "cogswell cogs", + "price" => 4.98 + ) + )) + ); + $type->addDocuments($docs); + $this->_index->refresh(); + } + + public function testNestedAggregation() + { + $agg = new Nested("resellers", "resellers"); + $min = new Min("min_price"); + $min->setField("price"); + $agg->addAggregation($min); + + $query = new Query(); + $query->addAggregation($agg); + $results = $this->_index->search($query)->getAggregation("resellers"); + + $this->assertEquals(4.98, $results['min_price']['value']); + } +} +
\ No newline at end of file |