2

我刚开始使用 FIWARE,但我想在 MongoDB 上保留的数据遇到问题。我想在最小模式下使用 STH Comet。我正在使用 Python 脚本创建具有特定 ID 的上下文数据,然后更新该数据的某些属性。虽然当我观察来自该脚本的 JSON 数据和 HTTP 请求时我看不到任何问题,但 MongoDB 仅在相关集合中保留此数据的最后更新版本。此外,没有显示“sth”标签的集合。但是我可以在属性中看到“credate”和“moddate”元数据。但是每次更新我都需要不同的记录。

这是我发送给 Orion 以创建上下文数据的第一个 POST 请求:

{"id": "urn:ngsi-ld:entity:001", 
"type": "Log",
"a": {"type": "Datetime", "value": "17/09/2021"}, 
"b": {"type": "Datetime", "value": "12:00:18.0"}, 
"c": {"type": "Integer", "value": 49.51}, 
"d": {"type": "Integer", "value": 175.35}, 
"e": {"type": "Integer", "value": 24.25}, 
"f": {"type": "Integer", "value": 999.1}, 
"g": {"type": "Integer", "value": 85.87}, 
"h": {"type": "Integer", "value": -0.01}, 
"i": {"type": "Integer", "value": 37.41}, 
"j": {"type": "Integer", "value": 60.65}}

这是我在 MongoDB 集合中得到的内容,attrNames 已针对该问题设置为虚拟对象:

{
  "_id": {
    "id": "urn:ngsi-ld:entity:001",
    "type": "Log",
    "servicePath": "/"
  },
  "attrNames": [
    "a",
    "b",
    "c",
    "d",
    "e",
    "f",
    "g",
    "h",
    "i",
    "j"
  ],
  "attrs": {
    "a": {
      "type": "Datetime",
      "creDate": 1645514416,
      "modDate": 1645514416,
      "value": "17/09/2021",
      "mdNames": []
    },
    "b": {
      "value": "12:00:21.0",
      "type": "Datetime",
      "mdNames": [],
      "creDate": 1645514416,
      "modDate": 1645514597
    },
    "c": {
      "value": 666.47,
      "type": "Integer",
      "mdNames": [],
      "creDate": 1645514416,
      "modDate": 1645514640
    },
    "d": {
      "value": 175.55,
      "type": "Integer",
      "mdNames": [],
      "creDate": 1645514416,
      "modDate": 1645514597
    },
    "e": {
      "value": 24.27,
      "type": "Integer",
      "mdNames": [],
      "creDate": 1645514416,
      "modDate": 1645514597
    },
    "f": {
      "value": 999.28,
      "type": "Integer",
      "mdNames": [],
      "creDate": 1645514416,
      "modDate": 1645514597
    },
    "g": {
      "type": "Integer",
      "creDate": 1645514416,
      "modDate": 1645514416,
      "value": 85.87,
      "mdNames": []
    },
    "h": {
      "type": "Integer",
      "creDate": 1645514416,
      "modDate": 1645514416,
      "value": -0.01,
      "mdNames": []
    },
    "i": {
      "type": "Integer",
      "creDate": 1645514416,
      "modDate": 1645514416,
      "value": 37.41,
      "mdNames": []
    },
    "j": {
      "value": 1111.47,
      "type": "Integer",
      "mdNames": [],
      "creDate": 1645514416,
      "modDate": 1645514640
    }
  },
  "creDate": 1645514416,
  "modDate": 1645514640,
  "lastCorrelator": "679e1cba-93b0-11ec-be0f-0242ac120102" 

这是我可以使用 STH Comet Query 获得的数据输出:

{
    "contextResponses": [
        {
            "contextElement": {
                "attributes": [
                    {
                        "name": "c",
                        "values": [
                            {
                                "_id": "621ca977165813000740898e",
                                "recvTime": "2022-02-28T10:52:39.012Z",
                                "attrName": "c",
                                "attrType": "Integer",
                                "attrValue": 49.47
                            },
                            {
                                "_id": "621ca97d165813000740899e",
                                "recvTime": "2022-02-28T10:52:45.581Z",
                                "attrName": "c",
                                "attrType": "Integer",
                                "attrValue": 49.61
                            },
                            {
                                "_id": "621ca98316581300074089a7",
                                "recvTime": "2022-02-28T10:52:51.239Z",
                                "attrName": "c",
                                "attrType": "Integer",
                                "attrValue": 49.46
                            },
                            {
                                "_id": "621ca98916581300074089ac",
                                "recvTime": "2022-02-28T10:52:57.662Z",
                                "attrName": "c",
                                "attrType": "Integer",
                                "attrValue": 49.57
                            },
                            {
                                "_id": "621ca98d16581300074089b9",
                                "recvTime": "2022-02-28T10:53:01.852Z",
                                "attrName": "c",
                                "attrType": "Integer",
                                "attrValue": 49.47
                            },
                            {
                                "_id": "621ca99316581300074089c7",
                                "recvTime": "2022-02-28T10:53:07.242Z",
                                "attrName": "c",
                                "attrType": "Integer",
                                "attrValue": 49.41
                            },
                            {
                                "_id": "621ca9a116581300074089d2",
                                "recvTime": "2022-02-28T10:53:21.305Z",
                                "attrName": "c",
                                "attrType": "Integer",
                                "attrValue": 49.51
                            }
                        ]
                    }
                ],
                "id": "urn:ngsi-ld:entity:001",
                "isPattern": false,
                "type": "Log"
            },
            "statusCode": {
                "code": "200",
                "reasonPhrase": "OK"
            }
        }
    ]
}

如您所见,我可以_id在返回的查询中获取 MongoDB,但问题是,我在相关的 MongoDB 数据库中找不到这些单独数据的位置。

我浏览了所有文档,但要么找不到解决方案,要么我在架构逻辑中遗漏了一些东西。我应该如何处理这个问题?

谢谢!

4

1 回答 1

1

简单来说,我意识到我遇到的问题是由于我在远程服务器上设置的 STH Comet的config.js文件中的参数没有更改。

因此,我更改了部分host参数(从"localhost""server's own IP")和文件部分中的参数(从到)。config.serverURI"localhost:27017""serversIP:27017"config.database

该系统现在按预期工作。

于 2022-03-04T11:01:42.767 回答