from & to: Search Examples

The search operations from & to will search for entities where the search attribute value is before or after the specified timestamp.

The search operations from & to should only be used to search for date type fields and formatted in ISO-8601.
The search operations from & to are inclusive, so values that exactly match the timestamp will be included in the results.

Example 1: Search for entities created after a timestamp

Search:

  • Use the search API: Device Search
  • Match the attribute _creationTime with the value of or after 2023-06-08T06:41:38.166Z
  • Limit the number of results to 10 per page
  • Return the first page

Filter object will look like this:

{
  "filter": {   
    "_creationTime": {
      "from": "2023-06-08T06:41:38.166Z"
    }
  },
  "limit": 10,
  "page": 0
}

Encoded API call:

https://api.dev.example.biot-med.com/device/v2/devices?searchRequest=%7B%0A%20%20%22filter%22%3A%20%7B%20%20%20%0A%20%20%20%20%22_creationTime%22%3A%20%7B%0A%20%20%20%20%20%20%22from%22%3A%20%222023-06-08T06%3A41%3A38.166Z%22%0A%20%20%20%20%7D%0A%20%20%7D%2C%0A%20%20%22limit%22%3A%2010%2C%0A%20%20%22page%22%3A%200%0A%7D

Example 2: Search for entities created before a timestamp

Search:

  • Use the search API: Device Search
  • Match the attribute _creationTime with the value of or before 2023-06-08T06:41:38.166Z
  • Limit the number of results to 10 per page
  • Return the first page

Filter object will look like this:

{
  "filter": {   
    "_creationTime": {
      "to": "2023-06-08T06:41:38.166Z"
    }
  },
  "limit": 10,
  "page": 0
}

Encoded API call:

https://api.dev.example.biot-med.com/device/v2/devices?searchRequest=%7B%0A%20%20%22filter%22%3A%20%7B%20%20%20%0A%20%20%20%20%22_creationTime%22%3A%20%7B%0A%20%20%20%20%20%20%22to%22%3A%20%222023-06-08T06%3A41%3A38.166Z%22%0A%20%20%20%20%7D%0A%20%20%7D%2C%0A%20%20%22limit%22%3A%2010%2C%0A%20%20%22page%22%3A%200%0A%7D

Example 3: Search for entities created after a timestamp but before another timestamp

Search:

  • Use the search API: Device Search
  • Match the attribute _creationTime with the value between2023-06-07T06:41:38.166Zand 2023-06-08T06:41:38.166Z inclusive
  • Limit the number of results to 10 per page
  • Return the first page

Filter object will look like this:

{
  "filter": {   
    "_creationTime": {
      "from": "2023-06-07T06:41:38.166Z",
      "to": "2023-06-08T06:41:38.166Z"
    }
  },
  "limit": 10,
  "page": 0
}

Encoded API call:

https://api.dev.example.biot-med.com/device/v2/devices?searchRequest=%7B%0A%20%20%22filter%22%3A%20%7B%20%20%20%0A%20%20%20%20%22_creationTime%22%3A%20%7B%0A%20%20%20%20%20%20%22from%22%3A%20%222023-06-07T06%3A41%3A38.166Z%22%2C%0A%20%20%20%20%20%20%22to%22%3A%20%222023-06-08T06%3A41%3A38.166Z%22%0A%20%20%20%20%7D%0A%20%20%7D%2C%0A%20%20%22limit%22%3A%2010%2C%0A%20%20%22page%22%3A%200%0A%7D