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

Closed
bigoper opened this issue Jun 4, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@bigoper
Copy link

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/sync.py", line 135, in handle
    self.handle_request(listener, req, client, addr)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/gunicorn/workers/sync.py", line 176, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/eve/flaskapp.py", line 1043, in __call__
    return super(Eve, self).__call__(environ, start_response)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/flask/app.py", line 2309, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/flask/app.py", line 2295, in wsgi_app
    response = self.handle_exception(e)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/flask/app.py", line 1741, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/flask/app.py", 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/endpoints.py", line 56, in collections_endpoint
    response = get(resource, lookup)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/eve/methods/common.py", line 297, in rate_limited
    return f(*args, **kwargs)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/eve/auth.py", line 78, in decorated
    return f(*args, **kwargs)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/eve/methods/common.py", line 1181, in decorated
    r = f(resource, **combined_args)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/eve/methods/get.py", line 39, in get
    return get_internal(resource, **lookup)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/eve/methods/get.py", line 112, in get_internal
    return _perform_find(resource, lookup)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/eve/methods/get.py", line 206, in _perform_find
    for document in cursor:
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/pymongo/cursor.py", line 1169, in next
    if len(self.__data) or self._refresh():
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/pymongo/cursor.py", line 1085, in _refresh
    self.__send_message(q)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/pymongo/cursor.py", line 975, in __send_message
    helpers._check_command_response(first)
  File "/usr/venvs/venv_idx20/lib/python3.5/site-packages/pymongo/helpers.py", line 145, in _check_command_response
    raise OperationFailure(msg % errmsg, code, response)
pymongo.errors.OperationFailure: invalid argument in geo near query: minDistance

Environment

  • Python version: Python 3.5.2
  • Eve version: 0.8
@bigoper

This comment has been minimized.

Copy link
Author

commented Jun 4, 2019

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

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

It works now.

@bigoper bigoper closed this 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
You can’t perform that action at this time.