1

I'm trying to create a search feature for my website, so I'm using lunr.js and it requires me to create an index and when I want to search, to load that index and search using it.

So, after I create my index, I need to convert it to JSON and load it later when I need to use it. I was thinking of using localStorage, so I save it in localStorage. But when I try to load the index back, it gives me a "cannot load un-registered function: undefined"

Relevant code:

var savedIndex = index.toJSON();
var workingLoad = lunr.Index.load(savedIndex);
console.log(workingLoad);

// Put the object into storage
localStorage.setItem('savedIndex', JSON.stringify(savedIndex));

var data = localStorage.getItem('savedIndex');
var nonWorkingLoad = lunr.Index.load(data); //Error here
Oliver Nightingale
  • 1,805
  • 1
  • 17
  • 22
Homerdough
  • 353
  • 1
  • 3
  • 12

0 Answers0