将 FIWARE Orion 与 Azure Cosmos DB 连接
Connecting FIWARE Orion with Azure Cosmos DB
我尝试使用 FIWARE Orion [1],对于数据库,我使用 Azure Cosmos DB Mongo API。我按照问题 [2] 中概述的步骤进行操作。 docker-compose.yml文件内容为:
version: "3"
services:
orion:
image: fiware/orion
ports:
- "1026:1026"
command: -dbhost "mongo-perf-testing.mongo.cosmos.azure.com:10255" -db "fiver_db" -dbuser "mongo-perf-testing" -dbpwd "password" -dbSSL -dbDisableRetryWrites -logLevel DEBUG -t 100
当我 运行 docker 容器时,它启动正常。
然后我运行以下查询:
查询:curl localhost:1026/version
回应:
{
"orion" : {
"version" : "3.6.0",
"uptime" : "0 d, 0 h, 9 m, 31 s",
"git_hash" : "973850279e63d58cb93dff751648af5ec6e05777",
"compile_time" : "Wed Mar 2 10:34:48 UTC 2022",
"compiled_by" : "root",
"compiled_in" : "5e6b6f1167f7",
"release_date" : "Wed Mar 2 10:34:48 UTC 2022",
"machine" : "x86_64",
"doc" : "https://fiware-orion.rtfd.io/en/3.6.0/",
"libversions": {
"boost": "1_66",
"libcurl": "libcurl/7.61.1 OpenSSL/1.1.1k zlib/1.2.11 nghttp2/1.33.0",
"libmosquitto": "2.0.12",
"libmicrohttpd": "0.9.70",
"openssl": "1.1",
"rapidjson": "1.1.0",
"mongoc": "1.17.4",
"bson": "1.17.4"
}
}
}
然后我插入一个条目使用:
查询:
'http://localhost:1026/v2/entities' \
-H 'Content-Type: application/json' \
-d '
{
"id": "urn:ngsi-ld:Store:001",
"type": "Store",
"address": {
"type": "PostalAddress",
"value": {
"streetAddress": "Bornholmer Straße 65",
"addressRegion": "Berlin",
"addressLocality": "Prenzlauer Berg",
"postalCode": "10439"
},
"metadata": {
"verified": {
"value": true,
"type": "Boolean"
}
}
},
"location": {
"type": "geo:json",
"value": {
"type": "Point",
"coordinates": [13.3986, 52.5547]
}
},
"name": {
"type": "Text",
"value": "Bösebrücke Einkauf"
}
}'
回复:
HTTP/1.1 201 Created Connection: Keep-Alive Content-Length: 0 Location: /v2/entities/urn:ngsi-ld:Store:003?type=Store Fiware-Correlator: f32e6e46-c520-11ec-b804-0242ac130002
接下来,我进行查询:
查询:
'http://localhost:1026/v2/entities' \
-d 'type=Store' \
-d 'options=keyValues'
我得到回复:
{"error":"Internal Server Error","description":"Error at querying MongoDB: Error=2, Details='Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: fde36487-2dd9-44a4-a719-99453acdd618; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: fde36487-2dd9-44a4-a719-99453acdd618; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: fde36487-2dd9-44a4-a719-99453acdd618; Reason: (Message: {"Errors":["The index path corresponding to the specified o"}
当我转到 Azure cosmosdb 仪表板时,我可以看到该条目。所以我不确定这里出了什么问题。
能否请您建议如何解决此问题?
解决方案已发布 。在这种特殊情况下,根据问题评论中的@anupam 反馈,解决方案是这一步:
You need to create an index at creDate
(e.g. db.entities.createIndex({creDate:1})
) and maybe more, if you use orderBy
param in your NGSIv2 queries. More detail here
我尝试使用 FIWARE Orion [1],对于数据库,我使用 Azure Cosmos DB Mongo API。我按照问题 [2] 中概述的步骤进行操作。 docker-compose.yml文件内容为:
version: "3"
services:
orion:
image: fiware/orion
ports:
- "1026:1026"
command: -dbhost "mongo-perf-testing.mongo.cosmos.azure.com:10255" -db "fiver_db" -dbuser "mongo-perf-testing" -dbpwd "password" -dbSSL -dbDisableRetryWrites -logLevel DEBUG -t 100
当我 运行 docker 容器时,它启动正常。
然后我运行以下查询:
查询:curl localhost:1026/version
回应:
{
"orion" : {
"version" : "3.6.0",
"uptime" : "0 d, 0 h, 9 m, 31 s",
"git_hash" : "973850279e63d58cb93dff751648af5ec6e05777",
"compile_time" : "Wed Mar 2 10:34:48 UTC 2022",
"compiled_by" : "root",
"compiled_in" : "5e6b6f1167f7",
"release_date" : "Wed Mar 2 10:34:48 UTC 2022",
"machine" : "x86_64",
"doc" : "https://fiware-orion.rtfd.io/en/3.6.0/",
"libversions": {
"boost": "1_66",
"libcurl": "libcurl/7.61.1 OpenSSL/1.1.1k zlib/1.2.11 nghttp2/1.33.0",
"libmosquitto": "2.0.12",
"libmicrohttpd": "0.9.70",
"openssl": "1.1",
"rapidjson": "1.1.0",
"mongoc": "1.17.4",
"bson": "1.17.4"
}
}
}
然后我插入一个条目使用:
查询:
'http://localhost:1026/v2/entities' \
-H 'Content-Type: application/json' \
-d '
{
"id": "urn:ngsi-ld:Store:001",
"type": "Store",
"address": {
"type": "PostalAddress",
"value": {
"streetAddress": "Bornholmer Straße 65",
"addressRegion": "Berlin",
"addressLocality": "Prenzlauer Berg",
"postalCode": "10439"
},
"metadata": {
"verified": {
"value": true,
"type": "Boolean"
}
}
},
"location": {
"type": "geo:json",
"value": {
"type": "Point",
"coordinates": [13.3986, 52.5547]
}
},
"name": {
"type": "Text",
"value": "Bösebrücke Einkauf"
}
}'
回复:
HTTP/1.1 201 Created Connection: Keep-Alive Content-Length: 0 Location: /v2/entities/urn:ngsi-ld:Store:003?type=Store Fiware-Correlator: f32e6e46-c520-11ec-b804-0242ac130002
接下来,我进行查询: 查询:
'http://localhost:1026/v2/entities' \
-d 'type=Store' \
-d 'options=keyValues'
我得到回复:
{"error":"Internal Server Error","description":"Error at querying MongoDB: Error=2, Details='Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: fde36487-2dd9-44a4-a719-99453acdd618; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: fde36487-2dd9-44a4-a719-99453acdd618; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: fde36487-2dd9-44a4-a719-99453acdd618; Reason: (Message: {"Errors":["The index path corresponding to the specified o"}
当我转到 Azure cosmosdb 仪表板时,我可以看到该条目。所以我不确定这里出了什么问题。
能否请您建议如何解决此问题?
解决方案已发布
You need to create an index at
creDate
(e.g.db.entities.createIndex({creDate:1})
) and maybe more, if you useorderBy
param in your NGSIv2 queries. More detail here