python - PyMongo select fields on a full-text search -


folks,
trying use fields argument on find method, got follow error code:

typeerror: __init__() got multiple values keyword argument 'fields' 

code:

mongo.db.products.find({ '$text': { '$search': string } }, { 'score': { '$meta': 'textscore' } }, fields=('name', 'foo', 'bar',)) 

without full-text search fields argument works fine.

for pymongo "projection part" 'textscore' needs included in "fields" specification in full form:

mongo.db.products.find(     { '$text': { '$search': string } },     fields=({ 'name': 1, 'foo': 1, 'bar': 1, 'score': { '$meta': 'textscore' } ) ) 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -