docat-org / docat

Host your docs. Simple. Versioned. Fancy.
MIT License
796 stars 49 forks source link

Add support for https://lunrjs.com/ search index #527

Open randombenj opened 1 year ago

randombenj commented 1 year ago

It would be nice to have search across projects, to support this let's have a look at lunrjs as it seems to be the default frontend search thingy.

goerks commented 5 months ago

Hi @randombenj, I like this approach.

We are using the Hugo static website generator based on markdown documents. We use the Relearn Hugo theme which is shipped with the lunrjs search engine. Therefore each Hugo documentation has a index.search.js containing the prebuilt search index.

var relearn_search_index = [
  {
    "content": " Documentation as Code You should write the documentation ...,
    "description": "Explains the principle of Documentation as Code.",
    "tags": null,
    "title": "Documentation as Code",
    "uri": "/training/advanced/docs-as-code/index.html"
  },
  ...
]

Minimal setup

Advanced setup

randombenj commented 5 months ago

@goerks We tried to implement search multiple times now, unfortunately it seems to be a harder problem than it looks ...

@reglim Is this something we looked into when you tried to implement search?

reglim commented 5 months ago

@randombenj Yes I did. I think this idea was dropped first of all because to serve the pre-built index it would need to be built in the backend which is not in JavaScript but Python. Also, Lunr doesn't allow you update an existing index, which would mean that it would have to be rebuilt completely every time something is updated.

An alternative could be elasticlunr that allows you to update documents, but that still has the issue of building it in the backend.

Also, in my testing, extracting all the text from the uploaded zip files can also be quite expensive.