Closed piranna closed 11 years ago
Good catch. There should definitely be a check that a document with that reference already exists before trying to remove it.
The document store already has a method for checking whether or not a ref exists, it just isn't being used here. A fix should just be a case of checking the documentStore
for the docRef
before retrieving the docTokens
.
if (!this.documentStore.has(docRef)) return
Feel free to open a pull request with a fix for this if you want, don't worry about updating the docs or the build, you should be able to add a test to test/index_test.js
and add your fix in lib/index.js
. Either that or I'll make a fix tomorrow and push a new version.
Ok, I'll try to take a look on it.
2013/4/24 Oliver Nightingale notifications@github.com
Good catch. There should definitely be a check that a document with that reference already exists before trying to remove it.
The document store already has a method for checking whether or not a ref exists, it just isn't being used here. A fix should just be a case of checking the documentStore for the docRef before retrieving the docTokens.
if (!this.documentStore.has(docRef)) return
Feel free to open a pull request with a fix for this if you want, don't worry about updating the docs or the build, you should be able to add a test to test/index_test.js and add your fix in lib/index.js. Either that or I'll make a fix tomorrow and push a new version.
— Reply to this email directly or view it on GitHubhttps://github.com/olivernn/lunr.js/issues/22#issuecomment-16963869 .
"Si quieres viajar alrededor del mundo y ser invitado a hablar en un monton de sitios diferentes, simplemente escribe un sistema operativo Unix." – Linus Tordvals, creador del sistema operativo Linux
Hey, hows it going with your patch? Let me know if you don't have the time to do it and I'll make the change…
Sorry, I've been busy this days :-/ If required I can do it this afternoon...
By the way, the search engine is working great on my app ;-) El 30/04/2013 17:03, "Oliver Nightingale" notifications@github.com escribió:
Hey, hows it going with your patch? Let me know if you don't have the time to do it and I'll make the change…
— Reply to this email directly or view it on GitHubhttps://github.com/olivernn/lunr.js/issues/22#issuecomment-17232660 .
No massive rush, just wanted to make sure you were still keen on contributing a patch. Glad lunr is working well for you!
I've just send you a pull request from my project account ;-)
This has been fixed in version 0.3.1
When trying to remove a document from the index that the ID doesn't exists (maybe because an automatic clean-up) it raise an error because this case is not check:
If the document doesn't exists, docTokens get null, so the forEach method fails. I think it should be checked and if so, ignored.