【发布时间】:2018-05-03 04:43:39
【问题描述】:
根据lunrjs的官方文档:
“也支持搜索多个词。如果一个文档至少匹配一个搜索词,它将显示在结果中。搜索词与 OR 组合”。
只有当文档匹配所有搜索词时,它才会显示结果,有什么方法可以做到这一点?
将这些数据编入索引:
[
{id: 1, text: "foo", body: "jander"}
{id: 2, text: "bar", body: "clander"},
{id: 3, text: "foo bar", body: "jander crispy clander"}
{id: 4, text: "foz", body: "lorem ipsum"}
...
]
如果您搜索:
idx.search("foo jander clander");
我希望只有 一个 结果忽略其他两个,因为它们不包含 所有 项,而是包含一些:
// found (1)
{id: 3, text: "foo bar", body: "jander crispy clander"}
但我所拥有的是:
// found (3)
{id: 1, text: "foo", body: "jander"}
{id: 2, text: "bar", body: "clander"},
{id: 3, text: "foo bar", body: "jander crispy clander"}
提前感谢您的任何意见。
【问题讨论】:
-
看起来已经打开了一个 PR 来覆盖这个特性。 github.com/olivernn/lunr.js/pull/332
标签: javascript lunrjs