Orion Context Broker 使用带数字的匹配模式

Orion Context Broker Using Match Pattern with number

比如我身边就有这样一个人。 我想查询 person 的 phoneNumber 包含“354”。 我将使用这样的查询:GET /v2/entities?q=phoneNumber~=354。 那么是否可以在 orion context broker 中进行这样的查询? 正如我所见,匹配模式仅支持目标 属性 作为字符串。

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/ 部分:简单查询语言

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

非常感谢。

按照你说的运行

例如,在 localhost:1026 中使用带有空数据库的 Orion 2.2.0,创建一个类似于您建议的实体(但使用 NGSIv2 端点,因为 NGSIv1 已被弃用 API):

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

然后,您可以使用“354”模式进行查询,您将获得实体:

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

相反,如果您查询不匹配的模式(例如“999”),您将不会获得任何实体:

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