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

Deleting one document also causes other documents to disappear from searches #40

Closed
lucaong opened this issue Jul 21, 2022 · 2 comments · Fixed by #45
Closed

Deleting one document also causes other documents to disappear from searches #40

lucaong opened this issue Jul 21, 2022 · 2 comments · Fixed by #45
Assignees
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed v0.1.0

Comments

@lucaong
Copy link

lucaong commented Jul 21, 2022

Describe the bug
The bug occurs in lyra-0.0.1-beta-13.

Sorry for opening several bugs, I was trying to compare Lyra with MiniSearch and ran into these issues.

To Reproduce

const db = new Lyra({
  schema: {
    txt: "string",
  }
})

await db.insert({ txt: 'abc' })
//=> { id: 'J-LiSKu45O4d1phnVWvkc' }
await db.insert({ txt: 'abc' })
//=> { id: 'yx-s9o0-8I4uWcPsMyOWL' }
await db.insert({ txt: 'abcd' })
{ id: 'XoKJ6uWhRkftAt06UsdKo' }

await db.search({ term: 'abc', exact: true })
/* Returns what expected:
{
  elapsed: '814μs',
  hits: [
    { id: 'J-LiSKu45O4d1phnVWvkc', txt: 'abc' },
    { id: 'yx-s9o0-8I4uWcPsMyOWL', txt: 'abc' },
    undefined,
    undefined,
    undefined,
    undefined,
    undefined,
    undefined,
    undefined,
    undefined
  ],
  count: 2
}
*/

// Delete one of the two documents containing term `"abc"`
db.delete('yx-s9o0-8I4uWcPsMyOWL')

await db.search({ term: 'abc', exact: true })
/* Returns no results, even if one doc with "abc" should still be in the index:
{
  elapsed: '770μs',
  hits: [
    undefined, undefined,
    undefined, undefined,
    undefined, undefined,
    undefined, undefined,
    undefined, undefined
  ],
  count: 0
}
*/

Expected behavior

Deleting one document should have no effect on other documents.

@micheleriva micheleriva added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed v0.1.0 labels Jul 21, 2022
@lucaong
Copy link
Author

lucaong commented Jul 22, 2022

I don't think this is fixed by #41 . The test in that PR has an issue that leads to a false positive.

@lucaong
Copy link
Author

lucaong commented Jul 25, 2022

Check my comment on #45, as it fixes the issue but leaves dead code and possible performance concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed v0.1.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants