in & notIn: Search Examples

The search operations in & notIn will search for entities where the search attribute value is in or not in an array of values.

Example 1: Search for entities with value in an array of values

Search:

  • Use the search API: Device Search
  • Match the attribute _id with the values of R21468772 and R21407203
  • Limit the number of results to 10 per page
  • Return the first page

Filter object will look like this:

{
  "filter": {
    "_id": {
      "in": ["R21468772", "R21407203"]
    }
  },
  "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%0A%20%20%20%20%22_id%22%3A%20%7B%0A%20%20%20%20%20%20%22in%22%3A%20%5B%22R21468772%22%2C%20%22R21407203%22%5D%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 with value not in an array of values

Search:

  • Use the search API: Device Search
  • Match the attribute _id with the values that are not R21468772 or R21407203
  • Limit the number of results to 10 per page
  • Return the first page

Filter object will look like this:

{
  "filter": {
    "_id": {
      "notIn": ["R21468772", "R21407203"]
    }
  },
  "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%0A%20%20%20%20%22_id%22%3A%20%7B%0A%20%20%20%20%20%20%22notIn%22%3A%20%5B%22R21468772%22%2C%20%22R21407203%22%5D%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