Skip to content

Aggregate Query Commands (Spider)

JoeWinter edited this page Feb 18, 2015 · 1 revision

[Table of Contents](https://github.com/dell-oss/Doradus/wiki/Spider Databases: Table-of-Contents) | Previous | Next
Spider REST Commands: Aggregate Query Commands


Doradus Spider supports two commands for performing aggregate queries.

Aggregate Query via URI

An aggregate query can submit all parameters in the URI of a GET request. The REST command is:

GET /{application}/{table}/_aggregate?{params}

where {application} is the application name, {table} is the perspective table, and {params} are URI parameters separated by ampersands (&). The following parameters are supported:

  • m=metric expression list (required): A list of one or more metric functions to calculate for selected objects. Each function is computed across selected objects, optionally subdivided into groups as defined by the grouping parameter. Example metric function:

      m=COUNT(*)
      m=DISTINCT(Name)
      m=SUM(Size)
      m=MAX(Sender.Person.LastName)
      m=AVERAGE(SendDate)
      m=MAX(Size), MIN(Size), AVERAGE(Size), COUNT(*)		// 4 metric epressions
    
  • q=text (optional): A DQL query expression that defines which objects to include in metric computations. If omitted, all objects are selected (same as q=*). Examples:

      q=*
      q=LastName=Smith
      q=ALL(InternalRecipients.Person.Domain).IsInternal = false
    
  • f=grouping list (optional): A list of one or more grouping expressions, which divide computations into single- or multi-level groups. When this parameter is omitted, the corresponding global query computes a single value for each metric expression. When provided, the corresponding grouped query computes a value for each group value/metric expression combination. Multiple grouping sets can be specified via the GROUP function.Examples:

      f=Tags
      f=TOP(3,Sender.Person.Department)
      f=BATCH(Size,1000,10000,100000),TOP(5,ExternalRecipients.MessageAddress.Domain.Name)
      f=GROUP(*),GROUP(Tags),GROUP(TOP(3,Sender.Person.Office),TOP(3,Sender.Person.Department))
    
  • cf=grouping list (optional): For multi-level grouped queries, Doradus spider supports a special feature called composite grouping. It is requested by using &cf instead of &f, and it is meaningful only for aggregate queries with 2 or more grouping levels. The &cf parameter’s value is the same as for &f, but it causes extra composite values to be computed for intermediate grouping levels.:

Below is an example aggregate query using URI parameters:

GET /Msgs/Message/_aggregate?q=Size>10000&m=COUNT(*)&f=TOP(3,Sender.Person.Department)

Aggregate Query via Entity

Aggregate query parameters can be provided in an input entity instead of URI parameters. The same REST command is used except that no URI parameters are provided. Because some browsers/HTTP frameworks do not support HTTP GET-with-entity, this command also supports the PUT method even though no modifications are made. Both of the following are equivalent:

GET /{application}/{table}/_aggregate
PUT /{application}/{table}/_aggregate

where {application} is the application name and {table} is the perspective table. The input entity must be a JSON or XML document whose root element is aggregate-searc. Aggregate query parameters are given as child elements. URI query parameters map to the following element names:

URI Parameter Element name
cf composite-fields
f grouping-fields
m metric
q query

Below is an example aggregate query request entity in XML:

<aggregate-search>
	<query>Size&gt;10000</query>
	<metric>COUNT(*)</metric>
	<grouping-fields>TOP(3,Sender.Person.Department)</grouping-fields>
</aggregate-search>

In JSON:

{"aggregate-search": {
	"query": "Size>10000",
	"metric": "COUNT(*)",
	"grouping-fields": "TOP(3,Sender.Person.Department)",
}}
Clone this wiki locally