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

Add simple (optional?) search feature to documentation pages #447

Closed
5 tasks done
caendesilva opened this issue May 22, 2022 · 1 comment · Fixed by #459
Closed
5 tasks done

Add simple (optional?) search feature to documentation pages #447

caendesilva opened this issue May 22, 2022 · 1 comment · Fixed by #459
Assignees

Comments

@caendesilva
Copy link
Member

caendesilva commented May 22, 2022

While more complex sites probably (and should) use Algolia, it would be nice to ship something lightweight for smaller projects. I wrote something similar for Laradocgen which actually worked pretty nice.

Basically, when compiling the site, create a search index with the post descriptions, title, and slug, save it as a JSON file, then create a clientside search script to pull the data.

@caendesilva
Copy link
Member Author

caendesilva commented May 29, 2022

Some quick benchmarks for the search index generation. Using PHP 8 CLI, with Xdebug enabled. 16 cores @ 3.60 GHz.

The dataset:

100 Markdown files of randomized lorem ipsum Markdown, the files used can be found here https://github.com/caendesilva/RandomDatasets/tree/master/MarkdownPostsWithYAMLFrontMatter.

Each file is 4.79KB on average, however the size between files varies by design.

It took 5,444.42ms to generate a search index for all 100 files. The resulting JSON file is 439KB and contains 449625 characters.

Here is a table for how long various search queries take using Chrome 101 on the same machine.

term result count pages containing term processing time (ms)
[space] 63152 100 45.1
test 44 38 4
foo 11 9 2.7
lorem 196 100 9.7
lorem markdownum postes 1 1 0.7

As you can see, more specific terms with fewer matches are much faster. Overall, it is buttery smooth and feels like it is
in realtime, even for a massive search index like this where the compiled site is almost 3MB total with over 60 thousand words. On Safari on an iPhone 6s the processing times are around 3 times slower, on a Chromebook they are around 2 times slower. I cannot notice the difference.

caendesilva pushed a commit that referenced this issue Aug 28, 2022
…ydesemanticdocs

Rename HydeSmartDocs to SemanticDocumentationArticle hydephp/develop@25de138
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant