Saturday, 15 August 2015

mongodb - Mongo - Query multiple locations at once -


I am currently trying to find all the users who live in one of the locations list (places This list may be large, compared to a union on server-side, doing multiple queries, this is not necessary).

The use case, for example, is to find all those users who live within 2 miles of any church in my current city, a list of coordinates is given for those churches.

Right now, this low-level query works:

  db.users.count ({location: {$ inside: {$ centerSphere: [[-84.330984, 33.8615 ], 2/3959]}}})   

Also:

  db.users.count ({location: {$ pass: [-84.330984 , 33.8615], $ maxDistance: 2/69}}) However, I want to be able to calculate the number of users living in a series of different locations. I.e. something like this:  
  db.users.count ({$ or: [location: {$ inside: {$ centerSphere: [[-84.330984, 33.8615], 2/3959 }}}}, {Location: {$ inside: {$ centerSphere: [[-85.331122, 34.97832], 2/3 9 5 5}}}}}})   

Right now, When I run this query, the Mongo document returns the error:

  Tuesday Mar 26 17:24:22 Exception exception: The count has failed: {"errmsg": "Exception: $ or This can not contain a 'special' query. "" Code ": 13291," OK ": 0}   

With this error and open GIRA ticket (), Mongo currently $ or $ Using multiple The ability to query the location is limited (or $$) operator, so I can not query the chain location

Is there a best practice or work-around to accomplish this? ? Again, I do not like to ask a different question for each place; Although I know that this may be the only option.

I am currently using Mongo 2.2.3, but there is no problem upgrading to 2.4, if it will solve this dilemma.

Thanks

If you are familiar with Javascript, you can get it You can use mapReduce for.

However, there are two methods, which are essential for the construction of approximately $ $ and $ centerSphere, and you can not exceed the record of Matrred 1000.

Since monogodybie is limited to $ or operator, this is my first method to solve it.



No comments:

Post a Comment