Mongo Query Issue - Query records from two different collections and merge/join into one single record












0















I have two collections and From my queries , I got records from these collections as ,



Collection_A :



Query :



db.getCollection('Collection_A').findOne({"meta.md5":"270daaa8c9da2c0ce114fd297ecb3fce"},{"pdf":1,"_id":0})


Record :



{
"pdf" : {
"engine" : "pdf",
"status" : "done",
"retry" : 3,
"limit" : 4500,
"stop_on_detection" : 0,
"file_type" : "*",
"file_limit_slot" : 60,
"start_time" : 1543225534.08531,
"end_time" : 1543225534.90477,
"detection" : true
}
}


Collection_B:



Query :



db.getCollection('Collection_B').find({"md5":"270daaa8c9da2c0ce114fd297ecb3fce"},{"pdf":1,"_id":0})


Record :



{
"pdf" : {
"version" : {
"decomposer" : "1.0"
},
"results" : {
"status" : 1,
"vector_value" : 2,
"file_version" : "",
"is_portmanteau" : false,
"version" : {
"decomposer" : "1.0"
},
"pdfid" : {
"Encrypt" : 0,
"stream" : 2,
"JavaScript" : 1,
"OpenAction" : 1,
"JS" : 1,
"header" : "%PDF-1.1",
"entropy" : "",
"totalEntropy" : "",
"ObjStm" : 0,
"AcroForm" : 0,
"countEof" : "",
"xref" : 1,
"endobj" : 9,
"filename" : "270daaa8c9da2c0ce114fd297ecb3fce.pdf",
"version" : "0.2.1",
"AA" : 0,
"errorMessage" : "",
"Launch" : 0,
"RichMedia" : 0,
"endstream" : 2,
"nonStreamEntropy" : "",
"JBIG2Decode" : 0,
"trailer" : 1,
"isPdf" : "True",
"Page" : 1,
"countCharAfterLastEof" : "",
"dates" : {
"date" :
},
"obj" : 9,
"EmbeddedFile" : 1,
"startxref" : 1,
"XFA" : 0,
"Colors" : 0,
"streamEntropy" : "",
"errorOccurred" : "False"
},
"file_id" : "ae9eb8ef543504666d2c4f58e1c2ff48",
"file_path" : "NA",
"pdf_id_error" : ""
},
"scan_duration" : 0.0714380741119385
}
}


How to merge these both records from these collections using a single query ? In SQL , I have used join to get data from two different tables. Since Im not familiar much with mongo , Not sure how to achieve this ?



Expected Result :



    {
"pdf" : {
"status" : "Completed",
"detection" : true,
"pdf" : {
"version" : {
"decomposer" : "1.0"
},
"results" : {
"status" : 1,
"vector_value" : 2,
"file_version" : "",
"is_portmanteau" : false,
"version" : {
"decomposer" : "1.0"
},
"pdfid" : {
"Encrypt" : 0,
"stream" : 2,
"JavaScript" : 1,
"OpenAction" : 1,
"JS" : 1,
"header" : "%PDF-1.1",
"entropy" : "",
"totalEntropy" : "",
"ObjStm" : 0,
"AcroForm" : 0,
"countEof" : "",
"xref" : 1,
"endobj" : 9,
"filename" : "270daaa8c9da2c0ce114fd297ecb3fce.pdf",
"version" : "0.2.1",
"AA" : 0,
"errorMessage" : "",
"Launch" : 0,
"RichMedia" : 0,
"endstream" : 2,
"nonStreamEntropy" : "",
"JBIG2Decode" : 0,
"trailer" : 1,
"isPdf" : "True",
"Page" : 1,
"countCharAfterLastEof" : "",
"dates" : {
"date" :
},
"obj" : 9,
"EmbeddedFile" : 1,
"startxref" : 1,
"XFA" : 0,
"Colors" : 0,
"streamEntropy" : "",
"errorOccurred" : "False"
},
"file_id" : "ae9eb8ef543504666d2c4f58e1c2ff48",
"file_path" : "NA",
"pdf_id_error" : ""
},
"scan_duration" : 0.0714380741119385
}
}
}


Update :



Tried This query :



db.getCollection('Collection_A').aggregate( [ { $match: {"meta.md5":"270daaa8c9da2c0ce114fd297ecb3fce"}}, { $lookup: {from: "Collection_B",localField: "meta.md5", foreignField: "md5", as: "pdf"}}, { $project: {"pdf.status":1,"pdf.detection":1,"_id":0}} ] )


But i'm getting this error from the robo mongo client



Failed to execute script.

Error:
Assert: command failed: {
"ok" : 0,
"errmsg" : "global.Collection_B cannot be sharded",
"code" : 28769,
"codeName" : "Location28769"
} : aggregate failed
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:16:14
assert.commandWorked@src/mongo/shell/assert.js:370:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1319:5
DBCollection.prototype.aggregate@:1:355
@(shell):1:1

Error: command failed: {
"ok" : 0,
"errmsg" : "global.Collection_B cannot be sharded",
"code" : 28769,
"codeName" : "Location28769"
} : aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:16:14
assert.commandWorked@src/mongo/shell/assert.js:370:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1319:5
DBCollection.prototype.aggregate@:1:355
@(shell):1:1









share|improve this question

























  • put some sample data's with meta data

    – Senthur Deva
    Nov 27 '18 at 10:41











  • make sure both collections are available in same database

    – Senthur Deva
    Nov 27 '18 at 10:45











  • @SenthurDeva Thanks for the comment. But both the collections are under same database.

    – Arun
    Nov 27 '18 at 10:55











  • What is your mongoDB version?

    – Senthur Deva
    Nov 27 '18 at 11:00











  • @SenthurDeva db.serverStatus() shows version as 3.6.5 and Im using Robo Mongo 3T : 1.2 client to connect to mongo.

    – Arun
    Nov 27 '18 at 11:28


















0















I have two collections and From my queries , I got records from these collections as ,



Collection_A :



Query :



db.getCollection('Collection_A').findOne({"meta.md5":"270daaa8c9da2c0ce114fd297ecb3fce"},{"pdf":1,"_id":0})


Record :



{
"pdf" : {
"engine" : "pdf",
"status" : "done",
"retry" : 3,
"limit" : 4500,
"stop_on_detection" : 0,
"file_type" : "*",
"file_limit_slot" : 60,
"start_time" : 1543225534.08531,
"end_time" : 1543225534.90477,
"detection" : true
}
}


Collection_B:



Query :



db.getCollection('Collection_B').find({"md5":"270daaa8c9da2c0ce114fd297ecb3fce"},{"pdf":1,"_id":0})


Record :



{
"pdf" : {
"version" : {
"decomposer" : "1.0"
},
"results" : {
"status" : 1,
"vector_value" : 2,
"file_version" : "",
"is_portmanteau" : false,
"version" : {
"decomposer" : "1.0"
},
"pdfid" : {
"Encrypt" : 0,
"stream" : 2,
"JavaScript" : 1,
"OpenAction" : 1,
"JS" : 1,
"header" : "%PDF-1.1",
"entropy" : "",
"totalEntropy" : "",
"ObjStm" : 0,
"AcroForm" : 0,
"countEof" : "",
"xref" : 1,
"endobj" : 9,
"filename" : "270daaa8c9da2c0ce114fd297ecb3fce.pdf",
"version" : "0.2.1",
"AA" : 0,
"errorMessage" : "",
"Launch" : 0,
"RichMedia" : 0,
"endstream" : 2,
"nonStreamEntropy" : "",
"JBIG2Decode" : 0,
"trailer" : 1,
"isPdf" : "True",
"Page" : 1,
"countCharAfterLastEof" : "",
"dates" : {
"date" :
},
"obj" : 9,
"EmbeddedFile" : 1,
"startxref" : 1,
"XFA" : 0,
"Colors" : 0,
"streamEntropy" : "",
"errorOccurred" : "False"
},
"file_id" : "ae9eb8ef543504666d2c4f58e1c2ff48",
"file_path" : "NA",
"pdf_id_error" : ""
},
"scan_duration" : 0.0714380741119385
}
}


How to merge these both records from these collections using a single query ? In SQL , I have used join to get data from two different tables. Since Im not familiar much with mongo , Not sure how to achieve this ?



Expected Result :



    {
"pdf" : {
"status" : "Completed",
"detection" : true,
"pdf" : {
"version" : {
"decomposer" : "1.0"
},
"results" : {
"status" : 1,
"vector_value" : 2,
"file_version" : "",
"is_portmanteau" : false,
"version" : {
"decomposer" : "1.0"
},
"pdfid" : {
"Encrypt" : 0,
"stream" : 2,
"JavaScript" : 1,
"OpenAction" : 1,
"JS" : 1,
"header" : "%PDF-1.1",
"entropy" : "",
"totalEntropy" : "",
"ObjStm" : 0,
"AcroForm" : 0,
"countEof" : "",
"xref" : 1,
"endobj" : 9,
"filename" : "270daaa8c9da2c0ce114fd297ecb3fce.pdf",
"version" : "0.2.1",
"AA" : 0,
"errorMessage" : "",
"Launch" : 0,
"RichMedia" : 0,
"endstream" : 2,
"nonStreamEntropy" : "",
"JBIG2Decode" : 0,
"trailer" : 1,
"isPdf" : "True",
"Page" : 1,
"countCharAfterLastEof" : "",
"dates" : {
"date" :
},
"obj" : 9,
"EmbeddedFile" : 1,
"startxref" : 1,
"XFA" : 0,
"Colors" : 0,
"streamEntropy" : "",
"errorOccurred" : "False"
},
"file_id" : "ae9eb8ef543504666d2c4f58e1c2ff48",
"file_path" : "NA",
"pdf_id_error" : ""
},
"scan_duration" : 0.0714380741119385
}
}
}


Update :



Tried This query :



db.getCollection('Collection_A').aggregate( [ { $match: {"meta.md5":"270daaa8c9da2c0ce114fd297ecb3fce"}}, { $lookup: {from: "Collection_B",localField: "meta.md5", foreignField: "md5", as: "pdf"}}, { $project: {"pdf.status":1,"pdf.detection":1,"_id":0}} ] )


But i'm getting this error from the robo mongo client



Failed to execute script.

Error:
Assert: command failed: {
"ok" : 0,
"errmsg" : "global.Collection_B cannot be sharded",
"code" : 28769,
"codeName" : "Location28769"
} : aggregate failed
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:16:14
assert.commandWorked@src/mongo/shell/assert.js:370:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1319:5
DBCollection.prototype.aggregate@:1:355
@(shell):1:1

Error: command failed: {
"ok" : 0,
"errmsg" : "global.Collection_B cannot be sharded",
"code" : 28769,
"codeName" : "Location28769"
} : aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:16:14
assert.commandWorked@src/mongo/shell/assert.js:370:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1319:5
DBCollection.prototype.aggregate@:1:355
@(shell):1:1









share|improve this question

























  • put some sample data's with meta data

    – Senthur Deva
    Nov 27 '18 at 10:41











  • make sure both collections are available in same database

    – Senthur Deva
    Nov 27 '18 at 10:45











  • @SenthurDeva Thanks for the comment. But both the collections are under same database.

    – Arun
    Nov 27 '18 at 10:55











  • What is your mongoDB version?

    – Senthur Deva
    Nov 27 '18 at 11:00











  • @SenthurDeva db.serverStatus() shows version as 3.6.5 and Im using Robo Mongo 3T : 1.2 client to connect to mongo.

    – Arun
    Nov 27 '18 at 11:28
















0












0








0








I have two collections and From my queries , I got records from these collections as ,



Collection_A :



Query :



db.getCollection('Collection_A').findOne({"meta.md5":"270daaa8c9da2c0ce114fd297ecb3fce"},{"pdf":1,"_id":0})


Record :



{
"pdf" : {
"engine" : "pdf",
"status" : "done",
"retry" : 3,
"limit" : 4500,
"stop_on_detection" : 0,
"file_type" : "*",
"file_limit_slot" : 60,
"start_time" : 1543225534.08531,
"end_time" : 1543225534.90477,
"detection" : true
}
}


Collection_B:



Query :



db.getCollection('Collection_B').find({"md5":"270daaa8c9da2c0ce114fd297ecb3fce"},{"pdf":1,"_id":0})


Record :



{
"pdf" : {
"version" : {
"decomposer" : "1.0"
},
"results" : {
"status" : 1,
"vector_value" : 2,
"file_version" : "",
"is_portmanteau" : false,
"version" : {
"decomposer" : "1.0"
},
"pdfid" : {
"Encrypt" : 0,
"stream" : 2,
"JavaScript" : 1,
"OpenAction" : 1,
"JS" : 1,
"header" : "%PDF-1.1",
"entropy" : "",
"totalEntropy" : "",
"ObjStm" : 0,
"AcroForm" : 0,
"countEof" : "",
"xref" : 1,
"endobj" : 9,
"filename" : "270daaa8c9da2c0ce114fd297ecb3fce.pdf",
"version" : "0.2.1",
"AA" : 0,
"errorMessage" : "",
"Launch" : 0,
"RichMedia" : 0,
"endstream" : 2,
"nonStreamEntropy" : "",
"JBIG2Decode" : 0,
"trailer" : 1,
"isPdf" : "True",
"Page" : 1,
"countCharAfterLastEof" : "",
"dates" : {
"date" :
},
"obj" : 9,
"EmbeddedFile" : 1,
"startxref" : 1,
"XFA" : 0,
"Colors" : 0,
"streamEntropy" : "",
"errorOccurred" : "False"
},
"file_id" : "ae9eb8ef543504666d2c4f58e1c2ff48",
"file_path" : "NA",
"pdf_id_error" : ""
},
"scan_duration" : 0.0714380741119385
}
}


How to merge these both records from these collections using a single query ? In SQL , I have used join to get data from two different tables. Since Im not familiar much with mongo , Not sure how to achieve this ?



Expected Result :



    {
"pdf" : {
"status" : "Completed",
"detection" : true,
"pdf" : {
"version" : {
"decomposer" : "1.0"
},
"results" : {
"status" : 1,
"vector_value" : 2,
"file_version" : "",
"is_portmanteau" : false,
"version" : {
"decomposer" : "1.0"
},
"pdfid" : {
"Encrypt" : 0,
"stream" : 2,
"JavaScript" : 1,
"OpenAction" : 1,
"JS" : 1,
"header" : "%PDF-1.1",
"entropy" : "",
"totalEntropy" : "",
"ObjStm" : 0,
"AcroForm" : 0,
"countEof" : "",
"xref" : 1,
"endobj" : 9,
"filename" : "270daaa8c9da2c0ce114fd297ecb3fce.pdf",
"version" : "0.2.1",
"AA" : 0,
"errorMessage" : "",
"Launch" : 0,
"RichMedia" : 0,
"endstream" : 2,
"nonStreamEntropy" : "",
"JBIG2Decode" : 0,
"trailer" : 1,
"isPdf" : "True",
"Page" : 1,
"countCharAfterLastEof" : "",
"dates" : {
"date" :
},
"obj" : 9,
"EmbeddedFile" : 1,
"startxref" : 1,
"XFA" : 0,
"Colors" : 0,
"streamEntropy" : "",
"errorOccurred" : "False"
},
"file_id" : "ae9eb8ef543504666d2c4f58e1c2ff48",
"file_path" : "NA",
"pdf_id_error" : ""
},
"scan_duration" : 0.0714380741119385
}
}
}


Update :



Tried This query :



db.getCollection('Collection_A').aggregate( [ { $match: {"meta.md5":"270daaa8c9da2c0ce114fd297ecb3fce"}}, { $lookup: {from: "Collection_B",localField: "meta.md5", foreignField: "md5", as: "pdf"}}, { $project: {"pdf.status":1,"pdf.detection":1,"_id":0}} ] )


But i'm getting this error from the robo mongo client



Failed to execute script.

Error:
Assert: command failed: {
"ok" : 0,
"errmsg" : "global.Collection_B cannot be sharded",
"code" : 28769,
"codeName" : "Location28769"
} : aggregate failed
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:16:14
assert.commandWorked@src/mongo/shell/assert.js:370:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1319:5
DBCollection.prototype.aggregate@:1:355
@(shell):1:1

Error: command failed: {
"ok" : 0,
"errmsg" : "global.Collection_B cannot be sharded",
"code" : 28769,
"codeName" : "Location28769"
} : aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:16:14
assert.commandWorked@src/mongo/shell/assert.js:370:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1319:5
DBCollection.prototype.aggregate@:1:355
@(shell):1:1









share|improve this question
















I have two collections and From my queries , I got records from these collections as ,



Collection_A :



Query :



db.getCollection('Collection_A').findOne({"meta.md5":"270daaa8c9da2c0ce114fd297ecb3fce"},{"pdf":1,"_id":0})


Record :



{
"pdf" : {
"engine" : "pdf",
"status" : "done",
"retry" : 3,
"limit" : 4500,
"stop_on_detection" : 0,
"file_type" : "*",
"file_limit_slot" : 60,
"start_time" : 1543225534.08531,
"end_time" : 1543225534.90477,
"detection" : true
}
}


Collection_B:



Query :



db.getCollection('Collection_B').find({"md5":"270daaa8c9da2c0ce114fd297ecb3fce"},{"pdf":1,"_id":0})


Record :



{
"pdf" : {
"version" : {
"decomposer" : "1.0"
},
"results" : {
"status" : 1,
"vector_value" : 2,
"file_version" : "",
"is_portmanteau" : false,
"version" : {
"decomposer" : "1.0"
},
"pdfid" : {
"Encrypt" : 0,
"stream" : 2,
"JavaScript" : 1,
"OpenAction" : 1,
"JS" : 1,
"header" : "%PDF-1.1",
"entropy" : "",
"totalEntropy" : "",
"ObjStm" : 0,
"AcroForm" : 0,
"countEof" : "",
"xref" : 1,
"endobj" : 9,
"filename" : "270daaa8c9da2c0ce114fd297ecb3fce.pdf",
"version" : "0.2.1",
"AA" : 0,
"errorMessage" : "",
"Launch" : 0,
"RichMedia" : 0,
"endstream" : 2,
"nonStreamEntropy" : "",
"JBIG2Decode" : 0,
"trailer" : 1,
"isPdf" : "True",
"Page" : 1,
"countCharAfterLastEof" : "",
"dates" : {
"date" :
},
"obj" : 9,
"EmbeddedFile" : 1,
"startxref" : 1,
"XFA" : 0,
"Colors" : 0,
"streamEntropy" : "",
"errorOccurred" : "False"
},
"file_id" : "ae9eb8ef543504666d2c4f58e1c2ff48",
"file_path" : "NA",
"pdf_id_error" : ""
},
"scan_duration" : 0.0714380741119385
}
}


How to merge these both records from these collections using a single query ? In SQL , I have used join to get data from two different tables. Since Im not familiar much with mongo , Not sure how to achieve this ?



Expected Result :



    {
"pdf" : {
"status" : "Completed",
"detection" : true,
"pdf" : {
"version" : {
"decomposer" : "1.0"
},
"results" : {
"status" : 1,
"vector_value" : 2,
"file_version" : "",
"is_portmanteau" : false,
"version" : {
"decomposer" : "1.0"
},
"pdfid" : {
"Encrypt" : 0,
"stream" : 2,
"JavaScript" : 1,
"OpenAction" : 1,
"JS" : 1,
"header" : "%PDF-1.1",
"entropy" : "",
"totalEntropy" : "",
"ObjStm" : 0,
"AcroForm" : 0,
"countEof" : "",
"xref" : 1,
"endobj" : 9,
"filename" : "270daaa8c9da2c0ce114fd297ecb3fce.pdf",
"version" : "0.2.1",
"AA" : 0,
"errorMessage" : "",
"Launch" : 0,
"RichMedia" : 0,
"endstream" : 2,
"nonStreamEntropy" : "",
"JBIG2Decode" : 0,
"trailer" : 1,
"isPdf" : "True",
"Page" : 1,
"countCharAfterLastEof" : "",
"dates" : {
"date" :
},
"obj" : 9,
"EmbeddedFile" : 1,
"startxref" : 1,
"XFA" : 0,
"Colors" : 0,
"streamEntropy" : "",
"errorOccurred" : "False"
},
"file_id" : "ae9eb8ef543504666d2c4f58e1c2ff48",
"file_path" : "NA",
"pdf_id_error" : ""
},
"scan_duration" : 0.0714380741119385
}
}
}


Update :



Tried This query :



db.getCollection('Collection_A').aggregate( [ { $match: {"meta.md5":"270daaa8c9da2c0ce114fd297ecb3fce"}}, { $lookup: {from: "Collection_B",localField: "meta.md5", foreignField: "md5", as: "pdf"}}, { $project: {"pdf.status":1,"pdf.detection":1,"_id":0}} ] )


But i'm getting this error from the robo mongo client



Failed to execute script.

Error:
Assert: command failed: {
"ok" : 0,
"errmsg" : "global.Collection_B cannot be sharded",
"code" : 28769,
"codeName" : "Location28769"
} : aggregate failed
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:16:14
assert.commandWorked@src/mongo/shell/assert.js:370:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1319:5
DBCollection.prototype.aggregate@:1:355
@(shell):1:1

Error: command failed: {
"ok" : 0,
"errmsg" : "global.Collection_B cannot be sharded",
"code" : 28769,
"codeName" : "Location28769"
} : aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:16:14
assert.commandWorked@src/mongo/shell/assert.js:370:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1319:5
DBCollection.prototype.aggregate@:1:355
@(shell):1:1






mongodb join collections mongodb-query aggregation-framework






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 27 '18 at 10:53







Arun

















asked Nov 27 '18 at 8:58









ArunArun

535417




535417













  • put some sample data's with meta data

    – Senthur Deva
    Nov 27 '18 at 10:41











  • make sure both collections are available in same database

    – Senthur Deva
    Nov 27 '18 at 10:45











  • @SenthurDeva Thanks for the comment. But both the collections are under same database.

    – Arun
    Nov 27 '18 at 10:55











  • What is your mongoDB version?

    – Senthur Deva
    Nov 27 '18 at 11:00











  • @SenthurDeva db.serverStatus() shows version as 3.6.5 and Im using Robo Mongo 3T : 1.2 client to connect to mongo.

    – Arun
    Nov 27 '18 at 11:28





















  • put some sample data's with meta data

    – Senthur Deva
    Nov 27 '18 at 10:41











  • make sure both collections are available in same database

    – Senthur Deva
    Nov 27 '18 at 10:45











  • @SenthurDeva Thanks for the comment. But both the collections are under same database.

    – Arun
    Nov 27 '18 at 10:55











  • What is your mongoDB version?

    – Senthur Deva
    Nov 27 '18 at 11:00











  • @SenthurDeva db.serverStatus() shows version as 3.6.5 and Im using Robo Mongo 3T : 1.2 client to connect to mongo.

    – Arun
    Nov 27 '18 at 11:28



















put some sample data's with meta data

– Senthur Deva
Nov 27 '18 at 10:41





put some sample data's with meta data

– Senthur Deva
Nov 27 '18 at 10:41













make sure both collections are available in same database

– Senthur Deva
Nov 27 '18 at 10:45





make sure both collections are available in same database

– Senthur Deva
Nov 27 '18 at 10:45













@SenthurDeva Thanks for the comment. But both the collections are under same database.

– Arun
Nov 27 '18 at 10:55





@SenthurDeva Thanks for the comment. But both the collections are under same database.

– Arun
Nov 27 '18 at 10:55













What is your mongoDB version?

– Senthur Deva
Nov 27 '18 at 11:00





What is your mongoDB version?

– Senthur Deva
Nov 27 '18 at 11:00













@SenthurDeva db.serverStatus() shows version as 3.6.5 and Im using Robo Mongo 3T : 1.2 client to connect to mongo.

– Arun
Nov 27 '18 at 11:28







@SenthurDeva db.serverStatus() shows version as 3.6.5 and Im using Robo Mongo 3T : 1.2 client to connect to mongo.

– Arun
Nov 27 '18 at 11:28














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53495925%2fmongo-query-issue-query-records-from-two-different-collections-and-merge-join%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53495925%2fmongo-query-issue-query-records-from-two-different-collections-and-merge-join%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)