如何使用pymodm创建全文索引

How to create a full text index with pymodm

我不太确定如何使用 PyModm 创建全文索引。

我的 Meta class 看起来像这样:

lass Meta:
        write_concern = WriteConcern(j=True)
        indexes = [
            pymongo.IndexModel([("name", "text"), ("description", "text")])
        ]

但是,当我尝试使用 get_queryset().raw()

运行 原始查询时
{
    "$text": {"$search": query}
}

没有返回结果。

提前致谢。

想通了

显然,我只需要提供 (field, 'text') 个元组的列表

index = [
    pymongo.IndexModel([
        ("first_field", "text"),
        ("second_field", "text")
    ])
]