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

Support local search #776

Closed
yanzhiwei147 opened this issue Jun 15, 2018 · 75 comments
Closed

Support local search #776

yanzhiwei147 opened this issue Jun 15, 2018 · 75 comments
Labels
feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future.

Comments

@yanzhiwei147
Copy link

Is this a bug report?

NO

Have you read the [Contributing Guidelines on issues]

YES

Environment

None

Steps to Reproduce

None

Expected Behavior

None

Actual Behavior

None

Reproducible Demo

None

Request new feature

I have a website in my intranet, it generated use gitbook. Now i perfer to use the excellent website generator, and deprecated gitbook. But the tool miss local search capability while migrate process. So we have possible to provide local search(like hexo next theme)?

@endiliey endiliey added feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. difficulty: advanced Issues that are complex, e.g. large scoping for long-term maintainability. RFC labels Jun 17, 2018
@cuongnv-ibl
Copy link

Do you mean Algoria Search locally ?

@ntlex
Copy link

ntlex commented Jun 20, 2018

In my company we are looking for a similar solution using Lunrjs, where you can simply index your article locally. At the moment it looks pretty impossible to workaround reactjs and extend the navigation bar to allow the search field to appear without an algolia setup.

@endiliey
Copy link
Contributor

endiliey commented Jun 20, 2018

@ntlex
Hmm, thats a good point. It is indeed not possible to extend the navigation bar to allow your own search field (if not algolia) to appear without submitting a PR to Docusaurus itself.

Things will change in Docusaurus v2 though 😊.

@ntlex
Copy link

ntlex commented Jun 20, 2018

@endiliey when is Docusaurus v2 coming ?

@JoelMarcey
Copy link
Contributor

@ntlex Hi. We are in the planning stages now.

@altafakhai
Copy link

We have been evaluating a few tools to generate an internal help system in our company. The help system will be hosted behind the firewall and will not be exposed to public. To use the search feature, we need to have Algolia enabled, which wants the site to be public. Is there a way we can use the Search feature without Algolia? I really like Docusaurus and want to go ahead with it. However, the Search limitation is pulling us back. Will there be an immediate solution to this?

@JoelMarcey
Copy link
Contributor

Hi @altafakhai - I think we just responded to your tweet as well. We do not have a simple mechanism to support search behind a firewall at this point. We are looking at options for v2. There is probably a way to embed a search feature on your custom pages, but that is not optimal, of course.

I believe that Algolia has an offline feature, but I have never used it and I don't think it would easily integrate in the current version of Docusaurus.

cc: @s-pace

@s-pace
Copy link

s-pace commented Jun 20, 2018

👋 @altafakhai

You can use DocSearch on your internal network if you run it on your own. You will need to create your own configuration and then run it. We do not feature login so far but we are PR welcome. It is based on top of scrapy

You can inspire the configuration from the Docusarus's one.

Happy to help if you need anything else.

@endiliey
Copy link
Contributor

@s-pace I have a question.

If we run the scraper on our own, it will still push the the crawled results to the Algolia index (which is not our own network), and it's not "offline" search. Its just not requiring the website to be publicly accessible (as in to be crawled).

Is this correct ?

@s-pace
Copy link

s-pace commented Jun 20, 2018

@endiliey Indeed.

You can still use algolia offline but regarding the use-case, it is what we will recommend.

@yanzhiwei147
Copy link
Author

yanzhiwei147 commented Jun 21, 2018

Thank everyone provide so much suggests. Now i express my solution:

  1. Generate the index.xml to root directory while build website.
  2. Add search bar on website.
  3. Search from index.xml when search bar text input or change.

Information for your reference.

@altafakhai
Copy link

Thanks for the help, @JoelMarcey @s-pace

I will try to work with DocSearch and see if we get the desired results. Will keep you all posted with the progress.

Eagerly waiting for v2. 😃

@JoelMarcey
Copy link
Contributor

@sbansal3096 is planning to work on this either for v1 or v2.

@endiliey @yangshun - are we planning on offering a local search implementation for v2. Or just a pluggable infrastructure for search?

@endiliey
Copy link
Contributor

Just pluggable search box. I think he can try it on v1, the main implementation part is on building the docs index.

@JoelMarcey
Copy link
Contributor

I think he can try it on v1, the main implementation part is on building the docs index.

@endiliey Do you mean he should only index *.md files and not worry about trying to index React pages, etc? If so, I think that is ok. I think @sbansal3096 should use an off the shelf indexer like lunr.js and run with that.

@cryptoads
Copy link

Any update on this?

@pauljamescleary
Copy link

Any update? Currently looking at static site generators for documentation. Like most things about Docusaurus except for the search. This is a nice project :)

@the-darc
Copy link

the-darc commented Apr 8, 2019

I have the same issue here on a Internal project and solved it with a server side search using @weixsong/elasticlunr.js.

I would like to send a PR with this solution at some time. But Unfortunately I do not have time to do it right now. For now it is available in @the-darc/Docusaurus.

@cryptoads
Copy link

Just implemented your fix. Looks good!! Cheers.

@haslam22
Copy link

+1 Local search would be an amazing addition. My use case is that I'd like to use Docusaurus for documentation hosted on an intranet and I can't pass any information to a third-party.

@endiliey endiliey removed the RFC label May 17, 2019
@danforbes
Copy link

@JoelMarcey any chance someone could take a peek at the above?

@slorber
Copy link
Collaborator

slorber commented Jun 10, 2020

@danforbes I can help you.

Let's talk about your migration on your repo (can you open an issue or PR and ping me?) or on Discord instead.

@danforbes
Copy link

Thank you, @slorber! Are you able to add comments to this commit in GitHub?

@danforbes
Copy link

@danforbes
Copy link

@slorber I've also created a draft PR substrate-developer-hub/substrate-developer-hub.github.io#563

@dhitimedin
Copy link

I have the same issue here on a Internal project and solved it with a server side search using @weixsong/elasticlunr.js.

I would like to send a PR with this solution at some time. But Unfortunately I do not have time to do it right now. For now it is available in [@the-darc/Docusaurus](https://github.com/the-darc/Docusaurus

I am looking for local search support for Hindi language. Any suggestions or a sulution?

@lelouch77
Copy link

@dhitimedin You can make use of this MihaiValentin/lunr-languages#6

@dhitimedin
Copy link

dhitimedin commented Sep 20, 2020

@ lelouch77 When I try to do that I get series of warnings. While running "npm run swizzle docusaurus-lunr-search SearchBar", I get exception.

Trace pasted below:

npm WARN deprecated mkdirp@0.3.0: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN @cmfcmf/docusaurus-search-local@0.3.0 requires a peer of @docusaurus/core@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @docusaurus/plugin-content-pages@2.0.0-alpha.62 requires a peer of @docusaurus/core@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @docusaurus/plugin-debug@2.0.0-alpha.62 requires a peer of @docusaurus/core@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @docusaurus/plugin-google-analytics@2.0.0-alpha.62 requires a peer of @docusaurus/core@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @docusaurus/plugin-google-gtag@2.0.0-alpha.62 requires a peer of @docusaurus/core@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @docusaurus/plugin-sitemap@2.0.0-alpha.62 requires a peer of @docusaurus/core@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @docusaurus/preset-classic@2.0.0-alpha.62 requires a peer of @docusaurus/core@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @docusaurus/theme-classic@2.0.0-alpha.62 requires a peer of @docusaurus/core@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @docusaurus/theme-search-algolia@2.0.0-alpha.62 requires a peer of @docusaurus/core@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN docusaurus-lunr-search@2.1.7 requires a peer of @docusaurus/core@^2.0.0 but none is installed. You must install peer dependencies yourself.

Component "SearchBar" doesn't exists. "SearchBar" is swizzled instead of "SearchBar".
Error: SearchBar is an internal component, and have a higher breaking change probability. If you want to swizzle it, use the "--danger" flag.

@praveenn77
Copy link

@dhitimedin Thats happens on version of dosucarus ... Try running npm run swizzle docusaurus-lunr-search SearchBar --- --danger Thanks

@slorber
Copy link
Collaborator

slorber commented Sep 29, 2020

These swizzle error messages are tracked in #3408
It's definitively a bug but you should be able to swizzle using the --danger cli flag

@weareoutman
Copy link
Contributor

Hi everyone, I just created https://github.com/easyops-cn/docusaurus-search-local, which is originally forked from cmfcmf/docusaurus-search-local, but later fully rewritten to reach our goal: up to date, maintainable, robustness, pretty look, and mostly language of Chinese supported. We have already using it in our production (but not public, that's why we need local search, : ).).

@dhitimedin
Copy link

https://github.com/easyops-cn/docusaurus-search-local

Great! I will try right away. Does it support Hindi as a language?

@dhitimedin
Copy link

Hi everyone, I just created https://github.com/easyops-cn/docusaurus-search-local, which is originally forked from cmfcmf/docusaurus-search-local, but later fully rewritten to reach our goal: up to date, maintainable, robustness, pretty look, and mostly language of Chinese supported. We have already using it in our production (but not public, that's why we need local search, : ).).

UI does not work properly on mobile.

@weareoutman
Copy link
Contributor

@dhitimedin Hope it will help you. It currently supports all lunr-languages + Chinese, but Hindi is not in it yet.

I actually have not tested it with mobile devices. But it can be fixed easily by apply css media queries. I'll fix it later.

@dhitimedin
Copy link

@dhitimedin Hope it will help you. It currently supports all lunr-languages + Chinese, but Hindi is not in it yet.

I actually have not tested it with mobile devices. But it can be fixed easily by apply css media queries. I'll fix it later.

Great! Would be helpful. My users use my site mostly from mobile. Do keep me posted on the steps required to rectify.

@dhitimedin
Copy link

Hi everyone, I just created https://github.com/easyops-cn/docusaurus-search-local, which is originally forked from cmfcmf/docusaurus-search-local, but later fully rewritten to reach our goal: up to date, maintainable, robustness, pretty look, and mostly language of Chinese supported. We have already using it in our production (but not public, that's why we need local search, : ).).

Getting the following error while installing it:

node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://github.com/yanyiwu/nodejieba/releases/download/2.4.1/nodejieba-v2.4.1-node-v72-darwin-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not found for nodejieba@2.4.1 and node@12.18.0 (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.

gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: gyp failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 19.5.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/nishit/Documents/GitHub/docusaurus3/node_modules/nodejieba/build/Release/nodejieba.node" "--module_name=nodejieba" "--module_path=/Users/nishit/Documents/GitHub/docusaurus3/node_modules/nodejieba/build/Release" "--napi_version=6" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"
gyp ERR! cwd /Users/nishit/Documents/GitHub/docusaurus3/node_modules/nodejieba
gyp ERR! node -v v12.18.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/nishit/Documents/GitHub/docusaurus3/node_modules/nodejieba/build/Release/nodejieba.node --module_name=nodejieba --module_path=/Users/nishit/Documents/GitHub/docusaurus3/node_modules/nodejieba/build/Release --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
node-pre-gyp ERR! stack at ChildProcess. (/Users/nishit/Documents/GitHub/docusaurus3/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:315:20)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
node-pre-gyp ERR! System Darwin 19.5.0
node-pre-gyp ERR! command "/usr/local/bin/node" "/Users/nishit/Documents/GitHub/docusaurus3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/nishit/Documents/GitHub/docusaurus3/node_modules/nodejieba
node-pre-gyp ERR! node -v v12.18.0
node-pre-gyp ERR! node-pre-gyp -v v0.14.0
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/nishit/Documents/GitHub/docusaurus3/node_modules/nodejieba/build/Release/nodejieba.node --module_name=nodejieba --module_path=/Users/nishit/Documents/GitHub/docusaurus3/node_modules/nodejieba/build/Release --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nodejieba@2.4.1 install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nodejieba@2.4.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/nishit/.npm/_logs/2020-10-21T08_08_50_492Z-debug.log

@weareoutman
Copy link
Contributor

@dhitimedin I think this is not the right place to trouble shooting this error. Could you please fire an issue at easyops-cn/docusaurus-search-local?

@weareoutman
Copy link
Contributor

@dhitimedin I just moved nodejieba from dependencies to peerDependencies (which is only required for language of zh), and a new version has published (v0.7.0), you can try it. It means that you will not get nodejieba installed by default, and the install error above would be no longer an issue.

For further questions, please fire issues at easyops-cn/docusaurus-search-local, thank you.

@sagarreddypatil
Copy link

Any update on this issue?

@dhitimedin
Copy link

dhitimedin commented Aug 5, 2021 via email

@benhalverson
Copy link

I have a working example of a local search here which uses flexsearch. It's similar to lunrjs
live demo https://staging.nodejs.dev/1677/
I'm not using docusaurus but it uses gatsby

@dhitimedin
Copy link

My local storage works for english. You can check out the site here. https://dhitimedin.github.io/docusaurus3/en/welcome

@dhitimedin
Copy link

Except that it does not work for Hindi

@Josh-Cena Josh-Cena removed the v2 label Oct 30, 2021
@Josh-Cena
Copy link
Collaborator

Closing because there are ample community plugins and there seems to be little interest to bring this into the main repo. If you find any problem working with packages like @easyops-cn/docusaurus-search-local or @cmfcmf/docusaurus-search-local, please report to their repos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future.
Projects
None yet
Development

No branches or pull requests