@@ -512,7 +512,7 @@ public function log($message = NULL) {
512512 * @return integer
513513 */
514514 public function getTotalItems () {
515- return $ this ->result ['totalItemCount ' ];
515+ return $ this ->result ['total ' ];
516516 }
517517
518518 /**
@@ -554,27 +554,19 @@ public function fetch() {
554554 $ response = $ this ->elasticSearchClient ->getIndex ()->request ('GET ' , '/_search ' , array (), json_encode ($ this ->request ));
555555 $ timeAfterwards = microtime (TRUE );
556556
557- $ treatedContent = $ response ->getTreatedContent ();
557+ $ this -> result =& $ response ->getTreatedContent ();
558558
559- $ hits = array ();
560559 $ this ->result ['nodes ' ] = array ();
561- if (array_key_exists ('hits ' , $ treatedContent ) && is_array ($ treatedContent ['hits ' ]) && count ($ treatedContent ['hits ' ]) > 0 ) {
562- $ hits = $ treatedContent ['hits ' ];
563- $ this ->result ['nodes ' ] = $ this ->convertHitsToNodes ($ treatedContent ['hits ' ]);
560+ if (array_key_exists ('hits ' , $ this ->result ) && is_array ($ this ->result ['hits ' ]) && count ($ this ->result ['hits ' ]) > 0 ) {
561+ $ this ->result ['nodes ' ] = $ this ->convertHitsToNodes ($ this ->result ['hits ' ]);
564562 }
565563
566564 if ($ this ->logThisQuery === TRUE ) {
567565 $ this ->logger ->log (sprintf ('Query Log (%s): %s -- execution time: %s ms -- Limit: %s -- Number of results returned: %s -- Total Results: %s ' ,
568- $ this ->logMessage , json_encode ($ this ->request ), (($ timeAfterwards - $ timeBefore ) * 1000 ), $ this ->limit , count ($ hits ['hits ' ]), $ hits ['total ' ])
566+ $ this ->logMessage , json_encode ($ this ->request ), (($ timeAfterwards - $ timeBefore ) * 1000 ), $ this ->limit , count ($ this -> result [ ' hits ' ] ['hits ' ]), $ this -> result [ ' hits ' ] ['total ' ])
569567 , LOG_DEBUG );
570568 }
571569
572- $ this ->result ['totalItemCount ' ] = $ hits ['total ' ];
573-
574- if (array_key_exists ('aggregations ' , $ treatedContent )) {
575- $ this ->result ['aggregations ' ] = $ treatedContent ['aggregations ' ];
576- }
577-
578570 return $ this ->result ;
579571 }
580572
@@ -704,10 +696,10 @@ public function allowsCallOfMethod($methodName) {
704696 }
705697
706698 /**
707- * @param $hits
708- * @return array
699+ * @param array $hits
700+ * @return array Array of Node objects
709701 */
710- protected function convertHitsToNodes ($ hits ) {
702+ protected function convertHitsToNodes (array $ hits ) {
711703 $ nodes = array ();
712704 $ elasticSearchHitPerNode = array ();
713705
0 commit comments