|
@@ -33,9 +33,9 @@ discard block |
|
|
block discarded – undo |
|
33
|
33
|
$aggregations = $resultList->getAggregations(); |
|
34
|
34
|
|
|
35
|
35
|
error_log('AGGS'); |
|
36
|
|
- foreach ($aggregations as $agg) { |
|
|
36
|
+ foreach($aggregations as $agg) { |
|
37
|
37
|
error_log($agg->Name); |
|
38
|
|
- foreach ($agg->Buckets as $bucket) { |
|
|
38
|
+ foreach($agg->Buckets as $bucket) { |
|
39
|
39
|
error_log("\t$bucket->Key -> $bucket->DocumentCount"); |
|
40
|
40
|
} |
|
41
|
41
|
} |
|
@@ -429,7 +429,7 @@ discard block |
|
|
block discarded – undo |
|
429
|
429
|
$resultList = $this->search(''); |
|
430
|
430
|
|
|
431
|
431
|
//assert there are actually some results |
|
432
|
|
- $this->assertGreaterThan(0,$resultList->getTotalItems()); |
|
|
432
|
+ $this->assertGreaterThan(0, $resultList->getTotalItems()); |
|
433
|
433
|
$aggregations = $resultList->getAggregations()->toArray(); |
|
434
|
434
|
|
|
435
|
435
|
/* |
|
@@ -448,49 +448,49 @@ discard block |
|
|
block discarded – undo |
|
448
|
448
|
//Asserting aggregate of ISO, 64 has count 5 |
|
449
|
449
|
$this->assertEquals("64", $buckets[0]->Key); |
|
450
|
450
|
$this->assertEquals(5, $buckets[0]->DocumentCount); |
|
451
|
|
- $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',64)->count(),5); |
|
|
451
|
+ $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 64)->count(), 5); |
|
452
|
452
|
$bucketSum += $buckets[0]->DocumentCount; |
|
453
|
453
|
|
|
454
|
454
|
//Asserting aggregate of ISO, 100 has count 11 |
|
455
|
455
|
$this->assertEquals("100", $buckets[1]->Key); |
|
456
|
456
|
$this->assertEquals(11, $buckets[1]->DocumentCount); |
|
457
|
|
- $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',100)->count(),11); |
|
|
457
|
+ $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 100)->count(), 11); |
|
458
|
458
|
$bucketSum += $buckets[1]->DocumentCount; |
|
459
|
459
|
|
|
460
|
460
|
//Asserting aggregate of ISO, 200 has count 12 |
|
461
|
461
|
$this->assertEquals("200", $buckets[2]->Key); |
|
462
|
462
|
$this->assertEquals(12, $buckets[2]->DocumentCount); |
|
463
|
|
- $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',200)->count(),12); |
|
|
463
|
+ $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 200)->count(), 12); |
|
464
|
464
|
$bucketSum += $buckets[2]->DocumentCount; |
|
465
|
465
|
|
|
466
|
466
|
//Asserting aggregate of ISO, 400 has count 13 |
|
467
|
467
|
$this->assertEquals("400", $buckets[3]->Key); |
|
468
|
468
|
$this->assertEquals(13, $buckets[3]->DocumentCount); |
|
469
|
|
- $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',400)->count(),13); |
|
|
469
|
+ $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 400)->count(), 13); |
|
470
|
470
|
$bucketSum += $buckets[3]->DocumentCount; |
|
471
|
471
|
|
|
472
|
472
|
//Asserting aggregate of ISO, 800 has count 16 |
|
473
|
473
|
$this->assertEquals("800", $buckets[4]->Key); |
|
474
|
474
|
$this->assertEquals(16, $buckets[4]->DocumentCount); |
|
475
|
|
- $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',800)->count(),16); |
|
|
475
|
+ $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 800)->count(), 16); |
|
476
|
476
|
$bucketSum += $buckets[4]->DocumentCount; |
|
477
|
477
|
|
|
478
|
478
|
//Asserting aggregate of ISO, 1600 has count 13 |
|
479
|
479
|
$this->assertEquals("1600", $buckets[5]->Key); |
|
480
|
480
|
$this->assertEquals(13, $buckets[5]->DocumentCount); |
|
481
|
|
- $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',1600)->count(),13); |
|
|
481
|
+ $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 1600)->count(), 13); |
|
482
|
482
|
$bucketSum += $buckets[5]->DocumentCount; |
|
483
|
483
|
|
|
484
|
484
|
//Asserting aggregate of ISO, 2000 has count 11 |
|
485
|
485
|
$this->assertEquals("2000", $buckets[6]->Key); |
|
486
|
486
|
$this->assertEquals(11, $buckets[6]->DocumentCount); |
|
487
|
|
- $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',2000)->count(),11); |
|
|
487
|
+ $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 2000)->count(), 11); |
|
488
|
488
|
$bucketSum += $buckets[6]->DocumentCount; |
|
489
|
489
|
|
|
490
|
490
|
//Asserting aggregate of ISO, 3200 has count 19 |
|
491
|
491
|
$this->assertEquals("3200", $buckets[7]->Key); |
|
492
|
492
|
$this->assertEquals(19, $buckets[7]->DocumentCount); |
|
493
|
|
- $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',3200)->count(),19); |
|
|
493
|
+ $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 3200)->count(), 19); |
|
494
|
494
|
$bucketSum += $buckets[7]->DocumentCount; |
|
495
|
495
|
$this->assertEquals(100, $bucketSum); |
|
496
|
496
|
|
|
@@ -503,43 +503,43 @@ discard block |
|
|
block discarded – undo |
|
503
|
503
|
//Asserting aggregate of Focal Length, 24 has count 12 |
|
504
|
504
|
$this->assertEquals("24", $buckets[0]->Key); |
|
505
|
505
|
$this->assertEquals(12, $buckets[0]->DocumentCount); |
|
506
|
|
- $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',24)->count(),12); |
|
|
506
|
+ $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 24)->count(), 12); |
|
507
|
507
|
$bucketSum += $buckets[0]->DocumentCount; |
|
508
|
508
|
|
|
509
|
509
|
//Asserting aggregate of Focal Length, 50 has count 11 |
|
510
|
510
|
$this->assertEquals("50", $buckets[1]->Key); |
|
511
|
511
|
$this->assertEquals(11, $buckets[1]->DocumentCount); |
|
512
|
|
- $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',50)->count(),11); |
|
|
512
|
+ $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 50)->count(), 11); |
|
513
|
513
|
$bucketSum += $buckets[1]->DocumentCount; |
|
514
|
514
|
|
|
515
|
515
|
//Asserting aggregate of Focal Length, 80 has count 11 |
|
516
|
516
|
$this->assertEquals("80", $buckets[2]->Key); |
|
517
|
517
|
$this->assertEquals(11, $buckets[2]->DocumentCount); |
|
518
|
|
- $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',80)->count(),11); |
|
|
518
|
+ $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 80)->count(), 11); |
|
519
|
519
|
$bucketSum += $buckets[2]->DocumentCount; |
|
520
|
520
|
|
|
521
|
521
|
//Asserting aggregate of Focal Length, 90 has count 20 |
|
522
|
522
|
$this->assertEquals("90", $buckets[3]->Key); |
|
523
|
523
|
$this->assertEquals(20, $buckets[3]->DocumentCount); |
|
524
|
|
- $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',90)->count(),20); |
|
|
524
|
+ $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 90)->count(), 20); |
|
525
|
525
|
$bucketSum += $buckets[3]->DocumentCount; |
|
526
|
526
|
|
|
527
|
527
|
//Asserting aggregate of Focal Length, 120 has count 12 |
|
528
|
528
|
$this->assertEquals("120", $buckets[4]->Key); |
|
529
|
529
|
$this->assertEquals(12, $buckets[4]->DocumentCount); |
|
530
|
|
- $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',120)->count(),12); |
|
|
530
|
+ $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 120)->count(), 12); |
|
531
|
531
|
$bucketSum += $buckets[4]->DocumentCount; |
|
532
|
532
|
|
|
533
|
533
|
//Asserting aggregate of Focal Length, 150 has count 17 |
|
534
|
534
|
$this->assertEquals("150", $buckets[5]->Key); |
|
535
|
535
|
$this->assertEquals(17, $buckets[5]->DocumentCount); |
|
536
|
|
- $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',150)->count(),17); |
|
|
536
|
+ $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 150)->count(), 17); |
|
537
|
537
|
$bucketSum += $buckets[5]->DocumentCount; |
|
538
|
538
|
|
|
539
|
539
|
//Asserting aggregate of Focal Length, 200 has count 17 |
|
540
|
540
|
$this->assertEquals("200", $buckets[6]->Key); |
|
541
|
541
|
$this->assertEquals(17, $buckets[6]->DocumentCount); |
|
542
|
|
- $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',200)->count(),17); |
|
|
542
|
+ $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 200)->count(), 17); |
|
543
|
543
|
$bucketSum += $buckets[6]->DocumentCount; |
|
544
|
544
|
$this->assertEquals(100, $bucketSum); |
|
545
|
545
|
|
|
@@ -827,7 +827,7 @@ discard block |
|
|
block discarded – undo |
|
827
|
827
|
$originalAggregations = $resultList->getAggregations()->toArray(); |
|
828
|
828
|
|
|
829
|
829
|
$filters = array('ISO' => 3200); |
|
830
|
|
- $resultListFiltered = $this->search('New Zealand', $fields,$filters); |
|
|
830
|
+ $resultListFiltered = $this->search('New Zealand', $fields, $filters); |
|
831
|
831
|
$filteredAggregations = $resultListFiltered->getAggregations()->toArray(); |
|
832
|
832
|
|
|
833
|
833
|
$this->checkDrillingDownHasHappened($filteredAggregations, $originalAggregations); |
|
@@ -839,8 +839,8 @@ discard block |
|
|
block discarded – undo |
|
839
|
839
|
$resultList = $this->search('New Zealand', $fields, array('ISO' => 400)); |
|
840
|
840
|
$originalAggregations = $resultList->getAggregations()->toArray(); |
|
841
|
841
|
|
|
842
|
|
- $filters = array('ISO' => 400, 'Aspect' => 'Vertical' ); |
|
843
|
|
- $resultListFiltered = $this->search('New Zealand', $fields,$filters); |
|
|
842
|
+ $filters = array('ISO' => 400, 'Aspect' => 'Vertical'); |
|
|
843
|
+ $resultListFiltered = $this->search('New Zealand', $fields, $filters); |
|
844
|
844
|
$filteredAggregations = $resultListFiltered->getAggregations()->toArray(); |
|
845
|
845
|
|
|
846
|
846
|
$this->checkDrillingDownHasHappened($filteredAggregations, $originalAggregations); |
|
@@ -855,8 +855,8 @@ discard block |
|
|
block discarded – undo |
|
855
|
855
|
'Aspect' => 'Vertical')); |
|
856
|
856
|
$originalAggregations = $resultList->getAggregations()->toArray(); |
|
857
|
857
|
|
|
858
|
|
- $filters = array('ISO' => 400, 'Aspect' => 'Vertical', 'Aperture' => 5 ); |
|
859
|
|
- $resultListFiltered = $this->search('New Zealand', $fields,$filters); |
|
|
858
|
+ $filters = array('ISO' => 400, 'Aspect' => 'Vertical', 'Aperture' => 5); |
|
|
859
|
+ $resultListFiltered = $this->search('New Zealand', $fields, $filters); |
|
860
|
860
|
$filteredAggregations = $resultListFiltered->getAggregations()->toArray(); |
|
861
|
861
|
|
|
862
|
862
|
$this->checkDrillingDownHasHappened($filteredAggregations, $originalAggregations); |
|
@@ -896,7 +896,7 @@ discard block |
|
|
block discarded – undo |
|
896
|
896
|
private function checkDrillingDownHasHappened($filteredAggregations, $originalAggregations) { |
|
897
|
897
|
$aggCtr = 0; |
|
898
|
898
|
|
|
899
|
|
- foreach ($filteredAggregations as $filteredAgg) { |
|
|
899
|
+ foreach($filteredAggregations as $filteredAgg) { |
|
900
|
900
|
$origAgg = $originalAggregations[$aggCtr]; |
|
901
|
901
|
$bucketCtr = 0; |
|
902
|
902
|
$origBuckets = $origAgg->Buckets->toArray(); |
|
@@ -905,17 +905,17 @@ discard block |
|
|
block discarded – undo |
|
905
|
905
|
$origCounts = array(); |
|
906
|
906
|
$filteredCounts = array(); |
|
907
|
907
|
|
|
908
|
|
- foreach ($origBuckets as $bucket) { |
|
|
908
|
+ foreach($origBuckets as $bucket) { |
|
909
|
909
|
$origCounts[$bucket->Key] = $bucket->DocumentCount; |
|
910
|
910
|
} |
|
911
|
911
|
|
|
912
|
|
- foreach ($filteredBuckets as $bucket) { |
|
|
912
|
+ foreach($filteredBuckets as $bucket) { |
|
913
|
913
|
$filteredCounts[$bucket->Key] = $bucket->DocumentCount; |
|
914
|
914
|
} |
|
915
|
915
|
|
|
916
|
916
|
$akf = array_keys($filteredCounts); |
|
917
|
917
|
|
|
918
|
|
- foreach ($akf as $aggregateKey) { |
|
|
918
|
+ foreach($akf as $aggregateKey) { |
|
919
|
919
|
$this->assertGreaterThanOrEqual( |
|
920
|
920
|
$filteredCounts[$aggregateKey], $origCounts[$aggregateKey] |
|
921
|
921
|
); |
|
@@ -951,8 +951,8 @@ discard block |
|
|
block discarded – undo |
|
951
|
951
|
$es->setQueryResultManipulator('FlickrPhotoTOElasticaSearchHelper'); |
|
952
|
952
|
|
|
953
|
953
|
//Add filters |
|
954
|
|
- foreach ($filters as $key => $value) { |
|
955
|
|
- $es->addFilter($key,$value); |
|
|
954
|
+ foreach($filters as $key => $value) { |
|
|
955
|
+ $es->addFilter($key, $value); |
|
956
|
956
|
} |
|
957
|
957
|
|
|
958
|
958
|
$es->showResultsForEmptySearch(); |
|
@@ -971,7 +971,7 @@ discard block |
|
|
block discarded – undo |
|
971
|
971
|
* Test searching |
|
972
|
972
|
* http://stackoverflow.com/questions/28305250/elasticsearch-customize-score-for-synonyms-stemming |
|
973
|
973
|
*/ |
|
974
|
|
- private function search($queryText,$fields = array('Title' => 1, 'Description' => 1), |
|
|
974
|
+ private function search($queryText, $fields = array('Title' => 1, 'Description' => 1), |
|
975
|
975
|
$filters = array()) { |
|
976
|
976
|
$es = new ElasticSearcher(); |
|
977
|
977
|
$es->setStart(0); |
|
@@ -980,9 +980,9 @@ discard block |
|
|
block discarded – undo |
|
980
|
980
|
$es->setQueryResultManipulator('FlickrPhotoTOElasticaSearchHelper'); |
|
981
|
981
|
|
|
982
|
982
|
//Add filters |
|
983
|
|
- foreach ($filters as $key => $value) { |
|
|
983
|
+ foreach($filters as $key => $value) { |
|
984
|
984
|
error_log("ADDING FILTER RESULT $key, $value"); |
|
985
|
|
- $es->addFilter($key,$value); |
|
|
985
|
+ $es->addFilter($key, $value); |
|
986
|
986
|
} |
|
987
|
987
|
|
|
988
|
988
|
$es->showResultsForEmptySearch(); |