0
  • I have three collections like WindowsCollection,EsxCollection and LinuxCollection in these all three collections documents i have cpuUtilization,memoryUtilization,hostID keys. Now i have to find top 10 records from all three collections and get these key values from these top 10 documents and form json like below. {"cpu": [10,20,30,40,550,60,70,80,100,30] "memory": [20,30,40,50,60,30,20,40,50,29] "hostId": [92,30,1,2,3,4,5,6,6,7,8,] }

    i am working in scala with salat mongodb.any help ..thankx

Pradip Karad
  • 1,377
  • 2
  • 9
  • 8
  • MongoDB does not "join" collections in any way. You want separate queries on "each" collection or combine all your data into **one** collection. This is what MongoDB was made for. Not to be used just like a relational database. If you want that functionality then use relational instead. – Neil Lunn Oct 02 '14 at 10:36
  • actually i have seperate collections but i have to aggregate them ...isn't it possible ? – Pradip Karad Oct 02 '14 at 10:43
  • It's a very simple statement "no joins". So not possible. Change what you are doing or don't use MongoDB. It's not like that basic information is not readily available. – Neil Lunn Oct 02 '14 at 10:51

0 Answers0