这里topic_question中的topic_list是一个数组,需要查找topic_list中匹配给定两个元素的条目
listf=list() results = db.topic_questions.find({'$and': [{'topic_list':source}, {'topic_list': target}]}) for result in results: listf.append({'question': result['title'], 'answers_count': result['answers_count']})
参考链接:
https://stackoverflow.com/questions/18148166/find-document-with-array-that-contains-a-specific-value
http://www.runoob.com/python3/python-mongodb-query-document.html
https://stackoverflow.com/questions/10018730/how-use-sql-like-in-pymongo
https://blog.csdn.net/LanSeTianKong12/article/details/51725453