'Connecting FIWARE Orion with Azure Cosmos DB

I tried using FIWARE Orion [1] and for the database I used Azure Cosmos DB Mongo API. I followed the steps as outlined in the issue [2]. The contents of the file docker-compose.yml are:

 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

When I run the docker container, it starts off okay.

Then I run following queries:

Query: curl localhost:1026/version Response:

{
"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"
  }
}
}

Then I insert an entry using:

Query:

'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"
    }
}'

Response:

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

Next, I do the query: Query:

'http://localhost:1026/v2/entities' \
-d 'type=Store' \
-d 'options=keyValues'

And I get the response:

{"error":"Internal Server Error","description":"Error at querying MongoDB: Error=2, Details='Response status code does not indicate success: BadRequest (400)&#59; Substatus: 0&#59; ActivityId: fde36487-2dd9-44a4-a719-99453acdd618&#59; Reason: (Response status code does not indicate success: BadRequest (400)&#59; Substatus: 0&#59; ActivityId: fde36487-2dd9-44a4-a719-99453acdd618&#59; Reason: (Response status code does not indicate success: BadRequest (400)&#59; Substatus: 0&#59; ActivityId: fde36487-2dd9-44a4-a719-99453acdd618&#59; Reason: (Message: {"Errors":["The index path corresponding to the specified o"}

When I goto Azure cosmosdb dashboard I can see the entry present. So I am not sure what is going wrong here.

Can you please suggest how to fix this issue?

  1. https://github.com/telefonicaid/fiware-orion
  2. https://github.com/telefonicaid/fiware-orion/issues/3797


Solution 1:[1]

The solution was already posted in this answer. In this particular case, according with @anupam feedback in the question comments, the solution was this step:

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 fgalan