node.js - 如何改进这个 mongodb 地图集搜索
问题描述
我刚刚进入 MongoDB 并玩得很开心,我想知道是否可以提供一些关于在哪里改进此搜索的指示:
我希望最后两个结果得分最高。
Organix Melty Carrot Puffs, score: 2.034492015838623
Organix Melty Carrot Puffs Multipack 4x18g, score: 1.9151359796524048
Organix Carrot Cake Soft Oaty Bars 6x30g, score: 1.8090081214904785
Free & Easy Organic Carrot & Coconut Soup 400g, score: 1.8090081214904785
Tesco Organic Carrots 700G, score: 1.8080946207046509
Sainsbury's Carrots, SO Organic 750g, score: 1.695409893989563
我正在使用的查询:
{
'$search': {
'index': 'default',
'text': {
'query': 'Carrot',
'path': 'item_name',
'fuzzy': {
'maxEdits': 2,
'prefixLength': 5
}
}
}
}, {
'$project': {
'item_name': 1,
'item_price': 1,
'score': {
'$meta': 'searchScore'
}
}
}
非常感谢大家的时间
解决方案
推荐阅读
- r - 自定义函数上 purrr::map 中的列名匹配
- python - 在python中一个接一个地将函数列表应用于可迭代
- python - 如何在 python asyncio 中使用摘要身份验证?
- javascript - 如何忽略 nodejs 和电子中的系统主机
- python - 将 subprocess.Popen 与交互式程序一起使用
- node.js - 命令在终端中工作,但不适用于 node.js
- django - Django表单初始值未显示
- sql-server - SQL VIEW 执行超时已过期
- postgresql - CTE 和 DML 语句的 PG 意外行为
- php - 为什么我得到数组到字符串的转换错误?