Skip to content

Commit

Permalink
Fixed potentially slow score/trend on segmented result sets. Fixed sc…
Browse files Browse the repository at this point in the history
…ore/trend from pages > 1
  • Loading branch information
Rashid Khan committed Apr 6, 2012
1 parent 4a0f260 commit 9753518
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 4 additions & 1 deletion js/ajax.js
Expand Up @@ -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("");

Expand Down Expand Up @@ -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")});

Expand Down
14 changes: 8 additions & 6 deletions loader2.php
Expand Up @@ -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;
}
Expand All @@ -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;
Expand All @@ -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;

Expand All @@ -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'])));
Expand Down

0 comments on commit 9753518

Please sign in to comment.