Skip to content
This repository has been archived by the owner on Nov 22, 2017. It is now read-only.

Commit

Permalink
issue #6 - forced query. Added filter_string to config
Browse files Browse the repository at this point in the history
  • Loading branch information
Rashid Khan committed Feb 6, 2012
1 parent 1308a42 commit fd520dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
// Results to show per page
'results_per_page' => 100,

// You may wish to insert a default search which all user searches
// must match. For example @source_host:www1 might only show results
// from www1.
'filter_string' => '',

// When searching, Kibana will attempt to only search indices
// that match your timeframe, to make searches faster. You can
// turn this behavior off if you use something other than daily
Expand Down
7 changes: 6 additions & 1 deletion loader2.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,13 @@ protected function buildQuery ($req) {
// Contruct the query
$query = new stdClass;
$query->from = $req->offset;

$filter_string = ($this->config['filter_string'] == "")?
"":" AND ".$this->config['filter_string'];

$query->query->filtered->query->query_string->query =
($req->search == "")? "*": $req->search;
($req->search == "")? "*" . $filter_string:
"(".$req->search.")" . $filter_string;
$query->query->filtered->query->query_string->default_field = $this->config['primary_field'];
$query->size = $this->config['results_per_page'];
$query->sort->{'@timestamp'}->order = 'desc';
Expand Down

0 comments on commit fd520dc

Please sign in to comment.