I am investigating Cygnus for FIWARE Orion historical data persistence.
Since Cygnus 3.0.0, indexes are created according to the data model when writing to MongoDB, but the order of the indexes created and the data written to MongoDB are different.
I tried it and found that the following indexes were created.
> db['sth_/_Car1_Car'].getIndexes()
[
{
"v" : 2,
"key" : {
"_id" : 1
},
"name" : "_id_"
},
{
"v" : 2,
"key" : {
"recvTime" : 1,
"attrName" : 1,
"attrType" : 1,
"attrValue" : 1
},
"name" : "cyg_raw_opt"
}
]
However, the data written from Cygnus to MongoDB is in the following order, so it seems that the index is not valid.
> db['sth_/_Car1_Car'].find()
{ "_id" : ObjectId("6475a09a91bf560e1ef4cb0d"), "attrName" : "speed", "attrType" : "Float", "attrValue" : 80, "recvTime" : ISODate("2023-05-30T07:07:05.588Z") }
{ "_id" : ObjectId("6475a09f91bf560e1ef4cb0e"), "attrName" : "speed", "attrType" : "Float", "attrValue" : 70, "recvTime" : ISODate("2023-05-30T07:07:11.584Z") }
I checked some past Issues and found that the data was lined up in the same order as the index.(ex. https://github.com/telefonicaid/fiware-cygnus/issues/2204)
What settings are needed to make this order?
My environment is as follows:
- Cygnus 3.1.0
- MongoDB 4.4
Thank you in advance.