manastech / middleman-search

LunrJS-based search for Middleman
MIT License
58 stars 31 forks source link

search_lunr_js_pipeline not defined #20

Closed eemi closed 7 years ago

eemi commented 7 years ago

Hey guys!

When retrieving the data file (search.json), I got this error in the console: Cannot load un-registered function: stopWordFilter-es. I didn't add the function myself, but I guess it was done automatically when setting es as the language.

So, I created a deregister.js.erb file with this content <%= search_lunr_js_pipeline %> and loaded it before retrieving the data file as specified in your readme. The issue is that the method doesn't seem to exist, this is what I getting in the console:

throw Error("NameError: undefined local variable or method `search_lunr_js_pipeline' for #<#<Class:0x007fdfad03c818>:0x007fdfa4fccef8>\n on line 1 of /Users/emi/Documents/ANSES/code/site/source/assets/js/deregister.js.erb)")

What I'm doing wrong?

Im using Middleman 4.1.10 and middleman-search (0.9.0)

Kind regards

matiasgarciaisaia commented 7 years ago

Hi, @eemi!

Thanks for the feedback :) It helped me realize we were testing the indexing of the gem, but not the actual use of the index - so I tried that.

The error you see is because the client code is not loading lunr's stemmer support & custom language stopword filters. We did that during the index generation, but it was missing from the client code.

So I've just updated the README to reflect this - let me know if that works. It's getting a bit verbose - I'm not sure if we could make the extension work out this requires -, but it should do the trick.

Once again, thanks for pointing this out.

Cheers!

eemi commented 7 years ago

@matiasgarciaisaia thank you very much! It's working flawlessly.