在网络浏览器中使用lunr (elastic lunr0.9.5)
作为搜索引擎。
它既简单又快速。但是当它有更多时,它不会在第一个位置列出完全匹配的对象。
我在打字稿中的月份配置
this.lunrIndex = lunr(function () {
this.field('itemId');
this.field('name');
this.ref('itemId');
this.pipeline.remove(lunr.stemmer)
})
当我搜索pan d ca
文字时,它正在返回,
[{
"ref": "PANCOR DSR CAPSULE 10''S",
"score": 0.01674628244112235
},
{
"ref": "PANLID DSR CAPSULE 10''S",
"score": 0.01674628244112235
},
{
"ref": "PANSIO DSR CAPSULE 10''S",
"score": 0.01590146213665648
},
{
"ref": "PANLIFE DSR CAPSULE 10''S",
"score": 0.015507241586286287
},
{
"ref": "PANSEC DSR CAPSULE 10''S",
"score": 0.014526355502926632
},
{
"ref": "PAN D CAPSULE 10''S",
"score": 0.011554433713104873
}
]
Lunr修剪可能是上述结果的原因之一,所以我从管道执行中删除了lunr.trimmer
,但仍然给出了相同的结果。
上面的结果显示,完全匹配的字符串(PAN D C
)得分较低(0.011554433713104873
)。我错过了任何配置吗?
我需要完全匹配的字符串才能获得最高分,我怎样才能实现这一目标?