Customer Portal

Mongo reader Malfunction reading objectId of a record

Comments 3

  • Avatar
    admin
    0
    Comment actions Permalink
    Hi sidharth,

    Can you please check that your database really contains only ObjectId as _id? Because Mongo accepts as _id any data type. So it is well possible you have string "ObjectId(\"53b0e85472a0ec06118b45ff\")" used as _id. Or even object {"$oid":"53b0e85472a0ec06118b45ff"}. In that case you would need to dive into that object - so not only by "_id" but also "$oid".

    You can check what _id values you have by Mongo viewer like RoboMongo. In case you won't be able to detect problem please send us screenshot of two expanded records - one which return correct _id and one which does not.

    I hope this helps.
  • Avatar
    sidharth
    0
    Comment actions Permalink
    The object id is present as "_id" : ObjectId("53b0e85472a0ec06118b45ff").
    I need to get value 53b0e85472a0ec06118b45ff in metadata product_id ,is it possible in output mapping of mongo reader to do the necessary adjustments.How do you suggest We dive into that object and take the value?
  • Avatar
    admin
    0
    Comment actions Permalink
    Hi sidharth,

    Diving into _id/$oid is not possible in MongoReader, there is available only one root key-value map. For that you need to pass whole JSON object text into JSONReader/Extract and extract value there. Sample mapping for JSONExtract may look like:


    <Mappings>
    <Mapping element="json_object">
    <Mapping element="_id">
    <Mapping element="_x0024oid" outPort="0"
    xmlFields="../{}_x0024oid"
    cloverFields="_id">
    </Mapping>
    </Mapping>
    </Mapping>
    </Mappings>


    (x0024 is escape for $)

    I hope this helps.

Please sign in to leave a comment.