Search code examples
mongodbfiwarefiware-cygnus

Fiware Cygnus: Can we store Orion data in MongoDB under other types than String?


I am subscribing to Orion Context Broker data using Cygnus. Cygnus stores the data on MongoDB like the following. Is there a possibility to store the attrValue as float not as String to be able to use Mongo's aggregation features?

> db['cygnus_/kurapath_enocean_power_enocean'].find().pretty()
{
    "_id" : ObjectId("55e81e9631d7791085668331"),
    "recvTime" : ISODate("2015-09-03T10:19:02Z"),
    "attrName" : "power",
    "attrType" : "string",
    "attrValue" : "2085.0"
}

Solution

  • Not currently, mainly because Cygnus does not (always) receives information about the real type of an entity's attribute. The entity's "type" Orion sents is just a description of the type, I mean, it could be anything like "float" or "number_of_potatos". It is true that some reserved words, such as "float", have been chosen in recent versions of Orion in order to describe effective float numbers, and in that case the type could be used to persist effective float numbers in Mongo (or whatever backend you use), but many other attributes will continue having an unknown type. Thus, currently everything is considered as a string.

    In addition, it must be said another feature is under study: the possibility to notify some special entities, the "entity models" fully describing a class of entities.

    Most probably next coming releases will be implementing an effective typing in some of the above directions.

    Anyway, did you see the OrionSTHSink? Despite its name (STH, Short-Term Historic), it is a sink that already creates aggregations of data in a MongoDB.