Reputation: 321
Folks,
I trying to use the fields argument on find method, I got the follow error code:
TypeError: __init__() got multiple values for keyword argument 'fields'
Code:
mongo.db.products.find({ '$text': { '$search': string } }, { 'score': { '$meta': 'textScore' } }, fields=('name', 'foo', 'bar',))
Without full-text search the fields argument works fine.
Upvotes: 1
Views: 3927
Reputation: 151112
For pymongo the "projection part" for the 'textScore' needs to be included in the "fields" specification in the full form:
mongo.db.products.find(
{ '$text': { '$search': string } },
fields=({ 'name': 1, 'foo': 1, 'bar': 1, 'score': { '$meta': 'textScore' } )
)
Upvotes: 4