reyesr / fullproof

javascript fulltext search engine library
http://reyesr.github.com/fullproof/
Apache License 2.0
666 stars 46 forks source link

how to know when injected documents are searchable? #20

Open naknomum opened 11 years ago

naknomum commented 11 years ago

i am a little confused, so my apologies if this is covered in the docs somewhere. i am inserting text into a fullproof search engine and the callback for injectDocument() is getting called. however when i try to do a lookup() on a word in the document it can take several minutes before it actually comes back with a match. (until then, the result set is false.) my questions are:

  1. is this long wait while it is actually building the index?
  2. if so, is there a way to speed it up (the text is only a few hundred words long)
  3. is there a callback i can set somewhere for when the entire index is ready to be searched?

here is what my code looks like:

searchEngine.injectDocument(text, node.id, function() { _doneIndexing(node); });

and the results, from console (each attempt was done about 15 sec apart):

booker.search('bluff');
undefined
nope! popup.js:312
booker.search('bluff');
undefined
nope! popup.js:312
booker.search('bluff');
undefined
nope! popup.js:312
booker.search('bluff');
undefined
fullproof.ResultSet {comparatorObject: Object, data: Array[1], last_insert: "7", insert: function, merge: function…}
 popup.js:309

(the function _doneIndexing() is called almost immediately after the inject happens, for what it is worth.) i wonder if it has to do with me doing multiple iterations of injecting documents? i step through dozens of nodes in a loop and inject the text content from each via the above method. i am trying to discern why i am getting these long delays and some strange lookup results.

thanks! -jon