An open API service indexing awesome lists of open source software.

https://github.com/vshn/embedded-search-engine

Search engine meant to be embedded inside a Kubernetes / OpenShift pod running an Antora-generated website.
https://github.com/vshn/embedded-search-engine

vshn-project-ignore

Last synced: 6 months ago
JSON representation

Search engine meant to be embedded inside a Kubernetes / OpenShift pod running an Antora-generated website.

Awesome Lists containing this project

README

        

= Embedded Search Engine

Search engine meant to be embedded inside a Kubernetes / OpenShift pod running an Antora-generated website. Written using https://www.typescriptlang.org/[TypeScript], compiled and run upon start.

== Running Locally

After cloning the repo, run `npm install` to install all the dependencies.

The server runs with this command:

`npm run dev`

== Compiling the Express.js Application

Use the following command to build the production version of the application (in the `dist` folder):

`npm run build`

== Starting the Production Application

Use the following command after compilation:

`npm run start`

== Building the Container Image

Run the following command:

`podman build -t embedded-search-engine .`

A prebuilt container image is available as a package in this project.

== Running the Search Engine Container Image

Use the following command:

`podman run --detach --publish 8081:3000 ghcr.io/vshn/embedded-search-engine`

Test the search engine with a curl command piped to https://stedolan.github.io/jq/[jq]:

`curl http://localhost:8081/search?q=backup&c=20 --silent | jq`

The `c` optional parameter specifies the number of results to return (by default, 10.)

== Indexing the Documentation

For each specific applications, the files `index/files.json` and `index/lunr.json` must be replaced with ad-hoc content extracted from other projects, using the tool in the https://github.com/vshn/antora-indexer-cli[Antora Indexer CLI Tool].

== nginx Configuration

It can be used in a Kubernetes pod, as a secondary container providing search services. The nginx configuration of the main container should redirect all requests beginning with `/search` to this container, for example:

[source]
----
server {
# users are not allowed to listen on privileged ports
listen 8080;
server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
}

# Redirect all searches to the Node.js app
# in the other container of the same pod.
location /search {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
----