-
Notifications
You must be signed in to change notification settings - Fork 25.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add lunr-gr.js and fix lunr-en.js #1445
Conversation
nickgarlis
commented
Jan 3, 2018
This looks good to me. Question on stemmers. Is it your intention to add ones from that repo you shared before? Or does it make sense to provide some documentation and how to build one, and then others provide PR's or their own as needed? |
@mmistakes It would make sense but I personally find stemmers kind of complicated to make. I forgot to mention that I got the Greek one from this repository. I am planning on adding the ones from lunr-languages however, I haven't tried using them yet. |
I'm going to partially roll this one back. If the user sets their locale to one we don't support (which currently is a lot except <script src="{{ '/assets/js/lunr-' | append: lang | append: '.js' | absolute_url }}"></script> Example: locale: es-ES Will produce and fail. <script src="{{ '/assets/js/lunr-es.js' }}"></script> Not sure if there is a clean way of only appending Might have to go back to drawing board on this one. How bad is Lunr's search without using any of the language/stemm stuff? Can we get away with just going vanilla? The theme does support overriding the scripts, so in theory we provide a basic English version. And if you're competent enough you build your own language version as you have and load that instead. I'm most interested in making the theme as simple as possible. It should be something where you install the theme and that's it. Anything involving complicated configs and other nonsense is out. I've already failed at that in a few places... cough cough archives. |
Came up with something by using Liquid's {% if site.search == true or page.layout == "search" %}
{% assign lang = site.locale | slice: 0,2 | default: "en" %}
{% case lang %}
{% when "gr" %}
{% assign lang = "gr" %}
{% else %}
{% assign lang = "en" %}
{% endcase %}
<script src="{{ '/assets/js/lunr.min.js' | absolute_url }}"></script>
<script src="{{ '/assets/js/lunr-' | append: lang | append: '.js' | absolute_url }}"></script>
{% endif %} |
@mmistakes Oops I forgot to set the default value.... Your solution looks great to me I totally missed that scenario. As far as languages are concerned, Lunr doesn't work at all with Greek or any other non-latin alphabet by default. Languages that use latin characters might work but not well enough since they are most likely to use some extra characters too. |
@mmistakes Ok so while I was experimenting with Russian, I came to the conclusion that Stemmers, are useful but not as necessary as I presented them to be. So my sincere apologies for that. I will try to explain what is going on. First of all it was Lunr trimmer that blocked non-latin characters. While we were using Things are a bit different now because we use
Which means that:
Simply put, stemming is only useful in exact matching |
That makes sense. I'm cool simplifying things and leaving out the stemmers. Search is a tricky thing which is why I held off for a long time adding it, knowing there would be a lot of nuance to it and/or users having different needs and expectations with it. Whatever we can do to give a good vanilla experience that covers the basics and worry less about edge cases I'm all for that. If someone wants to enhance search and tweak the priorities they can do that by overriding the scripts or using one of the other search providers we'll eventually support. |
@mmistakes I guess we can start messing with Algolia now |
@nickgarlis I'll need a good rainy day for that 😄. I tried quickly to test it out with my own personal site, but it's so big it hit their free tier limits so I gave up. |
@mmistakes hahahah thankfully I have got plenty of those where I live 😜 |
* Remove Lunr trimmer & bring back colons * Add Greek Stemmer * Translate `search_placeholder_text` and `results_found` to Greek
* Remove Lunr trimmer & bring back colons * Add Greek Stemmer * Translate `search_placeholder_text` and `results_found` to Greek
* Remove Lunr trimmer & bring back colons * Add Greek Stemmer * Translate `search_placeholder_text` and `results_found` to Greek