Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ php:

env:
- ELASTICSEARCH="1.3.9"
- ELASTICSEARCH="1.4.4"
- ELASTICSEARCH="1.5.1"
- ELASTICSEARCH="1.4.5"
- ELASTICSEARCH="1.5.2"

matrix:
allow_failures:
Expand Down
19 changes: 5 additions & 14 deletions Tests/Functional/DSL/Aggregation/AvgAggregationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,10 @@ public function testAvgAggregation()
$search = $repo->createSearch()->addAggregation($aggregation);
$results = $repo->execute($search, Repository::RESULTS_RAW);

$expectedResult = [
'agg_test_agg' => [
'value' => 19.18333339691162,
'value_as_string' => '19.18333339691162',
],
];
$expectedResult = 19.18;

$this->assertArrayHasKey('aggregations', $results, 'results array should have aggregations key');
$this->assertEquals($expectedResult, $results['aggregations'], '', 0.01);
$this->assertEquals($expectedResult, $results['aggregations']['agg_test_agg']['value'], '', 0.01);
}

/**
Expand All @@ -98,12 +93,8 @@ public function testAvgAggregationWithScriptSet()
$search = $repo->createSearch()->addAggregation($aggregation);
$results = $repo->execute($search, Repository::RESULTS_RAW);

$expectedResult = [
'agg_test_agg' => [
'value' => 23.020000076293943,
'value_as_string' => '23.020000076293943',
],
];
$this->assertEquals($expectedResult, $results['aggregations'], '', 0.01);
$expectedResult = 23.02;

$this->assertEquals($expectedResult, $results['aggregations']['agg_test_agg']['value'], '', 0.01);
}
}
40 changes: 16 additions & 24 deletions Tests/Functional/DSL/Aggregation/ExtendedStatsAggregationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ public function testExtendedStatsAggregation()
$search = $repo->createSearch()->addAggregation($aggregation);
$results = $repo->execute($search, Repository::RESULTS_RAW);

$expectedMin = 10.449999809265137;
$expectedMin = 10.450;

$this->assertArrayHasKey('aggregations', $results, 'results array should have aggregations key');
$this->assertEquals($expectedMin, $results['aggregations'][$aggregation->getName()]['min']);
$this->assertEquals($expectedMin, $results['aggregations'][$aggregation->getName()]['min'], '', 0.01);
}

/**
Expand All @@ -94,28 +94,20 @@ public function testExtendedStatsAggregationWithSigmaSet()
$results = $repo->execute($search, Repository::RESULTS_RAW);

$expectedResult = [
'agg_test_agg' => [
'count' => 3,
'min' => 10.449999809265137,
'max' => 32.0,
'avg' => 19.183333396911621,
'sum' => 57.550000190734863,
'sum_of_squares' => 1361.2125075340273,
'variance' => 85.737222294277672,
'std_deviation' => 9.2594396317637742,
'std_deviation_bounds' => ['upper' => 28.442773028675397, 'lower' => 9.9238937651478469],
'min_as_string' => '10.449999809265137',
'max_as_string' => '32.0',
'avg_as_string' => '19.18333339691162',
'sum_as_string' => '57.55000019073486',
'sum_of_squares_as_string' => '1361.2125075340273',
'variance_as_string' => '85.73722229427767',
'std_deviation_as_string' => '9.259439631763774',
'std_deviation_bounds_as_string' => ['upper' => '28.442773028675397', 'lower' => '9.9238937651478469'],
],
'count' => 3,
'min' => 10.450,
'max' => 32.0,
'avg' => 19.183,
'sum' => 57.550,
'sum_of_squares' => 1361.212,
'variance' => 85.737,
'std_deviation' => 9.259,
'std_deviation_bounds' => ['upper' => 28.443, 'lower' => 9.924],
];

$this->assertEquals($expectedResult, $results['aggregations']);
foreach ($expectedResult as $checkKey => $checkValue) {
$this->assertEquals($checkValue, $results['aggregations']['agg_test_agg'][$checkKey], '', 0.01);
}
}

/**
Expand All @@ -128,8 +120,8 @@ public function testExtendedStatsAggregationWithScriptSet()
$aggregation->setScript("doc['product.price'].value * 1.5");
$search = $repo->createSearch()->addAggregation($aggregation);
$results = $repo->execute($search, Repository::RESULTS_RAW);
$expectedMin = 15.674999713897705;
$expectedMin = 15.675;

$this->assertEquals($expectedMin, $results['aggregations'][$aggregation->getName()]['min']);
$this->assertEquals($expectedMin, $results['aggregations'][$aggregation->getName()]['min'], '', 0.01);
}
}
35 changes: 16 additions & 19 deletions Tests/Functional/DSL/Aggregation/HistogramAggregationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,31 +172,28 @@ public function testHistogramAggregationWithOrderAndMinDocCountSet()

$aggregation->setOrder($statsAggregation->getName() . '.min', HistogramAggregation::DIRECTION_ASC);
$aggregation->addAggregation($statsAggregation);

$expectedResults = [
'agg_test_agg' => [
'buckets' => [
[
'key' => 0,
'doc_count' => 2,
'agg_price_stats' => [
'count' => 2,
'min' => 2.0,
'max' => 3.0,
'avg' => 2.5,
'sum' => 5.0,
'min_as_string' => '2.0',
'max_as_string' => '3.0',
'avg_as_string' => '2.5',
'sum_as_string' => '5.0',
],
],
],
'doc_count' => 2,
'agg_price_stats' => [
'count' => 2,
'min' => 2.0,
'max' => 3.0,
'avg' => 2.5,
'sum' => 5.0,
],
];


$search = $repo->createSearch()->addAggregation($aggregation);
$results = $repo->execute($search, Repository::RESULTS_RAW)['aggregations'];

$this->assertEquals($expectedResults, $results);
$resultBucket = $results['agg_test_agg']['buckets'][0];

$this->assertEquals($expectedResults['doc_count'], $resultBucket['doc_count']);

foreach ($expectedResults['agg_price_stats'] as $checkKey => $checkValue) {
$this->assertEquals($checkValue, $resultBucket['agg_price_stats'][$checkKey], '', 0.01);
}
}
}
20 changes: 6 additions & 14 deletions Tests/Functional/DSL/Aggregation/MaxAggregationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,10 @@ public function testMaxAggregation()
$search = $repo->createSearch()->addAggregation($aggregation);
$results = $repo->execute($search, Repository::RESULTS_RAW);

$expectedResult = [
'agg_test_agg' => [
'value' => 32.0,
'value_as_string' => '32.0',
],
];
$expectedResult = 32.0;

$this->assertArrayHasKey('aggregations', $results, 'results array should have aggregations key');
$this->assertEquals($expectedResult, $results['aggregations'], '', 0.01);
$this->assertEquals($expectedResult, $results['aggregations']['agg_test_agg']['value'], '', 0.01);
}

/**
Expand All @@ -97,13 +92,10 @@ public function testMaxAggregationWithScriptSet()

$search = $repo->createSearch()->addAggregation($aggregation);
$results = $repo->execute($search, Repository::RESULTS_RAW);
$expectedResult = [
'agg_test_agg' => [
'value' => 38.4,
'value_as_string' => '38.4',
],
];

$expectedResult = 38.4;

$this->assertArrayHasKey('aggregations', $results);
$this->assertEquals($expectedResult, $results['aggregations'], '', 0.01);
$this->assertEquals($expectedResult, $results['aggregations']['agg_test_agg']['value'], '', 0.01);
}
}
20 changes: 6 additions & 14 deletions Tests/Functional/DSL/Aggregation/MinAggregationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,10 @@ public function testMinAggregation()
$search = $repo->createSearch()->addAggregation($aggregation);
$results = $repo->execute($search, Repository::RESULTS_RAW);

$expectedResult = [
'agg_test_agg' => [
'value' => 10.449999809265137,
'value_as_string' => '10.449999809265137',
],
];
$expectedResult = 10.45;

$this->assertArrayHasKey('aggregations', $results);
$this->assertEquals($expectedResult, $results['aggregations'], '', 0.01);
$this->assertEquals($expectedResult, $results['aggregations']['agg_test_agg']['value'], '', 0.01);
}

/**
Expand All @@ -97,13 +92,10 @@ public function testMinAggregationWithScriptSet()

$search = $repo->createSearch()->addAggregation($aggregation);
$results = $repo->execute($search, Repository::RESULTS_RAW);
$expectedResult = [
'agg_test_agg' => [
'value' => 12.539999771118163,
'value_as_string' => '12.539999771118163',
],
];

$expectedResult = 12.54;

$this->assertArrayHasKey('aggregations', $results, 'results array should have aggregations key');
$this->assertEquals($expectedResult, $results['aggregations'], '', 0.01);
$this->assertEquals($expectedResult, $results['aggregations']['agg_test_agg']['value'], '', 0.01);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ public function getPercentileRanksAggregationData()
$expectedResults = [
'10.0' => 12.5,
'30.0' => 100.0,
'10.0_as_string' => '12.5',
'30.0_as_string' => '100.0',
];
$out[] = [$aggregationData, $expectedResults];

Expand All @@ -89,9 +87,6 @@ public function getPercentileRanksAggregationData()
'10.0' => 12.5,
'20.0' => 0.0,
'90.0' => 100.0,
'10.0_as_string' => '12.5',
'20.0_as_string' => '0.0',
'90.0_as_string' => '100.0',
];
$out[] = [$aggregationData, $expectedResults];

Expand All @@ -101,9 +96,6 @@ public function getPercentileRanksAggregationData()
'10.0' => 0.0,
'20.0' => 100.0,
'90.0' => 100.0,
'10.0_as_string' => '0.0',
'20.0_as_string' => '100.0',
'90.0_as_string' => '100.0',
];
$out[] = [$aggregationData, $expectedResults];

Expand Down Expand Up @@ -137,7 +129,10 @@ public function testPercentileRanksAggregation($aggData, $expectedResults)

/** @var ValueAggregation $result */
$result = $results->getAggregations()['test_agg'];
$this->assertEquals($expectedResults, $result->getValue()['values']);

foreach ($expectedResults as $checkKey => $checkValue) {
$this->assertEquals($checkValue, $result->getValue()['values'][$checkKey]);
}
}

/**
Expand All @@ -158,9 +153,10 @@ public function testPercentileRanksWithScript()
$expectedResults = [
'10.0' => 12.5,
'30.0' => 100.0,
'10.0_as_string' => '12.5',
'30.0_as_string' => '100.0',
];
$this->assertEquals($expectedResults, $result->getValue()['values']);

foreach ($expectedResults as $checkKey => $checkValue) {
$this->assertEquals($checkValue, $result->getValue()['values'][$checkKey]);
}
}
}
36 changes: 9 additions & 27 deletions Tests/Functional/DSL/Aggregation/PercentilesAggregationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,13 @@ public function getPercentilesAggregationData()
// Case #0 without any percent or compression.
$aggregationData = ['field' => 'price', 'percents' => null, 'compression' => null];
$expectedResults = [
'1.0' => 10.149999999999999,
'1.0' => 10.150,
'5.0' => 10.75,
'25.0' => 13.75,
'50.0' => 20.0,
'75.0' => 25.0,
'95.0' => 25.0,
'99.0' => 25.0,
'1.0_as_string' => '10.149999999999999',
'5.0_as_string' => '10.75',
'25.0_as_string' => '13.75',
'50.0_as_string' => '20.0',
'75.0_as_string' => '25.0',
'95.0_as_string' => '25.0',
'99.0_as_string' => '25.0',
];
$out[] = [$aggregationData, $expectedResults];

Expand All @@ -103,13 +96,6 @@ public function getPercentilesAggregationData()
'75.0' => 18.75,
'95.0' => 18.75,
'99.0' => 18.75,
'1.0_as_string' => '18.75',
'5.0_as_string' => '18.75',
'25.0_as_string' => '18.75',
'50.0_as_string' => '18.75',
'75.0_as_string' => '18.75',
'95.0_as_string' => '18.75',
'99.0_as_string' => '18.75',
];
$out[] = [$aggregationData, $expectedResults];

Expand All @@ -119,9 +105,6 @@ public function getPercentilesAggregationData()
'10.0' => 11.5,
'20.0' => 13,
'90.0' => 25,
'10.0_as_string' => '11.5',
'20.0_as_string' => '13.0',
'90.0_as_string' => '25.0',
];
$out[] = [$aggregationData, $expectedResults];

Expand Down Expand Up @@ -155,7 +138,10 @@ public function testPercentilesAggregation($aggData, $expectedResults)

/** @var ValueAggregation $result */
$result = $results->getAggregations()['test_agg'];
$this->assertEquals($expectedResults, $result->getValue()['values']);

foreach ($expectedResults as $checkKey => $checkValue) {
$this->assertEquals($checkValue, $result->getValue()['values'][$checkKey]);
}
}

/**
Expand All @@ -180,14 +166,10 @@ public function testPercentilesAggregationWithScript()
'75.0' => 2.5,
'95.0' => 2.5,
'99.0' => 2.5,
'1.0_as_string' => '1.015',
'5.0_as_string' => '1.075',
'25.0_as_string' => '1.375',
'50.0_as_string' => '2.0',
'75.0_as_string' => '2.5',
'95.0_as_string' => '2.5',
'99.0_as_string' => '2.5',
];
$this->assertEquals($expectedResults, $result->getValue()['values']);

foreach ($expectedResults as $checkKey => $checkValue) {
$this->assertEquals($checkValue, $result->getValue()['values'][$checkKey]);
}
}
}
Loading