在Orion Context Broker 0.23.0中按属性值过滤 [英] Filter by attribute value in Orion Context Broker 0.23.0

查看:74
本文介绍了在Orion Context Broker 0.23.0中按属性值过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Orion Context Broker的当前版本0.23.0中,新添加的功能之一是它支持根据属性值(NGSI v2)过滤实体.我目前正在执行 http://telefonicaid.github.io/fiware-orion/api/中指示的GET操作v2/,我得到的是整个实体集,没有任何过滤操作.在这方面,能否请您提供一个有关如何使用新的REST API NGSI v2的清晰示例来帮助我?

In current version of Orion Context Broker, 0.23.0, one of the new added features is that it supports filtering entities according to attribute values (NGSI v2). I am currently executing GET operations as indicated in http://telefonicaid.github.io/fiware-orion/api/v2/ and what I obtain is the whole set of entities, no filtering action. Could you please help me in this regard with a clear example on how to use the new REST API, NGSI v2?

非常感谢您

推荐答案

NGSIv2过滤功能基于以下操作:

The NGSIv2 filtering capabilities are based in the following operation:

GET /v2/entities?q=<query_string>

其中query_string指定 NGSIv2规范文档中定义的查询字符串.例如,要获取所有temperature小于24,humidity在75到90之间且status在运行"中的实体,请使用以下操作:

where query_string specifies the query string as defined in the NGSIv2 specification document. For example, to get all the entities which temperature is less than 24, which humidity is in the range between 75 and 90 and which status is "running" use the following operation:

GET /v2/entities?q=temperature<24;humidity==75..90;status=running

您还可以使用POST /v1/queryContext有效负载中的scope字段,使用传统" NGSIv1进行查询.相同的查询将通过以下方式进行:

You can also do queries using "traditional" NGSIv1, using the scope field in the POST /v1/queryContext payload. The same query will be done in the following way:

 POST /v1/queryContext

 {
  "entities": [
      {
      "type": "",
      "isPattern": "true",
      "id": ".*"
      }
  ],
  "restriction": {
      "scopes": [
        {
          "type": "FIWARE::StringQuery",
          "value": "q=temperature<24;humidity==75..90;status=running"
        }
      ]
    }
 }

以下链接提供了其他信息.

请注意,某些过滤器(例如大于/小于范围等)假定属性值本机类型是数字.考虑到创建/更新属性的NGISv1操作总是将值转换为字符串(由于XML的兼容性,不再由NGSIv2维护).因此,如果您需要将属性值存储为数字以应用大于/小于范围等过滤器,则可以使用NGSIv2操作来创建/更新这些属性. 以下文档中对此警告进行了详细说明 a>.

Note that some filters (e.g. greater/less than, ranges, etc.) assume that the attribute value native type is a number. Take into account that NGISv1 operations to create/update attributes always transform the values to strings (due to XML compability, no longer mantained in NGSIv2). Thus, if you need to store attribute values as number to apply greater/less than, ranges, etc. filters, then use NGSIv2 operations to create/update these attributes. The caveat is explained in more detail in the following piece of documentation.

这篇关于在Orion Context Broker 0.23.0中按属性值过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆