Mapping an Object field in virtual graph

Hi I have a requirement where I have to fetch key/value of a field from my mongodb.. I know how to map String/Int and array fields but not sure how to do for object fields, below is the sample example

My record in mongodb

{ 
    "_id" : ObjectId("5db3460d7fb5c16ab"), 
    "imgId" : "abc.png", 
    "seq" : "20180208_122230", 
    "pop" : [
        "0000", 
        "0001
    ], 
    "value" : [
	"1111",
	"1234"
    ], 
    "pixels" : {
        "00" : NumberInt(128), 
        "02" : NumberInt(354), 
        "03" : NumberInt(1951), 
        "05" : NumberInt(2610), 
        "09" : NumberInt(3619), 
        "11" : NumberInt(1048), 
        "18" : NumberInt(3644)
    }
} 

I am trying to map it, my mapping file looks like :

Mapping
FROM JSON {
  "sample":{
    "_id": "?_id",
    "imgId": "?imgId",
    "seq": "?seq", 
    "pop": ["?pop"],
    "value": ["?value"],
    "pixels" : ?????
}
}

TO {
    ?image a :Images;
            :_id  ?_id;
            :seq ?seq;
            :pop ?pop;
            :value ?value;
	    :pixels : ???
}

WHERE {
  BIND (template("http://sample.com/images/{imgId}") AS ?image)

}

I am not sure how to map pixels field!!!
Please help..

Hi Fasal,

Am I correct in assuming that the keys within the pixels object ("00", "02", "03", ...) are variable? Meaning there is no limit to the potential values? If so, this is not something we currently support.

I'd like to more about the meaning of this data and how you would like to see it mapped.

I'm thinking you would use a variable predicate?

image:abc.png a :Image ;
   pixel:00 12815 ;
   pixel:02 354695 ;
   ....

...but we generally frown upon variable predicates in mappings unless they map to a finite set of meaningful predicates.

Would this be better?

image:abc.png a :Image ;
   :hasPixel pixel:00 ;
   :hasPixel pixel:02 .
pixel:00 :pixelValue 12815 .
pixel:02 :pixelValue 354695 .

We can look into supporting this. Let me know your thoughts.

-Paul

@PaulJackson
Thanks for the response.. Yes the keys "00","02" are variables..
Currently in our mongodb these keys are used to sort the results something like { "$sort" : { "pixels.09" : -1, "_id" : 1 } }, .....

As you said there will be no limit to the potential values.. But let's say I make it finite for now in that case how will we map it??

Suggestions you gave looks fine to me provided we can later use the variables in ORDER BY something like (ORDER BY DESC(?pixels.00)) ..