1
votes

For example I have a person like below. I wan to query person has phoneNumber contains "354". I will use the query like this: GET /v2/entities?q=phoneNumber~=354. So is it possible to do the query like this in orion context broker? As I have seen that the match pattern only support target property as string.

Match pattern: ~=. The value matches a given pattern, expressed as a regular expression, e.g. color~=ow. For an entity to match, it must contain the target property (color) and the target property value must match the string in the right-hand side, 'ow' in this example (brown and yellow would match, black and white would not). This operation is only valid for target properties of type string.

http://telefonicaid.github.io/fiware-orion/api/v2/stable/ Section: Simple Query Language

 {
        "type": "Person",
        "isPattern": "false",
        "id": "1",
        "attributes": [
            {
                "name": "phoneNumber",
                "type": "string",
                "value": "0102354678"
            }
        ]
    }

Many thanks.

1

1 Answers

1
votes

It works as you said.

For instance, using Orion 2.2.0 with an empty database in localhost:1026, creating an entity like the one you propose (but using NGSIv2 endpoint, as NGSIv1 is a deprecated API):

$ curl localhost:1026/v2/entities -H 'content-type: application/json' -d @- <<EOF
{
        "type": "Person",
        "id": "1",
        "phoneNumber": {
                "type": "string",
                "value": "0102354678"
            }
}
EOF

Then, you can do a query with "354" pattern and you will get the entity:

$ curl -s -S 'localhost:1026/v2/entities?q=phoneNumber~=354' | python -mjson.tool
[
    {
        "id": "1",
        "phoneNumber": {
            "metadata": {},
            "type": "string",
            "value": "0102354678"
        },
        "type": "Person"
    }
]

On the contrary, if you do a query for a non-matching pattern (such as "999") you will not get any entity:

$ curl -s -S 'localhost:1026/v2/entities?q=phoneNumber~=999' | python -mjson.tool
[]