Closed mnemanja closed 6 years ago
It looks like you are using Lunr 2.x which no longer supports adding documents to an index after it has been built (more info in the upgrading guide).
That said it looks like you are working around this by rebuilding the index every time you want to add a file to it. At a glance it looks like you call resetIndex
before doing the search, which doesn't actually add any files to the index. I think the problem then is in how you are creating the index before searching, you would need to ensure that all the files you want to search are being added to the index.
You can help debug the issue by checking if the index is empty in you find
function:
index.tokenSet.toArray()
The above will return all the words that are in the index, if this is empty the either you didn't add anything to the index when building it, or the field object you did add to the index had no words.
Hopefully this helps you get to the bottom of the problem, let me know if you manage to come good on this.
P.S. Paul was a colleague of mine when I worked in London, great guy. Hope you are enjoying his book!
Thanks for your response. I'll close this issue since I'm no longer working on this.
Hello, I'm following the tutorial from this book https://www.manning.com/books/cross-platform-desktop-applications.
They are using the old API, so I've tried using the new one but it does not work for me.
I cannot confirm if search and add exist from the perspective of API. I'm not sure how to debug it. Any thoughts?