Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pymongo.errors.OperationFailure: invalid argument in geo near query: minDistance #1281

bigoper opened this issue Jun 4, 2019 · 1 comment


Copy link

bigoper commented Jun 4, 2019

Executing the following GET request fails:
?where={"PostalCode":"33020","geo_location": {"$near": {"$geometry": {"type": "Point" ,"coordinates": [ -80.114494 , 26.48301 ]},"$maxDistance": 16000,"$minDistance": 1}}}&sort=-MatrixModifiedDT&max_results=20

-- it works when I execute the equivalent command in MongoDB

Expected Behavior

I'm expecting to get a list of document matching my query. Documents that their geo_location coordinates are within the radius


    "_error": {
        "code": 400,
        "message": "Query contains unknown or unsupported operators: $minDistance"
    "_status": "ERR"


Actual Behavior

Tell us what happens instead.

Traceback (most recent call last):
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/gunicorn/workers/", line 135, in handle
    self.handle_request(listener, req, client, addr)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/gunicorn/workers/", line 176, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/eve/", line 1043, in __call__
    return super(Eve, self).__call__(environ, start_response)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/flask/", line 2309, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/flask/", line 2295, in wsgi_app
    response = self.handle_exception(e)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/flask/", line 1741, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/flask/", line 35, in reraise
    raise value
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/flask/", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/flask/", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/flask/", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/flask/", line 35, in reraise
    raise value
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/flask/", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/flask/", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/eve/", line 56, in collections_endpoint
    response = get(resource, lookup)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/eve/methods/", line 297, in rate_limited
    return f(*args, **kwargs)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/eve/", line 78, in decorated
    return f(*args, **kwargs)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/eve/methods/", line 1181, in decorated
    r = f(resource, **combined_args)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/eve/methods/", line 39, in get
    return get_internal(resource, **lookup)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/eve/methods/", line 112, in get_internal
    return _perform_find(resource, lookup)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/eve/methods/", line 206, in _perform_find
    for document in cursor:
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/pymongo/", line 1169, in next
    if len(self.__data) or self._refresh():
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/pymongo/", line 1085, in _refresh
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/pymongo/", line 975, in __send_message
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/pymongo/", line 145, in _check_command_response
    raise OperationFailure(msg % errmsg, code, response)
pymongo.errors.OperationFailure: invalid argument in geo near query: minDistance


  • Python version: Python 3.5.2
  • Eve version: 0.8
Copy link

bigoper commented Jun 4, 2019

I've added '$minDistance' to the class.

+ ["$geometry", "$maxDistance", "$box"]

It works now.

@bigoper bigoper closed this as completed Jun 4, 2019
@nicolaiarocci nicolaiarocci reopened this Jun 6, 2019
@nicolaiarocci nicolaiarocci added this to the 0.9.2 milestone Jun 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

2 participants