in Education by
I have two collection vmdetails and rsc_installtion_status , i want to select the documents from rsc_installtion_status which do not have matching hostname in vmdetails I used the below query db.rsc_installtion_status.aggregate([{$lookup:{ from: "vmdetails",let: {rschostname: "$hostname"},pipeline:[{$match:{$expr:{$ne :["$hostname","$$rschostname"]}}}],as: "rscInstall"}},{$unwind:"$rscInstall"},{$project:{"_id":0,"rscInstall":0}}]) the no of records in vmdetails > db.vmdetails.find().count() 4 the no of records in > db.rsc_installtion_status.find().count() 37 out of 37 three documents match with documents in vmdetails so i expect the result to be 34 documents but the outcome what i get is 3 records for each document ie 34X3 { "hostname" : "string", "configdownload" : "string", "rscpkgdownload" : "string", "configextraction" : "string", "rscpkgextraction" : "string", "rscstartup" : "string", "installedversion" : "string", "_class" : "com.mastercard.rsc.domain.RscInstalltionStatus" } { "hostname" : "string", "configdownload" : "string", "rscpkgdownload" : "string", "configextraction" : "string", "rscpkgextraction" : "string", "rscstartup" : "string", "installedversion" : "string", "_class" : "com.mastercard.rsc.domain.RscInstalltionStatus" } { "hostname" : "string", "configdownload" : "string", "rscpkgdownload" : "string", "configextraction" : "string", "rscpkgextraction" : "string", "rscstartup" : "string", "installedversion" : "string", "_class" : "com.mastercard.rsc.domain.RscInstalltionStatus" } but in the $match if i use $eq instead of $ne the results are correct it only outputs three records. how can i select the records which do not match with hostname JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
db.rsc_installtion_status.aggregate([ {$lookup : { from:"vmdetails", localField:"hostname", foreignField:"hostname" , as:"rscinstall" } }, { $match: { "rscinstall": { $eq: [] } } } ]) the lookup script is basic one the below match is the one which solved $eq which checks whether the array is empty or not and returns documents which are not common in both collections. if $ne used then it will return the records which are matched in both the collections. { $match: { "rscinstall": { $eq: [] } } } ])

Related questions

0 votes
    I have a requirement to return the same length of the array provided to mongo. usernames = ['user1' ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I want to query something with SQL's like query: SELECT * FROM users WHERE name LIKE '%m%' How to do I ... like in the documentation. Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    Input: {_id:ObjectID(123),ip:'123.123.123.123'} {_id:ObjectID(123),ip:'123.123.123.123'} ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Input: {_id:ObjectID(123),ip:'123.123.123.123'} {_id:ObjectID(123),ip:'123.123.123.123'} ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    Input: {_id:ObjectID(123),ip:'123.123.123.123'} {_id:ObjectID(123),ip:'123.123.123.123'} ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    Following query is perfectly working in mongo shell. db.collection.find({ "_id" : UUID("87aa9ed6-8485-4517 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    I tried mongo replica sets for the first time. I am using ubuntu on ec2 and I booted up three instances ... replicate across machines? Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    Context: I have been writing automated test scripts with Appium for quite a while and everything works well ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 27, 2022 in Education by JackTerrance
0 votes
    You are given a data set consisting of variables with more than 30 percent missing values. How will you deal with them?...
asked Apr 26, 2021 in Technology by JackTerrance
0 votes
    Which of these method returns a largest whole number less than or equal to variable X? (a) double ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    What happens when number of available energy minima be more than number of patterns to be stored? (a) no effect (b) ... (d) none of the mentioned Please answer the above question....
asked Sep 3, 2022 in Education by JackTerrance
0 votes
    What happens when number of patterns is more than number of basins of attraction? (a) false wells (b) storage ... (d) none of the mentioned Please answer the above question....
asked Aug 30, 2022 in Education by JackTerrance
0 votes
    What happens when number of patterns is more than number of basins of attraction? (a) false wells (b) storage ... (d) none of the mentioned Please answer the above question....
asked Aug 30, 2022 in Education by JackTerrance
0 votes
    State whether the following statements are True or False, with reasons: The Second World War proved to be far more ... than the First World War. Please answer the above question....
asked Aug 20, 2022 in Education by JackTerrance
0 votes
    Does independence of the judiciary mean that the judiciary is not accountable to any one? Write your answer in not more than 100 words. Please answer the above question....
asked Aug 4, 2022 in Education by JackTerrance
...