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

OperationFailure: must have $meta projection for all $meta sort keys #1176

Closed
quentinpraz opened this Issue Jul 25, 2018 · 6 comments

Comments

Projects
None yet
2 participants
@quentinpraz
Copy link

quentinpraz commented Jul 25, 2018

Expected Behavior

I'am using the Full Text Search capability of MongoDB. To do so, my queries look like that
http://eve/example?where={"$text":{"$search":"test"}}&projection={"score":{"$meta":"textScore"}}&sort=[("score", {"$meta": "textScore"})]

This is working fine with Eve 0.7.10
Note that I set the allow_unknown property to True. (#841)

Actual Behavior

After the upgrade to Eve 0.8, I have the following error:

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/lib/python2.7/site-packages/eve/endpoints.py", line 56, in collections_endpoint
    response = get(resource, lookup)
  File "/usr/lib/python2.7/site-packages/eve/methods/common.py", line 297, in rate_limited
    return f(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/eve/auth.py", line 78, in decorated
    return f(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/eve/methods/common.py", line 1181, in decorated
    r = f(resource, **combined_args)
  File "/usr/lib/python2.7/site-packages/eve/methods/get.py", line 39, in get
    return get_internal(resource, **lookup)
  File "/usr/lib/python2.7/site-packages/eve/methods/get.py", line 112, in get_internal
    return _perform_find(resource, lookup)
  File "/usr/lib/python2.7/site-packages/eve/methods/get.py", line 206, in _perform_find
    for document in cursor:
  File "/usr/lib/python2.7/site-packages/pymongo/cursor.py", line 1189, in next
    if len(self.__data) or self._refresh():
  File "/usr/lib/python2.7/site-packages/pymongo/cursor.py", line 1104, in _refresh
    self.__send_message(q)
  File "/usr/lib/python2.7/site-packages/pymongo/cursor.py", line 982, in __send_message
    helpers._check_command_response(first)
  File "/usr/lib/python2.7/site-packages/pymongo/helpers.py", line 155, in _check_command_response
    raise OperationFailure(msg % errmsg, code, response)
OperationFailure: must have $meta projection for all $meta sort keys

Environment

  • Python version: 2.7.14
  • Eve version: 0.8
  • PyMongo: 3.7.1
@nicolaiarocci

This comment has been minimized.

Copy link
Member

nicolaiarocci commented Jul 31, 2018

By looking at your stack trace, the exception is raised by PyMongo. Did you try to backport it a little bit?

@nicolaiarocci nicolaiarocci added this to the 0.8.1 milestone Jul 31, 2018

@quentinpraz

This comment has been minimized.

Copy link
Author

quentinpraz commented Jul 31, 2018

I tested the full text search query in two environments:

Environment 1

  • Python version: 2.7.14
  • Eve version: 0.7.10
  • PyMongo: 3.7.1

→ Working fine ✔️

Environment 2

  • Python version: 2.7.14
  • Eve version: 0.8
  • PyMongo: 3.7.1

→ Not working

As you can see, the PyMongo version is the same.

@nicolaiarocci

This comment has been minimized.

Copy link
Member

nicolaiarocci commented Aug 1, 2018

The issue only surfaces on Eve 0.7.10, not on the latest stable, right?

@nicolaiarocci

This comment has been minimized.

Copy link
Member

nicolaiarocci commented Aug 1, 2018

(in the previous post, the contrary appeared to be true)

@quentinpraz

This comment has been minimized.

Copy link
Author

quentinpraz commented Aug 1, 2018

My bad, my second post was wrong (I updated it). It is not working with Eve 0.8. I had to roll back to version 7.10 to be able to use the full text search query.

@nicolaiarocci

This comment has been minimized.

Copy link
Member

nicolaiarocci commented Aug 3, 2018

Should be fixed in 0.8.1-dev

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.