From 072aa9f97f93dc2d5b2cfcf7c95248ea2412fa03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20Jonu=C5=A1as?= <mantas.jonusas@nfq.lt> Date: Mon, 20 Apr 2015 19:11:10 +0300 Subject: [PATCH] Refactored terms aggregation --- Aggregation/TermsAggregationTest.php | 30 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/Aggregation/TermsAggregationTest.php b/Aggregation/TermsAggregationTest.php index e988c1f..75f62ac 100644 --- a/Aggregation/TermsAggregationTest.php +++ b/Aggregation/TermsAggregationTest.php @@ -41,7 +41,7 @@ class TermsAggregationTest extends \PHPUnit_Framework_TestCase // Case #1 terms aggregation with size. $aggregation = new TermsAggregation('test_agg'); $aggregation->setField('test_field'); - $aggregation->setSize(1); + $aggregation->addParameter('size', 1); $result = [ 'agg_test_agg' => [ @@ -63,8 +63,8 @@ class TermsAggregationTest extends \PHPUnit_Framework_TestCase // Case #2 terms aggregation with size and min document count. $aggregation = new TermsAggregation('test_agg'); $aggregation->setField('test_field'); - $aggregation->setSize(1); - $aggregation->setMinDocCount(10); + $aggregation->addParameter('size', 1); + $aggregation->addParameter('min_doc_count', 10); $result = [ 'agg_test_agg' => [ @@ -87,8 +87,8 @@ class TermsAggregationTest extends \PHPUnit_Framework_TestCase // Case #3 terms aggregation with simple include, exclude. $aggregation = new TermsAggregation('test_agg'); $aggregation->setField('test_field'); - $aggregation->setInclude('test_.*'); - $aggregation->setExclude('pizza_.*'); + $aggregation->addParameter('include', 'test_.*'); + $aggregation->addParameter('exclude', 'pizza_.*'); $result = [ 'agg_test_agg' => [ @@ -111,8 +111,20 @@ class TermsAggregationTest extends \PHPUnit_Framework_TestCase // Case #4 terms aggregation with include, exclude and flags. $aggregation = new TermsAggregation('test_agg'); $aggregation->setField('test_field'); - $aggregation->setInclude('test_.*', 'CANON_EQ|CASE_INSENSITIVE'); - $aggregation->setExclude('pizza_.*', 'CASE_INSENSITIVE'); + $aggregation->addParameter( + 'include', + [ + 'pattern' => 'test_.*', + 'flags' => 'CANON_EQ|CASE_INSENSITIVE', + ] + ); + $aggregation->addParameter( + 'exclude', + [ + 'pattern' => 'pizza_.*', + 'flags' => 'CASE_INSENSITIVE', + ] + ); $result = [ 'agg_test_agg' => [ @@ -141,7 +153,7 @@ class TermsAggregationTest extends \PHPUnit_Framework_TestCase // Case #5 terms aggregation with order default direction. $aggregation = new TermsAggregation('test_agg'); $aggregation->setField('test_field'); - $aggregation->setOrder('_count'); + $aggregation->addParameter('order', ['_count' => 'asc']); $result = [ 'agg_test_agg' => [ @@ -163,7 +175,7 @@ class TermsAggregationTest extends \PHPUnit_Framework_TestCase // Case #6 terms aggregation with order term mode, desc direction. $aggregation = new TermsAggregation('test_agg'); $aggregation->setField('test_field'); - $aggregation->setOrder('_term', TermsAggregation::DIRECTION_DESC); + $aggregation->addParameter('order', ['_term' => 'desc']); $result = [ 'agg_test_agg' => [ -- GitLab