Skip to content
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

Search: default Sphinx's search doesn't work when I search Chinese or Janpanese #397

Closed
lucays opened this issue Oct 8, 2024 · 4 comments
Labels
Needed: more information A reply from issue author is required

Comments

@lucays
Copy link

lucays commented Oct 8, 2024

After addons is enabled, default Sphinx's search doesn't work when I search Chinese:
https://ocg-rule.readthedocs.io/zh-cn/latest/search.html?q=%22%E6%8A%80%E8%83%BD%E6%8A%BD%E5%8F%96%22

or Japanese: https://ocg-rule.readthedocs.io/zh-cn/latest/search.html?q=%22%E3%82%AF%E3%82%A4%E3%83%83%E3%82%AF%E3%82%A8%E3%83%95%E3%82%A7%E3%82%AF%E3%83%88%22

but works normally when I search English:
https://ocg-rule.readthedocs.io/zh-cn/latest/search.html?q=%22quick%22

I can confirm default Sphinx's search can search Chinese or Japanese normally before.

And, addon search api can search Chinese or Japanese:
https://ocg-rule.readthedocs.io/_/api/v3/search/?q=project%3Aocg-rule%2Flatest+%E6%8A%80%E8%83%BD%E6%8A%BD%E5%8F%96
https://ocg-rule.readthedocs.io/_/api/v3/search/?q=project%3Aocg-rule%2Flatest+%E3%82%AF%E3%82%A4%E3%83%83%E3%82%AF%E3%82%A8%E3%83%95%E3%82%A7%E3%82%AF%E3%83%88
image
image

just default Sphinx's search doesn't work.
I have reviewed the changelog and issues, but still don't know how to fix it.

Or, does the addon search provide a URL somewhere? like this: #21 (comment)
Thanks!

@humitos
Copy link
Member

humitos commented Oct 8, 2024

When performing a search on your project using default Sphinx's search, I see a Javascript error in the console saying that jQuery is not present. The call is done in a custom.js file which I guess is something from the project wrote.

Have you updated your Sphinx version recently? Note that newer versions don't install Sphinx by default, so you should install https://pypi.org/project/sphinxcontrib-jquery/ -- could you try installing that extension?

Read the Docs doesn't have control over the default Sphinx's search anymore. We stopped manipulating that code starting on October 7th, 2024. The error you are seeing should be related to Sphinx only.

And, addon search api can search Chinese or Japanese:

Great! This is what we 100% control 💯

does the addon search provide a URL somewhere? like this: #21 (comment)

Nope, we don't provide a link to a direct search using our addons yet as you figured it out 😄

@humitos humitos added the Needed: more information A reply from issue author is required label Oct 8, 2024
@lucays
Copy link
Author

lucays commented Oct 8, 2024

When performing a search on your project using default Sphinx's search, I see a Javascript error in the console saying that jQuery is not present. The call is done in a custom.js file which I guess is something from the project wrote.

Have you updated your Sphinx version recently? Note that newer versions don't install Sphinx by default, so you should install https://pypi.org/project/sphinxcontrib-jquery/ -- could you try installing that extension?

Read the Docs doesn't have control over the default Sphinx's search anymore. We stopped manipulating that code starting on October 7th, 2024. The error you are seeing should be related to Sphinx only.

And, addon search api can search Chinese or Japanese:

Great! This is what we 100% control 💯

does the addon search provide a URL somewhere? like this: #21 (comment)

Nope, we don't provide a link to a direct search using our addons yet as you figured it out 😄

Thanks, so it's because Sphinx search doesn't support Chinese search itself, and readthedocs search covered this result before.

Now I added html_search_language and html_search_options to conf.py:
https://stackoverflow.com/questions/57221406/why-no-search-result-for-the-cjkchinese-word-in-pythons-documentation-generat
https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_search_language

html_search_language = "zh"
package_path = [i for i in sys.path if 'site-packages' in i][0]
dict_path = os.path.join(package_path, 'jieba/dict.txt')
print('jieba dict path:', dict_path)
html_search_options = {'dict': dict_path}

image

But it still don't work.

I'll look it up myself again. Anyway, now I know the reason why I can't get result in the search. Thank you!

@lucays
Copy link
Author

lucays commented Oct 8, 2024

Not quite right... It can actually work now, but it's difficult to use...
search: "技能+抽取"
https://ocg-rule.readthedocs.io/zh-cn/jin-da-yin-shi-yong/search.html?q=%E6%8A%80%E8%83%BD+%E6%8A%BD%E5%8F%96&check_keywords=yes&area=default#
It works.
search: "技能", it also works.

search: "技能抽取", it don't work...
https://ocg-rule.readthedocs.io/zh-cn/jin-da-yin-shi-yong/search.html?q=%E6%8A%80%E8%83%BD%E6%8A%BD%E5%8F%96&check_keywords=yes&area=default#

May I ask how to make the search box of the theme directly use the addon search API?
Now I have to click the flyout to use it...

@humitos
Copy link
Member

humitos commented Oct 9, 2024

May I ask how to make the search box of the theme directly use the addon search API?

Yes, if you re-build your documentation with the latest 3.0.1 Read the Docs Sphinx theme, you will get this behavior by default.

@lucays lucays closed this as completed Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needed: more information A reply from issue author is required
Projects
None yet
Development

No branches or pull requests

2 participants