Get Free Trial
API reference
Table of contents

/select request for the flat table

[starting from version: 2.8]

A request for data.

Request

{
    "type": "select"
    "index": string,
    "query": {
        "fields"[]: FieldObject,
        "filter": FilterObject[] | FilterGroupObject,
        "aggs": {
            "values"[]: {
                "field": FieldObject,
                "func": string
            }
        }
    },
    "page": number
}

The request has the following parameters:

  • type — String. The type of the request. In this case, it is "select".
  • index – String. The dataset identifier.
  • query – Object. A query object. Contains the following properties:
    • fields – Array of FieldObjects. An array of fields (columns) to include in the response.
    • filter optional – Array of FilterObjects | FilterGroupObject. Query filters. The part of a query that specifies which filters should be applied to the data.
      If the server does not support multilevel hierarchies (i.e., the filters.advanced property is set to false), the filter’s structure is an array of FilterObjects.
      If multilevel hierarchies are supported, the filter can be:
    • aggs optional – Object. Query column totals. Contains the following properties:
      • values – Array of objects. Columns to aggregate totals for.
        Fields with at least one supported aggregation defined in the schema can be selected for this part of the query. Each object in the array has the following properties:
        • fieldFieldObject. The field selected as a measure.
        • func – String. The aggregation function name. For each field, the list of supported aggregations is defined in the response to the /fields request. Supported values may include: "sum", "count", "distinctcount", "average", "median", "product", "min", "max", "stdevp", "stdevs", "none", or a custom aggregation. Note: for the fields of the "number" type, Flexmonster Pivot supports built-in front-end aggregations.
  • page – Number. The page number. It can be used to load data by parts. If the response contains the pageTotal parameter, additional requests will be performed to load the remaining pages. Starts from 0.

Response

{
    "fields"[]: {
        "uniqueName": string
    },
    "hits"[]: [
        (index): string | number
    ],
    "aggs"[]: {
        "values": {
            (uniqueName): {
                (func): number
            }
        }
    },
    "page": number,
    "pageTotal": number
}

The response has the following parameters:

  • fields – Array of objects. Fields (columns) included in the response. Each object in the array has the following properties:
    • uniqueName – String. The field’s unique name.
  • hits – Array. A two-dimensional array containing data:
    • (index) – String | Number. A data row, where (index) is a field (column) index.
  • aggs optional – Array of objects. Column totals. Each object in the array has the following properties:
    • values – Object. Numeric values that are calculated for column totals. Contains the following properties:
      • (uniqueName) – Object. The field’s unique name.
        • (func) – Number. The result of the calculation, where (func) is the aggregation function.
  • page optional – Number. The current page number. Starts from 0.
  • pageTotal optional – Number. The total number of pages. It can be used to load members by parts.

Example

Request:

{
    "index": "data-set-123",
    "type": "select",
    "query": {
        "fields": [
            {
               "uniqueName": "country"
            },
            {
               "uniqueName": "city"
            },
            {
               "uniqueName": "price"
            },
            {
               "uniqueName": "quantity"
            }
        ],
        "aggs": {
            "values": [{
                "func": "sum", 
                "field": {
                   "uniqueName": "price"
                }
            }, {
                "func": "sum", 
                "field": {
                   "uniqueName": "quantity"
                }
            }]
        }
    },
    "page": 0
}

Response:

{
    "fields": [
        { "uniqueName": "country" },
        { "uniqueName": "city" },
        { "uniqueName": "price" },
        { "uniqueName": "quantity" }
    ],
    "hits": [
        ["Canada", "Toronto", 53, 2],
        ["...", "...", 1, 1]
    ],
    "aggs": [{
        "values": {
            "price": {
                "sum": 123
            },
            "quantity": {
                "sum": 5
            }
        }
    }]
}

See also

/handshake request
/fields request
/members request
/select request for pivot table
/select request for drill-through view