Search and Filter Data

4 min

The OpenHES API offers a search functionality to locate items within the system.

By using filtering and sorting options, you can refine search results and easily manage large numbers of configured items.


Important

All requests in this documentation follow this endpoint structure:

/io.clbs.openhes.services.svcapi.ApiService/{endpoint}

Replace {endpoint} with the specific API action listed in each section.


Search

To search for any items in OpenHES, send a request to the appropriate endpoint as shown below:

Item Endpoint
Bulks ListBulks
Jobs in bulks* ListBulkJobs
Communication buses ListCommunicationBuses
Communication units ListCommunicationUnits
Registers ListDeviceConfigurationRegisters
Templates ListDeviceConfigurationTemplates
Drivers ListDrivers
Devices ListDevices
Device groups ListDeviceGroups
Devices in device groups* ListDeviceGroupDevices
Modem pools ListModemPools
Variables ListVariables

* Requests to these endpoints require also the ID of the item.

Example requests:

  • Search with a limited number of results.
{
  "pageSize": 1000,
  "offset": 0,
}
  • List all devices in a group with the 01959ecb-6c9b-7664-85ec-d3a754ada88b ID.
{
  "groupId": "01959ecb-6c9b-7664-85ec-d3a754ada88b",
  "selector": {
    "pageSize": 1000,
    "offset": 0,
    "sortBy": [
      {
        "fieldId": "o.spec.dctId",
        "desc": true
      },
      {
        "fieldId": "o.spec.externalId",
        "desc": false
      }
    ]    
  }
}

API OBJECT documentation (List Items)


Filter Search Results

To narrow the results, you can apply filters based on specific criteria, such as IDs and Metadata.

The supported filter operators are:

  • EQUAL
  • NOT_EQUAL
  • GREATER_THAN
  • GREATER_THAN_OR_EQUAL
  • LESS_THAN, LESS_THAN_OR_EQUAL
  • CONTAINS
  • NOT_CONTAINS
  • STARTS_WITH
  • ENDS_WITH

Example request:

  • Filter devices that use the LANDISGYR_GENERIC_DLMS_SN driver:
{
  "pageSize": 100,
  "offset": 0,
  "filterBy": [
    {
      "fieldId": "o.spec.driverType",
      "operator": "EQUAL",
      "dataType": "TEXT",
      "text": [
        "LANDISGYR_GENERIC_DLMS_SN"
      ]
    }
  ]
}

API OBJECT documentation (Filter Items)


Sort Results

To organize search results, you can sort and arrange items according to their attributes.

Example request:

  • Sort devices first by their template ID dctId and then by externalId:
{
  "pageSize": 100,
  "offset": 0,
  "sortBy": [
    {
      "fieldId": "o.spec.dctId",
      "desc": true
    },
    {
      "fieldId": "o.spec.externalId",
      "desc": false
    }
  ]
}

API OBJECT documentation (Sort Items)