mirror of
https://github.com/rsyslog/loganalyzer.git
synced 2025-09-25 18:59:12 +02:00
Fixed bug in grouping functions of MongoDB Logstream Class
This commit is contained in:
parent
58f24e5c14
commit
a241de09e1
@ -817,15 +817,14 @@ class LogStreamMongoDB extends LogStream {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// --- Create Query Array!
|
// --- Create Query Array!
|
||||||
$myMongoQuery = array();
|
|
||||||
if ( ($res = $this->CreateQueryArray(UID_UNKNOWN)) != SUCCESS )
|
if ( ($res = $this->CreateQueryArray(UID_UNKNOWN)) != SUCCESS )
|
||||||
return $res;
|
return $res;
|
||||||
|
|
||||||
// Copy array
|
// Create Options array
|
||||||
$myMongoQuery = $this->_myMongoQuery;
|
$myOptions = array( 'condition' => $this->_myMongoQuery );
|
||||||
|
|
||||||
// Set default for custom fields!
|
// Set default for counter field!
|
||||||
$myMongoQuery[ $myDBSortedFieldName ] = 0;
|
$myMongoInit = array( $myDBSortedFieldName => 0 );
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
// --- Process Data and consolidate!
|
// --- Process Data and consolidate!
|
||||||
@ -838,7 +837,7 @@ class LogStreamMongoDB extends LogStream {
|
|||||||
OutputDebugMessage("LogStreamMongoDB|ConsolidateItemListByField: Running MongoDB group query", DEBUG_ULTRADEBUG);
|
OutputDebugMessage("LogStreamMongoDB|ConsolidateItemListByField: Running MongoDB group query", DEBUG_ULTRADEBUG);
|
||||||
|
|
||||||
// mongodb group is simular to groupby from MYSQL
|
// mongodb group is simular to groupby from MYSQL
|
||||||
$myResult = $this->_myMongoCollection->group( array($myDBConsFieldName => 1), $myMongoQuery, $groupReduce);
|
$myResult = $this->_myMongoCollection->group( array($myDBConsFieldName => 1), $myMongoInit, $groupReduce, $myOptions );
|
||||||
}
|
}
|
||||||
catch ( MongoCursorException $e )
|
catch ( MongoCursorException $e )
|
||||||
{
|
{
|
||||||
@ -963,21 +962,21 @@ class LogStreamMongoDB extends LogStream {
|
|||||||
//var_dump($myMongoFields);
|
//var_dump($myMongoFields);
|
||||||
|
|
||||||
// --- Create Query Array!
|
// --- Create Query Array!
|
||||||
$myMongoQuery = array();
|
|
||||||
if ( ($res = $this->CreateQueryArray(UID_UNKNOWN)) != SUCCESS )
|
if ( ($res = $this->CreateQueryArray(UID_UNKNOWN)) != SUCCESS )
|
||||||
return $res;
|
return $res;
|
||||||
|
|
||||||
// Copy array
|
// Create Options array
|
||||||
$myMongoQuery = $this->_myMongoQuery;
|
$myOptions = array( 'condition' => $this->_myMongoQuery );
|
||||||
|
|
||||||
// Set default for custom fields!
|
// Set default for counter field!
|
||||||
$myMongoQuery[ $myDBSortedFieldName ] = 0; // Set default for counter field
|
$myMongoInit = array( $myDBSortedFieldName => 0 );
|
||||||
|
|
||||||
//TODO, LIMIT not possible currently!
|
//TODO, LIMIT not possible currently!
|
||||||
// $myMongoQuery[ '$limit' ] = 5;
|
// $myMongoQuery[ '$limit' ] = 5;
|
||||||
//var_dump($myMongoQuery);
|
//var_dump($myMongoQuery);
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
|
/*
|
||||||
// Special handling for date fields
|
// Special handling for date fields
|
||||||
if ( $nConsFieldType == FILTER_TYPE_DATE )
|
if ( $nConsFieldType == FILTER_TYPE_DATE )
|
||||||
{
|
{
|
||||||
@ -987,6 +986,7 @@ class LogStreamMongoDB extends LogStream {
|
|||||||
$mySelectFieldName = $myDBGroupByFieldName . "Grouped";
|
$mySelectFieldName = $myDBGroupByFieldName . "Grouped";
|
||||||
$myDBQueryFieldName = "DATE( " . $myDBConsFieldName . ") AS " . $myDBGroupByFieldName ;
|
$myDBQueryFieldName = "DATE( " . $myDBConsFieldName . ") AS " . $myDBGroupByFieldName ;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// --- Process Data and consolidate!
|
// --- Process Data and consolidate!
|
||||||
// Create reduce function
|
// Create reduce function
|
||||||
@ -1020,7 +1020,7 @@ class LogStreamMongoDB extends LogStream {
|
|||||||
OutputDebugMessage("LogStreamMongoDB|ConsolidateDataByField: Running MongoDB group query", DEBUG_ULTRADEBUG);
|
OutputDebugMessage("LogStreamMongoDB|ConsolidateDataByField: Running MongoDB group query", DEBUG_ULTRADEBUG);
|
||||||
|
|
||||||
// mongodb group is simular to groupby from MYSQL
|
// mongodb group is simular to groupby from MYSQL
|
||||||
$myResult = $this->_myMongoCollection->group( array($myDBConsFieldName => 1), $myMongoQuery, $groupReduce);
|
$myResult = $this->_myMongoCollection->group( array($myDBConsFieldName => 1), $myMongoInit, $groupReduce, $myOptions);
|
||||||
}
|
}
|
||||||
catch ( MongoCursorException $e )
|
catch ( MongoCursorException $e )
|
||||||
{
|
{
|
||||||
@ -1129,15 +1129,17 @@ class LogStreamMongoDB extends LogStream {
|
|||||||
$mySelectFieldName = $myDBFieldName;
|
$mySelectFieldName = $myDBFieldName;
|
||||||
|
|
||||||
// --- Create Query Array!
|
// --- Create Query Array!
|
||||||
$myMongoQuery = array();
|
|
||||||
if ( ($res = $this->CreateQueryArray(UID_UNKNOWN)) != SUCCESS )
|
if ( ($res = $this->CreateQueryArray(UID_UNKNOWN)) != SUCCESS )
|
||||||
return $res;
|
return $res;
|
||||||
|
|
||||||
|
// Create Options array
|
||||||
|
$myOptions = array( 'condition' => $this->_myMongoQuery );
|
||||||
|
|
||||||
// Copy array
|
// Copy array
|
||||||
$myMongoQuery = $this->_myMongoQuery;
|
$myMongoQuery = $this->_myMongoQuery;
|
||||||
|
|
||||||
// Set default for custom fields!
|
// Set default for counter field!
|
||||||
$myMongoQuery[ 'TotalCount' ] = 0;
|
$myMongoInit = array( 'TotalCount' => 0 );
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
// --- Process Data and consolidate!
|
// --- Process Data and consolidate!
|
||||||
@ -1150,7 +1152,7 @@ class LogStreamMongoDB extends LogStream {
|
|||||||
OutputDebugMessage("LogStreamMongoDB|GetCountSortedByField: Running MongoDB group query", DEBUG_ULTRADEBUG);
|
OutputDebugMessage("LogStreamMongoDB|GetCountSortedByField: Running MongoDB group query", DEBUG_ULTRADEBUG);
|
||||||
|
|
||||||
// mongodb group is simular to groupby from MYSQL
|
// mongodb group is simular to groupby from MYSQL
|
||||||
$myResult = $this->_myMongoCollection->group( array($mySelectFieldName => 1), $myMongoQuery, $groupReduce);
|
$myResult = $this->_myMongoCollection->group( array($mySelectFieldName => 1), $myMongoInit, $groupReduce, $myOptions);
|
||||||
}
|
}
|
||||||
catch ( MongoCursorException $e )
|
catch ( MongoCursorException $e )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user