@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | $this->aggregationByName($aggregations); |
35 | 35 | |
36 | 36 | error_log('AGGS'); |
37 | - foreach ($aggregations as $agg) { |
|
37 | + foreach($aggregations as $agg) { |
|
38 | 38 | error_log($agg->Name); |
39 | - foreach ($agg->Buckets as $bucket) { |
|
39 | + foreach($agg->Buckets as $bucket) { |
|
40 | 40 | error_log("\t$bucket->Key -> $bucket->DocumentCount"); |
41 | 41 | } |
42 | 42 | } |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | $resultList = $this->search(''); |
433 | 433 | |
434 | 434 | //assert there are actually some results |
435 | - $this->assertGreaterThan(0,$resultList->getTotalItems()); |
|
435 | + $this->assertGreaterThan(0, $resultList->getTotalItems()); |
|
436 | 436 | $aggregations = $resultList->getAggregations()->toArray(); |
437 | 437 | $this->aggregationByName($aggregations); |
438 | 438 | |
@@ -452,49 +452,49 @@ discard block |
||
452 | 452 | //Asserting aggregate of ISO, 64 has count 5 |
453 | 453 | $this->assertEquals("64", $buckets[0]->Key); |
454 | 454 | $this->assertEquals(5, $buckets[0]->DocumentCount); |
455 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',64)->count(),5); |
|
455 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 64)->count(), 5); |
|
456 | 456 | $bucketSum += $buckets[0]->DocumentCount; |
457 | 457 | |
458 | 458 | //Asserting aggregate of ISO, 100 has count 11 |
459 | 459 | $this->assertEquals("100", $buckets[1]->Key); |
460 | 460 | $this->assertEquals(11, $buckets[1]->DocumentCount); |
461 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',100)->count(),11); |
|
461 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 100)->count(), 11); |
|
462 | 462 | $bucketSum += $buckets[1]->DocumentCount; |
463 | 463 | |
464 | 464 | //Asserting aggregate of ISO, 200 has count 12 |
465 | 465 | $this->assertEquals("200", $buckets[2]->Key); |
466 | 466 | $this->assertEquals(12, $buckets[2]->DocumentCount); |
467 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',200)->count(),12); |
|
467 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 200)->count(), 12); |
|
468 | 468 | $bucketSum += $buckets[2]->DocumentCount; |
469 | 469 | |
470 | 470 | //Asserting aggregate of ISO, 400 has count 13 |
471 | 471 | $this->assertEquals("400", $buckets[3]->Key); |
472 | 472 | $this->assertEquals(13, $buckets[3]->DocumentCount); |
473 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',400)->count(),13); |
|
473 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 400)->count(), 13); |
|
474 | 474 | $bucketSum += $buckets[3]->DocumentCount; |
475 | 475 | |
476 | 476 | //Asserting aggregate of ISO, 800 has count 16 |
477 | 477 | $this->assertEquals("800", $buckets[4]->Key); |
478 | 478 | $this->assertEquals(16, $buckets[4]->DocumentCount); |
479 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',800)->count(),16); |
|
479 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 800)->count(), 16); |
|
480 | 480 | $bucketSum += $buckets[4]->DocumentCount; |
481 | 481 | |
482 | 482 | //Asserting aggregate of ISO, 1600 has count 13 |
483 | 483 | $this->assertEquals("1600", $buckets[5]->Key); |
484 | 484 | $this->assertEquals(13, $buckets[5]->DocumentCount); |
485 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',1600)->count(),13); |
|
485 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 1600)->count(), 13); |
|
486 | 486 | $bucketSum += $buckets[5]->DocumentCount; |
487 | 487 | |
488 | 488 | //Asserting aggregate of ISO, 2000 has count 11 |
489 | 489 | $this->assertEquals("2000", $buckets[6]->Key); |
490 | 490 | $this->assertEquals(11, $buckets[6]->DocumentCount); |
491 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',2000)->count(),11); |
|
491 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 2000)->count(), 11); |
|
492 | 492 | $bucketSum += $buckets[6]->DocumentCount; |
493 | 493 | |
494 | 494 | //Asserting aggregate of ISO, 3200 has count 19 |
495 | 495 | $this->assertEquals("3200", $buckets[7]->Key); |
496 | 496 | $this->assertEquals(19, $buckets[7]->DocumentCount); |
497 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',3200)->count(),19); |
|
497 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 3200)->count(), 19); |
|
498 | 498 | $bucketSum += $buckets[7]->DocumentCount; |
499 | 499 | $this->assertEquals(100, $bucketSum); |
500 | 500 | |
@@ -507,43 +507,43 @@ discard block |
||
507 | 507 | //Asserting aggregate of Focal Length, 24 has count 12 |
508 | 508 | $this->assertEquals("24", $buckets[0]->Key); |
509 | 509 | $this->assertEquals(12, $buckets[0]->DocumentCount); |
510 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',24)->count(),12); |
|
510 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 24)->count(), 12); |
|
511 | 511 | $bucketSum += $buckets[0]->DocumentCount; |
512 | 512 | |
513 | 513 | //Asserting aggregate of Focal Length, 50 has count 11 |
514 | 514 | $this->assertEquals("50", $buckets[1]->Key); |
515 | 515 | $this->assertEquals(11, $buckets[1]->DocumentCount); |
516 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',50)->count(),11); |
|
516 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 50)->count(), 11); |
|
517 | 517 | $bucketSum += $buckets[1]->DocumentCount; |
518 | 518 | |
519 | 519 | //Asserting aggregate of Focal Length, 80 has count 11 |
520 | 520 | $this->assertEquals("80", $buckets[2]->Key); |
521 | 521 | $this->assertEquals(11, $buckets[2]->DocumentCount); |
522 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',80)->count(),11); |
|
522 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 80)->count(), 11); |
|
523 | 523 | $bucketSum += $buckets[2]->DocumentCount; |
524 | 524 | |
525 | 525 | //Asserting aggregate of Focal Length, 90 has count 20 |
526 | 526 | $this->assertEquals("90", $buckets[3]->Key); |
527 | 527 | $this->assertEquals(20, $buckets[3]->DocumentCount); |
528 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',90)->count(),20); |
|
528 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 90)->count(), 20); |
|
529 | 529 | $bucketSum += $buckets[3]->DocumentCount; |
530 | 530 | |
531 | 531 | //Asserting aggregate of Focal Length, 120 has count 12 |
532 | 532 | $this->assertEquals("120", $buckets[4]->Key); |
533 | 533 | $this->assertEquals(12, $buckets[4]->DocumentCount); |
534 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',120)->count(),12); |
|
534 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 120)->count(), 12); |
|
535 | 535 | $bucketSum += $buckets[4]->DocumentCount; |
536 | 536 | |
537 | 537 | //Asserting aggregate of Focal Length, 150 has count 17 |
538 | 538 | $this->assertEquals("150", $buckets[5]->Key); |
539 | 539 | $this->assertEquals(17, $buckets[5]->DocumentCount); |
540 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',150)->count(),17); |
|
540 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 150)->count(), 17); |
|
541 | 541 | $bucketSum += $buckets[5]->DocumentCount; |
542 | 542 | |
543 | 543 | //Asserting aggregate of Focal Length, 200 has count 17 |
544 | 544 | $this->assertEquals("200", $buckets[6]->Key); |
545 | 545 | $this->assertEquals(17, $buckets[6]->DocumentCount); |
546 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',200)->count(),17); |
|
546 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 200)->count(), 17); |
|
547 | 547 | $bucketSum += $buckets[6]->DocumentCount; |
548 | 548 | $this->assertEquals(100, $bucketSum); |
549 | 549 | |
@@ -830,7 +830,7 @@ discard block |
||
830 | 830 | $originalAggregations = $resultList->getAggregations()->toArray(); |
831 | 831 | |
832 | 832 | $filters = array('ISO' => 3200); |
833 | - $resultListFiltered = $this->search('New Zealand', $fields,$filters); |
|
833 | + $resultListFiltered = $this->search('New Zealand', $fields, $filters); |
|
834 | 834 | $filteredAggregations = $resultListFiltered->getAggregations()->toArray(); |
835 | 835 | |
836 | 836 | $this->checkDrillingDownHasHappened($filteredAggregations, $originalAggregations); |
@@ -842,8 +842,8 @@ discard block |
||
842 | 842 | $resultList = $this->search('New Zealand', $fields, array('ISO' => 400)); |
843 | 843 | $originalAggregations = $resultList->getAggregations()->toArray(); |
844 | 844 | |
845 | - $filters = array('ISO' => 400, 'Aspect' => 'Vertical' ); |
|
846 | - $resultListFiltered = $this->search('New Zealand', $fields,$filters); |
|
845 | + $filters = array('ISO' => 400, 'Aspect' => 'Vertical'); |
|
846 | + $resultListFiltered = $this->search('New Zealand', $fields, $filters); |
|
847 | 847 | $filteredAggregations = $resultListFiltered->getAggregations()->toArray(); |
848 | 848 | |
849 | 849 | $this->checkDrillingDownHasHappened($filteredAggregations, $originalAggregations); |
@@ -858,8 +858,8 @@ discard block |
||
858 | 858 | 'Aspect' => 'Vertical')); |
859 | 859 | $originalAggregations = $resultList->getAggregations()->toArray(); |
860 | 860 | |
861 | - $filters = array('ISO' => 400, 'Aspect' => 'Vertical', 'Aperture' => 5 ); |
|
862 | - $resultListFiltered = $this->search('New Zealand', $fields,$filters); |
|
861 | + $filters = array('ISO' => 400, 'Aspect' => 'Vertical', 'Aperture' => 5); |
|
862 | + $resultListFiltered = $this->search('New Zealand', $fields, $filters); |
|
863 | 863 | $filteredAggregations = $resultListFiltered->getAggregations()->toArray(); |
864 | 864 | |
865 | 865 | $this->checkDrillingDownHasHappened($filteredAggregations, $originalAggregations); |
@@ -899,7 +899,7 @@ discard block |
||
899 | 899 | private function checkDrillingDownHasHappened($filteredAggregations, $originalAggregations) { |
900 | 900 | $aggCtr = 0; |
901 | 901 | |
902 | - foreach ($filteredAggregations as $filteredAgg) { |
|
902 | + foreach($filteredAggregations as $filteredAgg) { |
|
903 | 903 | $origAgg = $originalAggregations[$aggCtr]; |
904 | 904 | $bucketCtr = 0; |
905 | 905 | $origBuckets = $origAgg->Buckets->toArray(); |
@@ -908,17 +908,17 @@ discard block |
||
908 | 908 | $origCounts = array(); |
909 | 909 | $filteredCounts = array(); |
910 | 910 | |
911 | - foreach ($origBuckets as $bucket) { |
|
911 | + foreach($origBuckets as $bucket) { |
|
912 | 912 | $origCounts[$bucket->Key] = $bucket->DocumentCount; |
913 | 913 | } |
914 | 914 | |
915 | - foreach ($filteredBuckets as $bucket) { |
|
915 | + foreach($filteredBuckets as $bucket) { |
|
916 | 916 | $filteredCounts[$bucket->Key] = $bucket->DocumentCount; |
917 | 917 | } |
918 | 918 | |
919 | 919 | $akf = array_keys($filteredCounts); |
920 | 920 | |
921 | - foreach ($akf as $aggregateKey) { |
|
921 | + foreach($akf as $aggregateKey) { |
|
922 | 922 | $this->assertGreaterThanOrEqual( |
923 | 923 | $filteredCounts[$aggregateKey], $origCounts[$aggregateKey] |
924 | 924 | ); |
@@ -954,8 +954,8 @@ discard block |
||
954 | 954 | $es->setQueryResultManipulator('FlickrPhotoTOElasticaSearchHelper'); |
955 | 955 | |
956 | 956 | //Add filters |
957 | - foreach ($filters as $key => $value) { |
|
958 | - $es->addFilter($key,$value); |
|
957 | + foreach($filters as $key => $value) { |
|
958 | + $es->addFilter($key, $value); |
|
959 | 959 | } |
960 | 960 | |
961 | 961 | $es->showResultsForEmptySearch(); |
@@ -974,7 +974,7 @@ discard block |
||
974 | 974 | * Test searching |
975 | 975 | * http://stackoverflow.com/questions/28305250/elasticsearch-customize-score-for-synonyms-stemming |
976 | 976 | */ |
977 | - private function search($queryText,$fields = array('Title' => 1, 'Description' => 1), |
|
977 | + private function search($queryText, $fields = array('Title' => 1, 'Description' => 1), |
|
978 | 978 | $filters = array()) { |
979 | 979 | $es = new ElasticSearcher(); |
980 | 980 | $es->setStart(0); |
@@ -983,9 +983,9 @@ discard block |
||
983 | 983 | $es->setQueryResultManipulator('FlickrPhotoTOElasticaSearchHelper'); |
984 | 984 | |
985 | 985 | //Add filters |
986 | - foreach ($filters as $key => $value) { |
|
986 | + foreach($filters as $key => $value) { |
|
987 | 987 | error_log("ADDING FILTER RESULT $key, $value"); |
988 | - $es->addFilter($key,$value); |
|
988 | + $es->addFilter($key, $value); |
|
989 | 989 | } |
990 | 990 | |
991 | 991 | $es->showResultsForEmptySearch(); |
@@ -1003,7 +1003,7 @@ discard block |
||
1003 | 1003 | */ |
1004 | 1004 | private function aggregationByName(&$aggregations) { |
1005 | 1005 | $ctr = 0; |
1006 | - foreach ($aggregations as $agg) { |
|
1006 | + foreach($aggregations as $agg) { |
|
1007 | 1007 | $aggregations[$agg->Name] = $agg; |
1008 | 1008 | unset($aggregations[$ctr]); |
1009 | 1009 | $ctr++; |