目标:
我希望允许用户按 ID 搜索文档,或允许其他基于文本的查询。
代码:
l_search_results = list(
cll_sips.find(
{
'$or': [
{'_id': ObjectId(s_term)},
{'s_text': re.compile(s_term, re.IGNORECASE)},
{'choices': re.compile(s_term, re.IGNORECASE)}
]
}
).limit(20)
)
错误:
<Whatever you searched for> is not a valid ObjectId