Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7673949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:37:44+00:00 2026-05-31T16:37:44+00:00

If I perform the following query in MongoDB shell, all is fine: db.users.find({location: {$near:

  • 0

If I perform the following query in MongoDB shell, all is fine:

db.users.find({location: {$near: [52.3, 6.6], $maxDistance: 0.27}})

However, if I switch the order of arguments, the query fails:

db.users.find({location: {$maxDistance: 0.27, $near: [52.3, 6.6]}})

Mongo returns the following error:

error: {
    "$err" : "geo values have to be numbers: { $maxDistance: 0.27, $near: [ 52.3, 6.6 ] }",
    "code" : 13026
}

Apparently, the order of the query dictionary’s arguments are important, which strikes me as odd. Can anybody shed some light on this? I’m running MongoDB 2.0.2.

The required order poses a problem for me as I build up the dictionary dynamically and (want to) have no control over the order in which the keys are serialised (which, happens to be the one posing the error).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:37:45+00:00Added an answer on May 31, 2026 at 4:37 pm

    Well, apparently, Mongo expects ordered dictionary (so called SONs) for some commands, like the $near-query.

    In Python, this is done by casting the dictionary to a SON, like so:

    from pymongo.son import SON
    
    s = SON({'$near': [50, 50]})
    s['$maxDistance'] = 0.27
    db.users.find({'geoloc': s})
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a query to perform the following: find the countryID where country =
When I perform the following: $popular_posts = $this->Blog->find('all', array('limit' => 5)); I get the
I need a VBA function that will perform the following: Find all unique values
I am using the following // perform query and get feed of all results
I am attempting to perform the following query: SELECT SUM(cash) AS total_cash FROM users
I'm using the following query to perform a search in SQLite. public MatrixCursor listViewCursor(String
I am using Doctrine (DQL) with ZF2 to perform the following query: $qb->select('a.schoolID, a.schoolName')
I'm using SQLServer 2008 and if I perform the following query: SELECT * FROM
I am trying to get ActiveRecord to perform the following query: SELECT A.*, B.*,
The following query will give me the list of IDs I need to perform

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.