Remove() not working with id for documents
See original GitHub issueHello, 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:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@MatteoBassan and @cezarsmpio I found a solution by looking at the source code:
Please change over to the version >= 0.7.x, thanks a lot.