question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove() not working with id for documents

See original GitHub issue

Hello, I tried removing documents from the index by passing id, as mentioned in documentation as “the fastest method”. This way, i cannot remove the document. Then, i tried removing the document by passing the document as remove argument, and this way it worked. (Attacched snippet) Am I missing something? Is it supposed to work like this?

Edit: i think this issue is somewhat related to #100

var FlexSearch = require("flexsearch");

var docs = [{
    data: {
        id: 0,
        title: "Foo",
        body: {
            content: "Foobaz"
        }
    }
}, {
    data: {
        id: 1,
        title: "Bar",
        body: {
            content: "Foobar"
        }
    }
}];

var index = new FlexSearch({
    debug: true,
    profile: 'default',
    doc: {
        id: "data:id",
        field: [
            "data:title",
            "data:body:content"
        ]
    }
});

index.add(docs);
index.remove(docs[1]) //<-- This one works, document is deleted
index.remove(1) //<-- This one NOT. Document is still searchable

console.log(index.search('bar'))

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
lludolcommented, Oct 29, 2019

@MatteoBassan and @cezarsmpio I found a solution by looking at the source code:

index.remove({ id: 1 });
0reactions
ts-thomascommented, Jun 28, 2021

Please change over to the version >= 0.7.x, thanks a lot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove element by id - javascript
You can directly remove that element by using remove() method of DOM. here's an example:
Read more >
Element.remove() - Web APIs - MDN Web Docs
Element.remove() is unscopable. The remove() method is not scoped into the with statement. See Symbol.unscopables for more information.
Read more >
Remove a DOM element by ID using JavaScript
To remove a DOM element by id: Select the DOM element using the document.getElementById() method. Call the remove() on the element, e.g. element.remove()...
Read more >
How to Remove Element by Id using JavaScript
An HTML element can be easily removed by using the built-in remove function of JavaScript once its id has been retrieved by the...
Read more >
HTML DOM Element remove Method
HTML DOM Element remove()​​ The remove() method removes an element (or node) from the document.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found