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
Post a Comment