在词典列表中查找常用元素并根据排名进行分类
我想找出两个列表中共有的“域”,并计算所提供的排名上限中的域数。
db.collection.find()
{
_id : objectId("12345"),
"tags": "txt",
"list_1" : {
{
"Domain": "abc.com",
"Rank" : 1
},
{
"Domain": "zxt.com",
"Rank" : 9999999
},
{
"Domain": "helloworld.com",
"Rank": 1000000
},
{
"Domain": "foo.com",
"Rank": 10000
}
....
"list_2" : {
{
"Domain": "abc.com",
"Rank" : 100000
},
{
"Domain": "sadsadasd.com",
"Rank" : 102
}
....
"list_3" ...
.
.
.
"list_n" ...
.
.
"super_list": {
{
"Domain": "abc.com",
"Rank": 50
},
{
"Domain": "helloworld.com",
"Rank": 2999999
},
{
"Domain": "foo.com",
"Rank": 9999999
}
....
}
....
}
在上面的示例中:list_1和list_2具有通用的但具有不同等级的域。可能有“ n”个列表。类似地,super_list是大多数列表的超级集。超级设置可能没有所有列表。
我想找到以下情况:
1) Domains that are common in both list_1 and list_2 or given 2 lists where ranking does not matter or opt out
Ex. list_1 and list_2 would give ouput as abc.com though they have different ranks.
2) Domains from list_1 which are common and lower than upper bound rank of list_2
Example: abc.com is common in both. But the ranking differs in list_1 and list_2. In this case, I would have some upperbound rank such as 99999. The query should not give common domains as "abc.com" as the ranking is 100000 in list_2
3) Domains that are common to list_1 and super_list where rank upper bound in super_list matter
Example: Let's say: The upper bound is 3 Million rank. We would like to get common domains that are under or equal to 3 Million in super_list from list_1
Here the output would be : helloworld.com which is under 3 Mil in super_list. The foo.com from super_list will be printed as it is higher than 3 Mil rank in super_list.
mongodb的输出