php - MongoDB 全文搜索不适用于特定单词(不是停用词)
问题描述
我有一个带有 MongoDB 4.4.x 和 PHP7.x 的 VPS,并使用 MongoDB PHP 库与 MongoDB 连接。
我的文件(大约 1000 万份)如下所示:
集合:租户,answers.answer 上的全文索引
"survey_id": {
"$numberLong": "424221"
},
"account_id": 20014,
"feedback_id": 738857,
"date_reg": "2021-04-22",
"time_reg": "21:15",
"source": 2,
"trigg": 1,
"read_status": 0,
.... etc...,
"answers": {
"0": {
"answer": "Feedback answer 1 lorem ipsum gmail doramet",
"type": 1,
"qid": 4241,
"datatype": 24,
"additional": "",
"q": "What do you think about..."
},
"1": {
"answer": "Feedback answer steve lorem ipsum",
"type": 2,
"qid": 21,
"datatype": 2,
"additional": "",
"q": "What was your experience with..."
},
... etc...
然后我像这样搜索:
$manager = new
MongoDB\Driver\Manager("mongodb://user:pass@localhost:27017");
$filter = ['$text' => ['$search' => "steve"]];
$options = ['limit' => 10];
$query = new MongoDB\Driver\Query($filter,$options);
$cursor = $manager->executeQuery('db.tenants', $query);
foreach($cursor as $row){
echo '<pre>';
print_r($row);
echo '</pre><br><br>';
$i++;
}
这不会返回带有“史蒂夫”的答案。但是,如果我搜索确实有效的“gmail”。那么为什么不为“史蒂夫”呢?两者都不是停用词。我究竟做错了什么?
解决方案
推荐阅读
- javascript - 试图了解此 Node.js 代码的哪一部分负责将我的 POST 请求定向到 mongoose/mongodb 服务器?
- docusignapi - DocuSign.eSign.Client.ApiException {"error":"consent_required"}" / 尝试授予同意时不支持响应类型
- typescript - 迁移到 TypeScript:需要为每个数据库表定义接口以进行解构?
- c - 跟踪线程池中的所有线程
- php - 如何将用户文件夹安全地存储在服务器中?
- r - 使用 nlme 使用阻塞因子重复测量 ANOVA
- python - 如何使用 PyQt6 在 QSettings 中启用 IniFormat?
- c++ - 如何在拥有 QObject 实例的同时收听视图的信号?
- python - 流生成器。详细使用迭代器
- django - docker compose 在 gitlab-ci 构建阶段失败