-
Notifications
You must be signed in to change notification settings - Fork 976
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
The integrated elasticlunr search can't work with language zh #1349
Comments
Chinese/Japanese search has been disabled by default in https://github.com/getzola/zola/blob/master/components/search/Cargo.toml#L8 because it inflated the binary size a lot (I guess shipping a dictionary or something? The binary went up to something like 90MB when they were included). Elasticlunr is definitely not the best solution when you have a lot of data. Does Algolia have some defined data format they need? |
@Keats https://www.algolia.com/doc/guides/sending-and-managing-data/prepare-your-data/
|
I have the same issue with italian language:
I really don't get why this is happening. I tried with Any ideas? |
Oh, I got it: it's all explained in the official documentation of elasticlunr. Language support requires two more js files as explained here. Anyone can add the files this way:
Better deferring:
We could add this to zola docs, maybe. |
Hmm I'm not using those in the docs? https://github.com/getzola/zola/blob/master/docs/templates/index.html#L105-L107 Ah it looks required for languages other than English? |
Yes, those files are are mandatory for other languages. I extended my theme like this: {% if config.build_search_index %}
<script src="{{ get_url(path='assets/js/search.js', trailing_slash=false) | safe }}"></script>
<script defer src="{{ get_url(path='elasticlunr.min.js', trailing_slash=false) | safe }}"></script>
{%- if config.default_language or config.default_language != "en" -%}
{%- set search_index_file = "search_index." ~ config.default_language ~ ".js" %}
{%- set lunr_lang_file = "assets/js/lunr-languages/lunr." ~ config.default_language ~ ".min.js" -%}
<script defer src="{{ get_url(path='assets/js/lunr-languages/lunr.stemmer.support.min.js', trailing_slash=false) | safe }}"></script>
<script defer src="{{ get_url(path=lunr_lang_file, trailing_slash=false) | safe }}"></script>
<script defer src="{{ get_url(path=search_index_file, trailing_slash=false) | safe }}"></script>
{%- else -%}
<script defer src="{{ get_url(path='search_index.en.js', trailing_slash=false) | safe }}"></script>
{%- endif -%}
{% endif %}
{% endmacro script %} Here the commit with the new assets for my theme. I can make a pull request with all the useful changes. |
@mr-chrome can you do a PR fo the docs? |
I've the same issue and fix that in my blog. use this one , https://blog.gaxxx.me/js/lunr.zh.js , modified from MihaiValentin's version remember to add lunr.stemmer.support.js as well, something like this <script src="https://blog.gaxxx.me/js/elasticlunr.min.js"></script> Hope this could help you out. |
Spend an hour just to decide to use Zola or Docosaurus. The only reason not to choose Zola is the docsearch support. I saw some projects also had similar issue codewars/docs#248 Will Zola support Algolia Docsearch? |
I would take a PR to emit the search index data in the algolia format instead of elasticlunr |
Can someone interested open either a new issue or a PR for the Algolia support? I'll close that one once the docs are updated to fix the original issue. |
|
Bug Report
Hello, I'm a Chinese user and fresh to
Zola
. According to the document, I build aZola-zh
from source (tag v0.13.0) locally to enable Chinese index. And I'm using a theme DeepThought which already support search function. However the javascript code runs error.There are some bad things for
elasticlunr
.10,000
short Chinese articles locally and the build progress even hanged.Is there any idea to support other search service like algolia?
Zola
can just generate a simple structured json data filled with page title, content, tags and so on. Then on the user side, we import the json data to suitable search service using a deploy script or manually...Thanks :d
The text was updated successfully, but these errors were encountered: