diff --git a/js/ajax.js b/js/ajax.js index 0733feab2..a7de87157 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -126,7 +126,7 @@ function getPage() { //console.log( // 'curl -XGET \'http://elasticsearch:9200/'+resultjson.indices+ // '/_search?pretty=true\' -d\''+resultjson.elasticsearch_json+'\''); - //console.log(resultjson.debug); + // console.log(resultjson.debug); $('#graphheader,#graph').text(""); @@ -171,14 +171,17 @@ function getPage() { } $("#sidebar").delegate("li.analyze_btn a", "click", function () { + window.hashjson.offset = 0; analyzeField( $(this).parents().eq(2).children('a').text(), "analyze")}); $("#sidebar").delegate("li.trend_btn a", "click",function () { + window.hashjson.offset = 0; analyzeField( $(this).parents().eq(2).children('a').text(), "trend")}); $("#sidebar").delegate("li.stat_btn a", "click",function () { + window.hashjson.offset = 0; analyzeField( $(this).parents().eq(2).children('a').text(), "mean")}); diff --git a/loader2.php b/loader2.php index 6192c620f..93424752d 100644 --- a/loader2.php +++ b/loader2.php @@ -262,7 +262,8 @@ protected function processQuery ($req, $query) { while($return->hits <= ($req->offset + $query->size) && $i < sizeof($index_array)) { - $return->debug[$i] = $this->index; + $query->size = $query->size - sizeof($result->hits->hits); + $return->debug[$i] = $query->size; if(($query->size - $req->offset) < 0) { $query->from = 0; } @@ -276,11 +277,6 @@ protected function processQuery ($req, $query) { $result->hits->hits,$result_tmp->hits->hits); $i++; } - if($req->mode == '') { - $slice = $this->config['results_per_page']; - $result->hits->hits = array_slice($result->hits->hits, 0, $slice); - } - } else { $result = $this->esQuery($query); $return->hits = $result->hits->total; @@ -298,10 +294,14 @@ protected function processQuery ($req, $query) { switch ($req->mode) { case 'analyze': + $slice = $this->config['analyze_limit']; + $result->hits->hits = array_slice($result->hits->hits, 0, $slice); $return = $this->analyzeField($req, $query, $return, $result); break; case 'trend': + $slice = $this->config['analyze_limit']; + $result->hits->hits = array_slice($result->hits->hits, 0, $slice); $return = $this->trendField($req, $query, $return, $result); break; @@ -310,6 +310,8 @@ protected function processQuery ($req, $query) { break; default: + $slice = $this->config['results_per_page']; + $result->hits->hits = array_slice($result->hits->hits, 0, $slice); $base_fields = array_values(array_unique(array_merge( array('@message'), $this->config['default_fields'])));