Get Devices API Tag Filter


#1

Hi,

I would like to do a query on all my devices to find one that contains a text substring in its Site tag. Currently I can only see how to do an exact match on Tags. I used the following Tag Filter as a test.

I have a Site tag on all devices, one device in particular has the Site value “Middle Earth (AB1023)”. If I use the Site Tag filter below, the device is found:

[
{
“key” : “Site”,
“value” : “Middle Earth (AB1023)”
}
]

However, for this application I need to be able to search just by “Middle Earth”, ie find a device whose Site tag CONTAINS “Middle Earth”. I tried the following Tag Filter but it did not work:

[
{
“key” : “Site”,
“value” : “Middle Earth”
}
]

Any suggestions?


#2

It’s not possible at this time; tag queries only match on specific keys, values, or key/value combinations. But we’ll explore more robust device querying in the manner you’re looking for.

I can think of two workarounds in the meantime …

  1. Separate out your tags more explicitly in your devices’ configurations. You could add a new tag for “SiteCategory” and add “Middle Earth” as the value.
  2. If you’re using the REST API to query these devices, you could put some of this information in the device name, as that query supports globbing. i.e. you find all devices that match the name “Middle Earth*”. Note, however, that the Device: Get Node does not support globbing when querying by device name.

#3

Hi Dylan,

Thanks for you tips. I am probably in too deep now to go rearranging all the tags on the devices…

Regards

Ashley