docusaurus-search-local icon indicating copy to clipboard operation
docusaurus-search-local copied to clipboard

Does search requires build?

Open Anthony-Gaudino opened this issue 3 years ago • 6 comments

There are other Docusaurus search plugins that only work when the website is built, does this one also requires that the website is built for it to work?

Anthony-Gaudino avatar Nov 25 '21 17:11 Anthony-Gaudino

Currently, yes, it requires build.

weareoutman avatar Dec 04 '21 15:12 weareoutman

How to do that? I'm trying by those commands without effects:

  • npm run build
  • yarn run build

Unfortunately, my search bar is saying: ⚠️ The search index is only available when you run docusaurus build!

RogalaPiotr avatar Jan 11 '22 15:01 RogalaPiotr

OK, I found a solution.

docusaurus-search-local is a fork of docusaurus-search-local there we can find info: "Search does not work in development (i.e., when running yarn start)." >> https://github.com/cmfcmf/docusaurus-search-local

So, if you want run a search, you can:

  1. npm run build
  • after this command you should have new folder "build" in your app
  1. rebiuld your app with "RUN_MODE=production" - this is necessary to run search properly.

In my example, I am using docusaurus app on image: awesometic/docusaurus. The proper setup to re-run container is like this:

docker run -d --name=docusaurus
-p 80:80
-v /config/dir:/docusaurus
-e TARGET_UID=1000
-e TARGET_GID=1000
-e AUTO_UPDATE=true
-e WEBSITE_NAME="awesometic-docs"
-e TEMPLATE=classic
-e RUN_MODE=production
awesometic/docusaurus

I hope this could help someone in the future.

RogalaPiotr avatar Jan 17 '22 14:01 RogalaPiotr

I'm trying by those commands without effects:

  • npm run build
  • yarn run build

The command you were looking for is yarn build.

TysonMN avatar Jan 25 '22 20:01 TysonMN

@Anthony-Gaudino all local search plugins needs to be build.

The sites need to be scanned first and an index being build. This is a given no matter what type of search you have. The only difference between local and online search engines is, that they do this asynchronously. But usually results are not available immediately.

SebastianSchuetze avatar Feb 23 '22 12:02 SebastianSchuetze

  • yarn build to build the static site
  • yarn run serve to serve the static site I have the searchbar working locally with this.

james-s-w-clark avatar Sep 20 '22 12:09 james-s-w-clark

In my case the search is showing no results. I followed the steps below:

  1. DEBUG=search-local:* npm run build
  2. npm run serve

Now, the search bar is also visible and the search-index.json file is also generated within the build folder but when I type something it always shows No results.

The DEBUG logs are also not showing any errors.

kdb13 avatar Jun 22 '23 07:06 kdb13

This issue should be marked closed since the original poster's question has been answered. @KdB13, I have opened a new issue for the empty results bug; feel free to add to it.

techbridgedev avatar Dec 18 '23 17:12 techbridgedev

Closing this, see discussions in https://github.com/facebook/docusaurus/discussions/8283

weareoutman avatar Dec 19 '23 02:12 weareoutman

In my case the search is showing no results. I followed the steps below:

  1. DEBUG=search-local:* npm run build
  2. npm run serve

Now, the search bar is also visible and the search-index.json file is also generated within the build folder but when I type something it always shows No results.

The DEBUG logs are also not showing any errors.

having same issue with my setup too

dakshika avatar Feb 16 '24 08:02 dakshika