Permalink
Browse files

fixed filters

  • Loading branch information...
Oliver Dala
Oliver Dala committed Oct 23, 2018
1 parent 2009b42 commit 9e84ce26e1cc246b7d5c92a9b6b7614d1ec1b6b9
Showing with 20 additions and 14 deletions.
  1. +20 −14 phplib/ESClient.php
@@ -175,11 +175,13 @@ private function query($query, $fields=null, $from=null, $to=null, $scroll=false
$conds['lt'] = $to;
}
if(count($conds) > 0) {
$filter = [
$filter[] = [
'range' => [ 'alert_date' => $conds ]
];
}
$filter['query_string'] = [ 'query' => $query ];
$filter[] = [
'query_string' => [ 'query' => $query ]
];
$body = [
'query' => [
@@ -270,11 +272,11 @@ public function bootstrap($query, $from=null, $to=null) {
$conds['lt'] = $to;
}
if(count($conds) > 0) {
$filter = [
$filter[] = [
'range' => [ 'alert_date' => $conds ]
];
}
$filter['query_string'] = [ 'query' => $query ];
$filter[] = ['query_string' => ['query' => $query]];
try {
$data = $client->search([
@@ -326,8 +328,10 @@ public function getActiveAlertCounts() {
$client = self::getClient();
$filter = [
'terms' => [
'state' => [Alert::ST_NEW, Alert::ST_INPROG]
[
'terms' => [
'state' => [Alert::ST_NEW, Alert::ST_INPROG]
]
]
];
$aggs = [
@@ -412,19 +416,20 @@ public function getAlertActivityCounts($range, $search_id=0) {
$client = self::getClient();
$filter = [
'range' => [
'create_date' => [
'lt' => 'now',
'gte' => sprintf('now-%dd/d', $range)
[
'range' => [
'create_date' => [
'lt' => 'now',
'gte' => sprintf('now-%dd/d', $range)
]
]
]
];
if($search_id != 0) {
$filter = [
$filter,
['term' => [
$filter[] = [
'term' => [
'search_id' => $search_id
]]
]
];
}
$aggs = ['agg' => [
@@ -597,3 +602,4 @@ public function unflatten(array $data) {
return $ret;
}
}

0 comments on commit 9e84ce2

Please sign in to comment.