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

Some documents may appear multiple times in the search result #437

Open
mikecat opened this issue Apr 13, 2024 · 1 comment
Open

Some documents may appear multiple times in the search result #437

mikecat opened this issue Apr 13, 2024 · 1 comment

Comments

@mikecat
Copy link

mikecat commented Apr 13, 2024

Environment:

  • Windows 11 Home 23H2
  • Node.js v20.12.2
  • FlexSearch 0.7.43

Example JavaScript code test-dupe.js:

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

const index = new Document({
  encode: (str) => str.split(" "),
  document: {
    id: "id",
    index: "data[]",
  },
});

index.add({ id: 0, data: ["test", "test hoge"] });
index.add({ id: 1, data: ["test", "hoge fuga test"] });
index.add({ id: 2, data: ["test", "hoge fuga foo"] });
index.add({ id: 3, data: ["bar", "test hoge"] });
index.add({ id: 4, data: ["meow", "hoge fuga test"] });

const res = index.search("test", { index: "data[]" });
console.log(res);

Running this code as node test-dupe.js resulted in:

[ { field: 'data[]', result: [ 0, 1, 2, 3, 1, 4 ] } ]

Now you can see the id 1 appears twice in the search result.

I expect that every documents should appear at most once in one search result.

This result also looks weird for me because the id 0 is not appearing twice while the document has test in two elements of data as the document with the id 1 does.

Documents with id 2, 3, and 4 are for verifying that each elements alone bring hits in the search.

My questions:

  • Is seeing the same document multiple times in one search result like this an expected behavior?
  • Why the document with id 0 doesn't appear twice while one with id 1 does in this case?
@baterrey
Copy link

baterrey commented Sep 5, 2024

Hello, any updates on it?

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

2 participants