0

I have many songs contained in a collection, each containing _id and description, in the description is an array of elements including line and sub_fingerprint, I pass on _id and line. How to retrieve subfingerprint? Thanks I have a mongo command called

db.getCollection ('song_fingerprint'). Find ({_id: 1},
                  {Fingerprint: {$ elemMatch: {line: 102}}})

But in Java it is very difficult ...

{
    "_id" : 13,
    "fingerprint" : [ 
        {
            "line" : 1,
            "sub_finger" : "74076e76"
        }, 
        {
            "line" : 2,
            "sub_finger" : "74076ef6"
        }, 
        {
            "line" : 3,
            "sub_finger" : "74076ef6"
        }, 
        {
            "line" : 4,
            "sub_finger" : "74056ef6"
        }, 
        {
            "line" : 5,
            "sub_finger" : "76856ed6"
        }, 
        {
            "line" : 6,
            "sub_finger" : "76e52ed6"
        }, 
        {
            "line" : 7,
            "sub_finger" : "76e58cd6"
        }]
}
s7vr
  • 73,656
  • 11
  • 106
  • 127

1 Answers1

0

i have tested in my local its working it's returning corresponding element in json

db.getCollection('song_fingerprint').find({"fingerprint.line" : 2},{_id: 13, fingerprint: {$elemMatch: {line: "2"}}})
Narendra
  • 127
  • 3
  • 11