首页 > 解决方案 > 如何改进这个 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'
                }
            }
            }

非常感谢大家的时间

标签: node.jsmongodbmongodb-atlas

解决方案


推荐阅读