sth-comet提供了计算max,min和其他函数的可能性,如[此处] https://github.com/telefonicaid/fiware-sth-comet/blob/master/doc/manuals/aggregated-data-retrieval.md
所述但是我尝试了不同的类型,但是没有给出合计的结果。
我实体的简化版本(在此示例中,我使用属性温度):
{
"id": "Beach:27",
"type": "Beach",
"flag": {
"type": "Property",
"value": "Verde"
},
"temperature": {
"type": "Number",
"value": 45
}
我进行了此查询,该查询应提供最大值:
http://{{sth-comet}}/STH/v1/contextEntities/type/Beach/id/Beach:27/attributes/temperature?aggrMethod=max&hLimit=100&hOffset=0
但结果不是最大值,而是属性的所有更改:
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "temperature",
"values": [
{
"recvTime": "2019-09-15T18:32:18.166Z",
"attrType": "Number",
"attrValue": "43"
},
{
"recvTime": "2019-09-15T18:32:24.645Z",
"attrType": "Number",
"attrValue": "44"
},
{
"recvTime": "2019-09-15T18:32:28.931Z",
"attrType": "Number",
"attrValue": "45"
}
]
}
],
"id": "Beach:27",
"isPattern": false,
"type": "Beach"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}
该属性必须具有哪种类型才能正常工作?我尝试使用“ Number”,“ integer”,“ string”,“ Property”,但没有获得“ max”值。
谢谢您的时间
答案 0 :(得分:1)
对聚合时间序列上下文信息的请求可以使用以下查询参数:
在您的请求中,您没有输入必填参数(aggrPeriod)。你能测试一下吗?
(http:// {{sth-comet}} /STH/v1/contextEntities/type/Beach/id/Beach:27/attributes/temperature?aggrMethod=max&aggrPeriod=second&dateFrom=2019-09-15T00:00:00.000Z&dateTo= 2019-09-15T23:59:59.999Z)