【发布时间】:2021-07-06 19:13:49
【问题描述】:
我有以下 2 个收藏:
Products
- name (String)
- price (number)
- category (ObjectID refs to Category collection)
Category
- name
我们有搜索查询,例如“一些查询”
我正在尝试获取 product.name 或 product.category.name 部分 包含搜索查询的记录
【问题讨论】:
-
或许可以使用 $text 索引:docs.mongodb.com/manual/reference/operator/query/text
-
文本索引不适用于填充字段。此外,它搜索完全匹配,它不支持部分搜索@ScottGnile
标签: node.js mongodb express mongoose mongoose-schema