Python 如何在pymongo中将查询结果传递给第二个查询?

Python 如何在pymongo中将查询结果传递给第二个查询?,python,mongodb,mongodb-query,full-text-search,pymongo,Python,Mongodb,Mongodb Query,Full Text Search,Pymongo,我的目标是运行一个包含文本搜索的查询。以下是我的尝试: from pymongo import MongoClient from datetime import datetime REMOTE_MONGO_URL = "" mongo_connection = MongoClient(REMOTE_MONGO_URL) xml_db = mongo_connection.some_string.some_other_string #pprint(xml_db.index_informati

我的目标是运行一个包含文本搜索的查询。以下是我的尝试:

from pymongo import MongoClient
from datetime import datetime
REMOTE_MONGO_URL = ""

mongo_connection = MongoClient(REMOTE_MONGO_URL)

xml_db = mongo_connection.some_string.some_other_string

#pprint(xml_db.index_information())


a = xml_db.find(
    {
        "source": "winterfell",
            'expiration_date': {
                '$gte': datetime.now().strftime('%Y-%m-%d')
            },

        "$text": {
                '$search': "ned cat john arya sansa"
            }
    },
    #hint='red_wedding'
)

print(a.count())
最初,当我运行查询时,它只运行无限长的时间,我感觉它没有使用正确的索引。因此,我尝试使用
$hint
强制索引。但是,它失败了,提示我不能同时使用
$text
$hint

因此,我的计划是首先在不使用文本搜索的情况下执行初始查询(这样我就可以对其使用
$hint
),然后对第一个查询的结果运行文本搜索的第二个查询。我怎么做