You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the documentation, searching for devices can be done using a predicate specified by the filterJson request parameter. The example in the documentation for example is {"field": "/ext/brand","value": "eclipse*"} indicating that searching in nested fields should be supported.
However, it seems that it is not as demonstrated by the following example run against the Hono sandbox setup.
First we'll get a list of the devices that are registered on the DEFAULT_TENANT:
If we perform a GET request using {"field": "/ext/ep","value": "IMEI4711"} as the jsonFilter value, we see that no device is returned:
➜ curl -X GET https://hono.eclipseprojects.io:28443/v1/devices/DEFAULT_TENANT\?filterJson\=%7B%22field%22%3A%20%22%2Fext%2Fep%22%2C%22value%22%3A%20%22IMEI4711%22%7D
{"error":"no devices matching searching criteria"}
When trying to search by the /id field using the jsonFilter value of {"field": "/id","value": "1234"}, that does not work either:
➜ curl -X GET https://hono.eclipseprojects.io:28443/v1/devices/DEFAULT_TENANT\?filterJson\=%7B%22field%22%3A%20%22%2Fid%22%2C%22value%22%3A%20%221234%22%7D
{"error":"no devices matching searching criteria"}
However, if we search for devices that have the enabled field set to a true value, that seems to work as we only get the subset of devices that actually have that set:
➜ curl -X GET https://hono.eclipseprojects.io:28443/v1/devices/DEFAULT_TENANT\?filterJson\=%7B%22field%22%3A%20%22%2Fenabled%22%2C%22value%22%3A%20true%7D | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 329 100 329 0 0 795 0 --:--:-- --:--:-- --:--:-- 794
{
"total": 3,
"result": [
{
"enabled": true,
"defaults": {
"content-type": "application/vnd.bumlux",
"importance": "high"
},
"status": {
"created": "2024-06-06T16:30:30Z"
},
"id": "4711"
},
{
"enabled": true,
"via": [
"gw-1"
],
"status": {
"created": "2024-06-06T16:30:31Z"
},
"id": "4712"
},
{
"enabled": true,
"status": {
"created": "2024-06-06T16:30:31Z"
},
"id": "gw-1"
}
]
}
Note that we're only getting 3 devices with this query while we got 5 devices with our original query (using no jsonFilter).
So my gut feeling is that this must be a bug.
The text was updated successfully, but these errors were encountered:
Can you reproduce this with a local installation using the JDBC registry with PostgreSQL? The integration tests of Hono include a test case that verifies searching by (nested) string-typed fields, but the embedded H2 based JDBC registry that is used on the Sandbox seems to have problems with this and sorting ...
I have reproduced this issue running on a fresh installation to my docker-desktop embedded k8s cluster. That setup has a PSQL DB underneath the JDBC based device registry. I'm seeing this behavior there as well.
According to the documentation, searching for devices can be done using a predicate specified by the
filterJson
request parameter. The example in the documentation for example is{"field": "/ext/brand","value": "eclipse*"}
indicating that searching in nested fields should be supported.However, it seems that it is not as demonstrated by the following example run against the Hono sandbox setup.
First we'll get a list of the devices that are registered on the
DEFAULT_TENANT
:Here we see that there is a device registered that we can try searching for by filtering on the value of
/ext/ep
:If we perform a GET request using
{"field": "/ext/ep","value": "IMEI4711"}
as thejsonFilter
value, we see that no device is returned:When trying to search by the
/id
field using thejsonFilter
value of{"field": "/id","value": "1234"}
, that does not work either:However, if we search for devices that have the
enabled
field set to atrue
value, that seems to work as we only get the subset of devices that actually have that set:Note that we're only getting 3 devices with this query while we got 5 devices with our original query (using no
jsonFilter
).So my gut feeling is that this must be a bug.
The text was updated successfully, but these errors were encountered: