Mongo多个数组值匹配

时间:2015-02-24 02:59:16

标签: mongodb sorting meteor filter

所以我有这个基于Facebook Insights API响应的数据模型,您可以假设它是作为mongo集合中的文档插入的。
我的问题是: - 来自FB的Insights数据的表示不是最好的,键可能包含“。”,或其他字符不是mongo友好的。

  • 我想要实现的查询按一些见解值排序:
    • 获取“墨尔本,VIC,澳大利亚”排名的所有文件。

基于这个问题,我的问题是:

  • 您是否建议将此文档转换为更友好的mongo,并使查询更简单?或
  • 您是否会保留此模型表示并解决更复杂的查询

在编辑此问题的那一刻,我已经转换了Insights数据表示,但欢迎您的意见!

干杯!

    {
      "id": "155257214638229/insights/page_fans_city/lifetime", 
      "name": "page_fans_city", 
      "period": "lifetime", 
      "values": [
        {
          "value": {
            "Bogotá, Distrito Especial, Colombia": 206, 
            "São Paulo, Brazil": 102, 
            "Melbourne, VIC, Australia": 95, 
            "Cali, Valle del Cauca, Colombia": 76, 
            "Medellín, Antioquia, Colombia": 72, 
            "Bangalore, Karnataka, India": 39, 
            "Cartagena, Bolivar, Colombia": 38, 
            "Barranquilla, Atlantico, Colombia": 36, 
            "New Delhi, Delhi, India": 34, 
            "Ibagué, Tolima, Colombia": 32, 
            "Calcutta, West Bengal, India": 32, 
            "Bucaramanga, Santander, Colombia": 31, 
            "Sydney, NSW, Australia": 29, 
            "Mumbai, Maharashtra, India": 27, 
            "Lisbon, Lisboa, Portugal": 27, 
            "Mexico City, Distrito Federal, Mexico": 26, 
            "Neiva, Huila, Colombia": 23, 
            "Chennai, Tamil Nadu, India": 22, 
            "Hyderabad, Andhra Pradesh, India": 19, 
            "Chandigarh, India": 17, 
            "Pasto, Narino, Colombia": 17, 
            "Cúcuta, Norte de Santander, Colombia": 16, 
            "Santa Marta, Colombia": 16, 
            "Salvador, Bahia, Brazil": 16, 
            "Valledupar, Cesar, Colombia": 15, 
            "Palmira, Valle del Cauca, Colombia": 15, 
            "Montería, Cordoba, Colombia": 15, 
            "Rio de Janeiro, Brazil": 14, 
            "Lucknow, Uttar Pradesh, India": 14, 
            "Villavicencio, Meta, Colombia": 13, 
            "Belo Horizonte, Minas Gerais, Brazil": 13, 
            "Surat, Gujarat, India": 13, 
            "Ahmedabad, Gujarat, India": 13, 
            "Santiago, Region Metropolitana, Chile": 12, 
            "Brasília, Distrito Federal, Brazil": 12, 
            "Pereira, Risaralda, Colombia": 12, 
            "Jalandhar, Punjab, India": 11, 
            "Barrancabermeja, Santander, Colombia": 11, 
            "Tuluá, Valle del Cauca, Colombia": 11, 
            "Buenaventura, Valle del Cauca, Colombia": 11, 
            "Guadalajara, Jalisco, Mexico": 10, 
            "Goiânia, Goias, Brazil": 10, 
            "Adelaide, SA, Australia": 10, 
            "London, England, United Kingdom": 9, 
            "Armenia, Quindio, Colombia": 9
          }, 
          "end_time": "2015-02-19T08:00:00+0000"
        }, 
        {
          "value": {
            "Bogotá, Distrito Especial, Colombia": 207, 
            "São Paulo, Brazil": 103, 
            "Melbourne, VIC, Australia": 95, 
            "Cali, Valle del Cauca, Colombia": 75, 
            "Medellín, Antioquia, Colombia": 72, 
            "Bangalore, Karnataka, India": 40, 
            "Cartagena, Bolivar, Colombia": 38, 
            "Barranquilla, Atlantico, Colombia": 36, 
            "New Delhi, Delhi, India": 34, 
            "Ibagué, Tolima, Colombia": 32, 
            "Calcutta, West Bengal, India": 31, 
            "Bucaramanga, Santander, Colombia": 30, 
            "Sydney, NSW, Australia": 29, 
            "Lisbon, Lisboa, Portugal": 27, 
            "Mumbai, Maharashtra, India": 27, 
            "Mexico City, Distrito Federal, Mexico": 26, 
            "Neiva, Huila, Colombia": 24, 
            "Chennai, Tamil Nadu, India": 22, 
            "Hyderabad, Andhra Pradesh, India": 19, 
            "Chandigarh, India": 17, 
            "Pasto, Narino, Colombia": 17, 
            "Cúcuta, Norte de Santander, Colombia": 16, 
            "Santa Marta, Colombia": 16, 
            "Salvador, Bahia, Brazil": 16, 
            "Palmira, Valle del Cauca, Colombia": 15, 
            "Valledupar, Cesar, Colombia": 15, 
            "Montería, Cordoba, Colombia": 15, 
            "Rio de Janeiro, Brazil": 14, 
            "Lucknow, Uttar Pradesh, India": 14, 
            "Belo Horizonte, Minas Gerais, Brazil": 13, 
            "Surat, Gujarat, India": 13, 
            "Ahmedabad, Gujarat, India": 13, 
            "Villavicencio, Meta, Colombia": 13, 
            "Santiago, Region Metropolitana, Chile": 12, 
            "Brasília, Distrito Federal, Brazil": 12, 
            "Pereira, Risaralda, Colombia": 12, 
            "Jalandhar, Punjab, India": 11, 
            "Barrancabermeja, Santander, Colombia": 11, 
            "Tuluá, Valle del Cauca, Colombia": 11, 
            "Buenaventura, Valle del Cauca, Colombia": 11, 
            "Guadalajara, Jalisco, Mexico": 10, 
            "Goiânia, Goias, Brazil": 10, 
            "Adelaide, SA, Australia": 10, 
            "Dehra Dun, Uttarakhand, India": 9, 
            "San Luis Potosí, San Luis Potosi, Mexico": 9
          }, 
          "end_time": "2015-02-20T08:00:00+0000"
        }, 
        {
          "value": {
            "Bogotá, Distrito Especial, Colombia": 206, 
            "São Paulo, Brazil": 103, 
            "Melbourne, VIC, Australia": 95, 
            "Cali, Valle del Cauca, Colombia": 75, 
            "Medellín, Antioquia, Colombia": 72, 
            "Bangalore, Karnataka, India": 40, 
            "Cartagena, Bolivar, Colombia": 38, 
            "Barranquilla, Atlantico, Colombia": 36, 
            "New Delhi, Delhi, India": 34, 
            "Ibagué, Tolima, Colombia": 32, 
            "Calcutta, West Bengal, India": 31, 
            "Bucaramanga, Santander, Colombia": 31, 
            "Sydney, NSW, Australia": 29, 
            "Lisbon, Lisboa, Portugal": 27, 
            "Mumbai, Maharashtra, India": 27, 
            "Mexico City, Distrito Federal, Mexico": 26, 
            "Neiva, Huila, Colombia": 23, 
            "Chennai, Tamil Nadu, India": 22, 
            "Hyderabad, Andhra Pradesh, India": 19, 
            "Chandigarh, India": 17, 
            "Pasto, Narino, Colombia": 17, 
            "Santa Marta, Colombia": 16, 
            "Salvador, Bahia, Brazil": 16, 
            "Palmira, Valle del Cauca, Colombia": 15, 
            "Cúcuta, Norte de Santander, Colombia": 15, 
            "Rio de Janeiro, Brazil": 15, 
            "Valledupar, Cesar, Colombia": 15, 
            "Montería, Cordoba, Colombia": 15, 
            "Lucknow, Uttar Pradesh, India": 14, 
            "Belo Horizonte, Minas Gerais, Brazil": 13, 
            "Surat, Gujarat, India": 13, 
            "Villavicencio, Meta, Colombia": 13, 
            "Ahmedabad, Gujarat, India": 13, 
            "Santiago, Region Metropolitana, Chile": 12, 
            "Brasília, Distrito Federal, Brazil": 12, 
            "Pereira, Risaralda, Colombia": 12, 
            "Jalandhar, Punjab, India": 11, 
            "Barrancabermeja, Santander, Colombia": 11, 
            "Tuluá, Valle del Cauca, Colombia": 11, 
            "Buenaventura, Valle del Cauca, Colombia": 11, 
            "Guadalajara, Jalisco, Mexico": 10, 
            "Adelaide, SA, Australia": 10, 
            "Goiânia, Goias, Brazil": 10, 
            "Dehra Dun, Uttarakhand, India": 9, 
            "San Luis Potosí, San Luis Potosi, Mexico": 9
          }, 
          "end_time": "2015-02-21T08:00:00+0000"
        }
      ], 
      "title": "Lifetime Likes by City", 
      "description": "Lifetime: Aggregated Facebook location data, sorted by city, about the people who like your Page. (Unique Users)"
    }

0 个答案:

没有答案