Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I have a question about how the results are sorted #431

Open
mtrucc opened this issue Mar 6, 2024 · 0 comments
Open

I have a question about how the results are sorted #431

mtrucc opened this issue Mar 6, 2024 · 0 comments

Comments

@mtrucc
Copy link

mtrucc commented Mar 6, 2024

const { Index } = require("flexsearch");

const data1 = [
  "你家里生的和你用银子买的,都必须受割礼。这样,我的约就立在你们肉体上作永远的约。", // 0
  "你若不肯容他们去,我必使青蛙糟蹋你的四境。", // 1
  "你们要吃无酵饼七日。头一日要把酵从你们各家中除去;因为从头一日起,到第七日为止,凡吃有酵之饼的,必从以色列中剪除。", // 2
  "你要在山的四围给百姓定界限,说:‘你们当谨慎,不可上山去,也不可摸山的边界;凡摸这山的,必要治死他。", // 3
  "你们要侍奉耶和华你们的 神,他必赐福与你的粮与你的水,也必从你们中间除去疾病。", // 4
  "你要对他们说:你们世世代代的后裔,凡身上有污秽、亲近以色列人所分别为圣、归耶和华圣物的,那人必在我面前剪除。我是耶和华。", // 5
  "你们要追赶仇敌,他们必倒在你们刀下。", // 6
  "你们五个人要追赶一百人,一百人要追赶一万人;仇敌必倒在你们刀下。", // 7
  "你们剩下的人必因自己的罪孽和祖宗的罪孽在仇敌之地消灭。", // 8
  "你若和我们同去,将来耶和华有什么好处待我们,我们也必以什么好处待你。”", // 9
  "你们要在这日守为圣安息日,世世代代作为永远的定例。", // 10
  "你们必晓得真理,真理必叫你们得以自由。”", // 11
];

var index = new Index({
  encode: (str) => str.split(""),
});

for (let i = 0; i < data1.length; i++) {
  index.add(i, data1[i]);
}

console.log(`你`, index.search("你", { suggest: true }));
console.log(`你们`, index.search("你们", { suggest: true }));
console.log(`你们必`, index.search("你们必", { suggest: true }));
console.log(`你们必`, index.search("你们必晓得", { suggest: true }));

return

你 [0, 1, 2, 3, 4, 5,  6, 7, 8, 9, 10, 11]
你们 [ 0,  1, 2, 3, 4, 5,  6, 7, 8, 9, 10, 11]
你们必 [ 0,  1, 2, 3, 4, 5,  6, 7, 8, 9, 11, 10]
你们必晓得 [ 11,  0, 1, 2, 3, 4,  5, 6, 7, 8, 9, 10]

But the result I expect is

你 [0, 1, 2, 3, 4, 5,  6, 7, 8, 9, 10, 11]
你们 [ 2, 4, 6, 7, 8, 9, 10, 11, 0, 1, 3, 5]
你们必 [ 11, 2, 4, 6, 7, 8, 9, 10, 0, 1, 3, 5]
你们必晓得 [ 11, 2, 4, 6, 7, 8, 9, 10, 0, 1, 3, 5]

I think when searching 你们必

"你们必晓得真理,真理必叫你们得以自由。”", // 11`

should be first

what should I do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant