Skip to content

Querying events

Rishabh edited this page Jun 21, 2014 · 8 revisions

The query analytics is used to filter and search for events. The request supports pagination.

Request

{
    "opcode": "query",          //This is a query operation (not-null)
    "table": "test-app",        //Your table/app name (not-null)
    "filters" : []              //Array of filters (default: no filters)
    "sort": {                   //Result sorting (default: {_timestamp, desc})
        "field": "_timestamp",  //You can put other field name if required. (default: _timestamp)
        "order": "asc"          //asc: ascending, desc: descending (default: desc)
    },
    "from": 0,                  //Start record number (default: 0)
    "limit": 10                 //Number of records to get (default: 10)
}

##Request (With Filter) The following will get the first ten events with field "os" not being equal to "ios", sort it in latest first (descending) order on time at which it came into the system (_timestamp field).

{
    "opcode": "query",
    "table": "test-app",
    "filters": [
        {
            "operator": "not_equals",
            "field": "os",
            "value": "ios"
        }
    ]
}

Response

{
    "opcode": "query",
    "documents": [
        {
            "id": "255c08c8-3b21-4acb-89c9-0dc834647b56",
            "timestamp": 1401445491709,
            "data": {
                //Your event
            }
        },
        {
            "id": "4d3a4529-6c90-4f41-9664-d06f53738fde",
            "timestamp": 1401445491709,
            "data": {
                //Your event
            }
        },
        {
            "id": "bc36d174-eeaa-4413-ae12-ed21646b8655",
            "timestamp": 1401445491709,
            "data": {
                //Your event
            }
        }
    ]
}

Multiple filters can be applied in same query.

For complete list of applicable filters, refer Filters.