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

TypeSense replacing Algolia #136

Merged
merged 2 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions .github/workflows/docsearch-scraper.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
name: DocSearch Scraper
name: TypeSense DocSearch Scraper

# This workflow periodically updates the search index on Algolia
# This workflow updates the search index on TypeSense every time the main branch changes

on:
workflow_dispatch:

schedule:
# * is a special character in YAML so we have to quote this string
- cron: '41 7 * * *'
- cron: "21 7 * * *"

workflow_run:
workflows: ["FreeSWITCH Docs"]
types:
- completed

jobs:
scraper:
runs-on: ubuntu-latest
container:
image: algolia/docsearch-scraper:latest
env:
APPLICATION_ID: ${{ secrets.ALGOLIA_APPLICATION_ID }}
API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
name: Run docs site scraper

steps:
- name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Run scraper
run: export CONFIG="$(cat algolia.json)"; (cd /root && pipenv install && pipenv run python -m src.index)
shell: bash
run: |
docker run --rm --name ts-scraper -v "${{ github.workspace }}:/tmp/search" \
-e "TYPESENSE_API_KEY=${{ secrets.TYPESENSE_API_KEY }}" \
-e "TYPESENSE_HOST=typesense.signalwire.cloud" \
-e "TYPESENSE_PORT=443" \
-e "TYPESENSE_PROTOCOL=https" \
-e "CONFIG=/tmp/search/typesense.json" \
typesense/docsearch-scraper:0.9.1
22 changes: 22 additions & 0 deletions config/typesense.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
// Replace this with the name of your index/collection.
// It should match the "index_name" entry in the scraper's "config.json" file.
typesenseCollectionName: "freeswitch-docs",

typesenseServerConfig: {
nodes: [
{
host: "typesense.signalwire.cloud",
protocol: "https",
exports: 443,
},
],
apiKey: "3BGfXh8sbHygzha5XXFhFYAbW8Qw5vpT",
},

// Optional: Typesense search parameters: https://typesense.org/docs/0.24.0/api/search.html#search-parameters
typesenseSearchParameters: {},

// Optional
contextualSearch: true,
};
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Restart tomcat, under Ubuntu should be like

point your browser to

http://yourip:port/cdr-logger-x.x/schema
`http://yourip:port/cdr-logger-x.x/schema`

It should return some error message similar to below

Expand All @@ -70,7 +70,7 @@ This indicate, the CDRLogger application properly installed.

Now, to automatically generate database schema, point your browser to :

http://yourip:port/cdr-logger-x.x/schema?type=create
`http://yourip:port/cdr-logger-x.x/schema?type=create`

This will start automatic schema generation. Check your database, it should generate following database table :

Expand Down Expand Up @@ -126,7 +126,7 @@ ALTER TABLE freeswitch_cdr_data OWNER TO postgres;

You can test the application to insert test record, point your browser to :

http://yourip:port/cdr-logger-x.x/schema?type=insert
`http://yourip:port/cdr-logger-x.x/schema?type=insert`

Then check freeswitch\_cdrs table, it should create a sample record.

Expand Down
28 changes: 6 additions & 22 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const darkCodeTheme = Themes.dracula;

/** @type {import('@docusaurus/types').Config} */
const config = {

themes: [
"docusaurus-theme-search-typesense",
],
title: "FreeSWITCH Documentation",
url: "https://developer.signalwire.com",
baseUrl: "/freeswitch/",
Expand Down Expand Up @@ -48,6 +52,7 @@ const config = {
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
typesense: require("./config/typesense"),
navbar: {
//title: "FreeSWITCH Documentation",
logo: {
Expand Down Expand Up @@ -126,28 +131,7 @@ const config = {
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
additionalLanguages: ["lua", "php", "csharp", "ruby", "java", "ini", "bash", "json", "perl", "c"],
},
algolia: {
appId: "2NBPM6ETKJ",
apiKey: "4489aa468117b5bfbcb83f7b0addddc9",
indexName: "freeswitch-docs",
externalUrlRegex: `.*`,
/**
* We need to set this to false, otherwise the query is done with
* default filters such as "docusaurus_tag:docs-default-current", which
* exclude all the content from README.
*
* Look for default facetFilters.
*/
contextualSearch: false,
/**
* We need to disable the searchPage because the results there are not
* accurate (they don't respect the contextualSearch setting value).
*
* Reference: https://github.com/facebook/docusaurus/issues/3805
*/
searchPagePath: false,
},
}
}),

plugins: ["docusaurus-plugin-sass"],
Expand Down
Loading
Loading