Class: ResultsContext

ResultsContext(marClient, searchId, resultCount, errorCount, hostCount, subscribedHostCount)

This object is used to access to the results of a MAR search.

Constructor

new ResultsContext(marClient, searchId, resultCount, errorCount, hostCount, subscribedHostCount)

Parameters:
Name Type Description
marClient MarClient

The MAR client used to perform the search.

searchId String

The identifier assigned to the search.

resultCount Number

The total count of items available in the search results.

errorCount Number

The count of errors that were reported during the search.

hostCount Number

The count of endpoints that responded to the search.

subscribedHostCount Number

The count of endpoints that were connected to the DXL fabric when the search started.

Source:
See:

Members

errorCount :Number

The count of errors that were reported during the search.

Type:
  • Number
Source:

hostCount :Number

The count of endpoints that responded to the search.

Type:
  • Number
Source:

resultCount :Number

The total count of items available in the search results.

Type:
  • Number
Source:

searchId :String

The identifier assigned to the search.

Type:
  • String
Source:

subscribedHostCount :Number

The count of endpoints that were connected to the DXL fabric when the search started.

Type:
  • Number
Source:

Methods

getResults(callback, options)

This method is used to retrieve a particular set of results from a MAR search.

Results

Each search result item has the following fields:

  • id: The identifier of the item within the search results
  • count: The number of times that the search result was reported
  • created_at: The item timestamp
  • output: The search result data where each key is composed of <CollectorName>|<OutputName> and the value that corresponds to that collector and output name.

The object below is an example of a result that would be returned from the following textual search:

Processes name, id where Processes name equals "csrss" and Processes name contains "exe" or Processes size not greater than 200

{
  'startIndex': 0,
  'totalItems': 2,
  'currentItemCount': 2,
  'itemsPerPage': 20,
  'items': [
    {
      'id': '{1=[[System Process], 0]}',
      'count': 2,
      'created_at': '2016-11-16T22:50:04.650Z',
      'output': {
        'Processes|id': 0,
        'Processes|name': '[System Process]'
      }
    },
    {
      'id": '{1=[System, 4]}',
      'count': 1,
      'created_at': '2016-11-16T22:50:04.650Z',
      'output': {
        'Processes|id': 4,
        'Processes|name': 'System'
      }
    }
  ]
}
Parameters:
Name Type Description
callback function

Callback function to invoke with a set of results from the search. If an error occurs when performing the lookup, the first parameter supplied to the callback contains an Error object with failure details. On successful completion of the search, the set of results, as an object, is provided as the second parameter to the callback.

options Object

Options to use in getting search results.

Properties
Name Type Attributes Default Description
offset Number <optional>
0

Index of the first result item to be returned. This value is 0 based.

limit Number <optional>
20

The maximum number of items to return in the results.

textFilter String <optional>

A text based filter to limit the results.

sortBy String <optional>
count

The field that will be used to sort the results.

sortDirection String <optional>
desc

values: ascending asc or descending desc.

Source:
Example
resultContext.getResults(
  function (resultError, searchResult) {
    if (resultError) {
      // Handle error
    } else {
      searchResult.items.forEach(function (item) {
        console.log('    ' + item.output['Processes|name'])
      })
    }
  },
  {
    sortBy: 'Processes|name',
    sortDirection: 'asc'
  }
)