Query the Digital Twin Registry

To select only the digital twins relevant for your uses case, you can define filters.

The Digital Twin Registry supports RQL filters, see https://github.com/persvr/rql.

Filtering reduces the amount of result by given filter criteria and returns a subset of the twins.

The general form of the query string looks like follows:

filter={filter expression}&option=limit({start},{count})

As your registry contains only 6 digital twins so far, we can omit for now the limiting options in the examples.
However, keep it in mind as it might come in handy when you implement a UI for hundreds or thousands of twins.

Example RQL queries

Find twins by label A

filter=eq(labels.name,"A")

Find twins of twinCategory "Machine" or "Device"

in(twinCategory,"Machine","Device")

More information on how to use RQL filter when querying in Digital Twin Registry can be found in chapter Find digital twins. There you can also find the complete list if supported properties

Hands on

In case you have skipped trying out the Postman collection B3, at latest now you should try it out.

  • Reuse the prepared environment file

  • Import and run the requests prepared in B3-get-twins.json.

You can, for example, duplicate the example "Get by Movement Aspect" and create a request which queries for all digital twins with a Temperature aspect.

As you will see, only the filter will need to be changed, namely to

`like(aspects.modelReference.urn,"urn:samm:com.bosch.nexeed.digitaltwin:1.0.0#Temperature")

(The full urn can be copied from the result of "Get all existing Twins").

Expected response: 2 twins, namely Machine 1 and Machine 2.

D1 filter on url
In case you run into an error, consider that the filter will be part of the request URL and will therefore need to be URL-encoded. In fact, you will need to set the filter parameter as follows:
like(aspects.modelReference.urn,"urn:samm:com.bosch.nexeed.digitaltwin:1.0.0%23Temperature")