This question is based on MongoDB, How to get selected items by selecting, selecting multiple conditions. This is similar to the IN condition in Mysql
SELECT * FROM venuelist WHERE siteid IN (siteid1, siteid2)
I added the json data structure that I used. [Ref: JSON STRUCTUE OF MONGODB] .
As an example, it has a local list in the list of places, it has several place identifiers for the place and the sum of the user agent name and the total as a value. User agents mean Os user, browser information, and device information. In this case, I used the os distribution. In this case, I counted linux, ubuntu was counting on a specific eventid.
This is true,
"sum" : [ { "name" : "linux", "value" : 12 }, { "name" : "ubuntu", "value" : 4 } ],
Finally, I want to get the count of all linux users by selecting the siteid list in a single search query in MongoDB.
As an example, I want to select the entire number of Linux users by setting if the place identifier is VID1212 or VID4343
Reference: JSON STRUCTUE OF MONGODB
{ "_id" : ObjectId("57f940c4932a00aba387b0b0"), "tenantID" : 1, "date" : "2016-10-09 00:23:56", "venueList" : [ { "id" : "VID1212", "sum" : [ { "name" : "linux", "value" : 12 }, { "name" : "ubuntu", "value" : 4 } ], "ssidList" : [ // this is list of ssid's in venue { "id" : "SSID1212", "sum" : [ { "name" : "linux", "value" : 8 }, { "name" : "ubuntu", "value" : 6 } ], "macList" : [ // this is mac list inside particular ssid ex: this is mac list inside the SSID1212 { "id" : "12:12:12:12:12:12", "sum" : [ { "name" : "linux", "value" : 12 }, { "name" : "ubuntu", "value" : 1 } ] } ] } ] }, { "id" : "VID4343", "sum" : [ { "name" : "linux", "value" : 2 } ], "ssidList" : [ { "id" : "SSID4343", "sum" : [ { "name" : "linux", "value" : 2 } ], "macList" : [ { "id" : "43:43:43:43:43:34", "sum" : [ { "name" : "linux", "value" : 2 } ] } ] } ] } ] }
I use golang as a data processing language using mongoldb using the mgo.v2 package
Expected Result:
Output
- linux: 12 + 2 = 14
- ubuntu: 4 + 0 = 4
Do not take into account the internal list in venuela.