### Project Structure After Initial Setup Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/qwik-js-search-bar.md This is the initial project structure after creating a basic Qwik app and installing dependencies. ```plaintext typesense-qwik-search/ ├── node_modules/ ├── public/ │ ├── favicon.svg │ ├── manifest.json │ └── robots.txt ├── src/ │ ├── components/ │ │ └── router-head/ │ ├── routes/ │ │ └── index.tsx │ ├── entry.dev.tsx │ ├── entry.preview.tsx │ ├── entry.ssr.tsx │ ├── global.css │ └── root.tsx ├── .gitignore ├── package.json ├── tsconfig.json └── vite.config.ts ``` -------------------------------- ### Start Typesense Server with Environment Variables Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/29.1/api/server-configuration.md This example shows how to start the Typesense server using environment variables for configuration. Environment variables are prefixed with 'TYPESENSE_' and use CAPS and underscores instead of hyphens. ```bash TYPESENSE_DATA_DIR=/var/lib/typesense TYPESENSE_API_KEY=AS3das2awQ2 ./typesense-server ``` -------------------------------- ### Start Typesense Server (Ubuntu) Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/install-typesense.md Starts the Typesense server service using systemctl. This command is used after installing the .deb package. ```bash sudo systemctl start typesense-server.service ``` -------------------------------- ### Install and Start Typesense via Homebrew Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/install-typesense.md Installs the Typesense server package for macOS using Homebrew and then starts the service. ```bash brew install typesense/tap/typesense-server@{{ $site.themeConfig.typesenseLatestVersion }} brew services start typesense-server@{{ $site.themeConfig.typesenseLatestVersion }} ``` -------------------------------- ### Navigate and Install Dependencies Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/qwik-js-search-bar.md Change into the project directory and install Typesense, the instantsearch adapter, instantsearch.js, and its CSS. ```shell cd typesense-qwik-search npm i typesense typesense-instantsearch-adapter instantsearch.js instantsearch.css ``` -------------------------------- ### Main Server Setup in Go Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/gin-search-api.md This Go code sets up a Gin server, initializes Typesense and PostgreSQL connections, configures CORS, defines API routes, and starts a background sync worker. It's designed to be the main entry point for the application. ```go package main import ( "context" "log" "time" "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" "github.com//typesense-gin-full-text-search/config" "github.com//typesense-gin-full-text-search/routes" "github.com//typesense-gin-full-text-search/search" "github.com//typesense-gin-full-text-search/store" ) func main() { // 1. Load .env and initialize env-dependent package variables config.InitializeEnv() // 2. Create the Typesense client (reads env vars set above) search.InitializeClient() // 3. Connect to PostgreSQL and auto-migrate the schema store.ConnectToDB(context.Background()) // 4. Ensure the Typesense collection exists (idempotent) ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() if err := search.InitializeCollections(ctx); err != nil { log.Fatalf("Failed to initialize collections: %v", err) } router := gin.Default() router.Use(cors.New(cors.Config{ AllowOrigins: []string{"*"}, AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}, AllowHeaders: []string{"Origin", "Content-Type", "Accept", "Authorization"}, ExposeHeaders: []string{"Content-Length"}, AllowCredentials: false, })) router.GET("/ping", func(c *gin.Context) { c.JSON(200, gin.H{"message": "pong"}) }) routes.SetupSearchRoutes(router) routes.SetupBookRoutes(router) // Start background sync worker in its own goroutine. // Without `go`, StartSyncWorker's infinite loop would block router.Run() // from ever being reached. syncConfig := search.DefaultSyncConfig() syncConfig.EnableSoftDelete = true go search.StartSyncWorker(context.Background(), syncConfig) port := config.GetEnv("PORT", "3000") log.Printf("Server starting on port %s", port) log.Printf("Sync worker started with interval: %d seconds", syncConfig.SyncIntervalSec) router.Run(":" + port) } ``` -------------------------------- ### Project Structure after Initial Setup Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/vanilla-js-search-bar.md This is the initial project structure after creating a basic Vite app and installing dependencies. ```plaintext typesense-vanilla-js-search/ ├── node_modules/ ├── public/ │ └── vite.svg ├── src/ │ ├── main.js │ └── style.css ├── .gitignore ├── index.html ├── package-lock.json └── package.json ``` -------------------------------- ### Install Typesense DEB Package (Ubuntu/Debian x64) Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/install-typesense.md Download the DEB package for x64 architecture and install it using apt. Then, start the Typesense server service. ```bash # Download & Install curl -O https://dl.typesense.org/releases/{{ $site.themeConfig.typesenseLatestVersion }}/typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-amd64.deb sudo apt install ./typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-amd64.deb # Start Typesense sudo systemctl start typesense-server.service ``` -------------------------------- ### Download and Install Typesense for Linux (arm64) Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/updating-typesense.md Download the arm64 binary for Linux, extract it, and move it to your PATH. Then, gracefully shut down the existing process and start the new one with the same data directory and API key. ```bash curl -O https://dl.typesense.org/releases/{{ $site.themeConfig.typesenseLatestVersion }}/typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-linux-arm64.tar.gz tar -xzf typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-linux-arm64.tar.gz mv ./typesense-server $PATH_TO_EXISTING_BINARY kill # will gracefully shutdown export TYPESENSE_API_KEY=xyz ./typesense-server --data-dir="$(pwd)"/typesense-data --api-key=$TYPESENSE_API_KEY --enable-cors ``` -------------------------------- ### Install Typesense Server (Windows WSL) Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/install-typesense.md Install the Typesense server package on Windows using WSL. This involves downloading the .deb file and installing it using apt. ```bash wsl curl -O https://dl.typesense.org/releases/{{ $site.themeConfig.typesenseLatestVersion }}/typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-amd64.deb sudo apt install ./typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-amd64.deb
``` -------------------------------- ### Install Dependencies Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/vanilla-js-search-bar.md Navigates to the project directory and installs the required dependencies for search functionality: typesense, typesense-instantsearch-adapter, and instantsearch.js. ```shell cd typesense-vanilla-js-search npm install npm i typesense typesense-instantsearch-adapter instantsearch.js ``` -------------------------------- ### Install Typesense InstantSearch Adapter Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/search-ui-components.md Install the typesense-instantsearch-adapter package using npm to enable InstantSearch.js to connect with Typesense. ```bash $ npm install --save typesense-instantsearch-adapter ``` -------------------------------- ### Start Typesense and PostgreSQL with Docker Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/gin-search-api.md Run Typesense and PostgreSQL services using Docker. Ensure you have Docker installed and create a directory for Typesense data. ```bash mkdir typesense-data # Start Typesense docker run -d -p 8108:8108 \ -v "$(pwd)"/typesense-data:/data \ typesense/typesense:{{ $site.themeConfig.typesenseLatestVersion }} \ --data-dir /data \ --api-key=xyz \ --enable-cors # Start PostgreSQL docker run -d -p 5432:5432 \ -e POSTGRES_USER=postgres \ -e POSTGRES_PASSWORD=password \ -e POSTGRES_DB=typesense_books \ postgres:15 ``` -------------------------------- ### Download and Install Typesense for macOS (Intel) Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/updating-typesense.md Download the amd64 binary for macOS, extract it, and move it to your PATH. Then, gracefully shut down the existing process and start the new one with the same data directory and API key. ```bash curl -O https://dl.typesense.org/releases/{{ $site.themeConfig.typesenseLatestVersion }}/typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-darwin-amd64.tar.gz tar -xzf typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-darwin-amd64.tar.gz mv ./typesense-server $PATH_TO_EXISTING_BINARY kill # will gracefully shutdown export TYPESENSE_API_KEY=xyz ./typesense-server --data-dir="$(pwd)"/typesense-data --api-key=$TYPESENSE_API_KEY --enable-cors ``` -------------------------------- ### Download and Install Typesense for macOS (Apple Silicon) Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/updating-typesense.md Download the arm64 binary for macOS, extract it, and move it to your PATH. Then, gracefully shut down the existing process and start the new one with the same data directory and API key. ```bash curl -O https://dl.typesense.org/releases/{{ $site.themeConfig.typesenseLatestVersion }}/typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-darwin-arm64.tar.gz tar -xzf typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-darwin-arm64.tar.gz mv ./typesense-server $PATH_TO_EXISTING_BINARY kill # will gracefully shutdown export TYPESENSE_API_KEY=xyz ./typesense-server --data-dir="$(pwd)"/typesense-data --api-key=$TYPESENSE_API_KEY --enable-cors ``` -------------------------------- ### Install Typesense Server (Large Page Size Build) Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/install-typesense.md Installs the Typesense server for ARM64 architecture with a 16K system page size. ```bash # Linux Binary curl -O https://dl.typesense.org/releases/{{ $site.themeConfig.typesenseLatestVersion }}/typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-linux-arm64-lg-page16.tar.gz tar -xzf typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-linux-arm64-lg-page16.tar.gz ``` -------------------------------- ### Example Data for `bucket_size` Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/30.2/api/search.md This is an example dataset used to illustrate the behavior of the `bucket_size` parameter. ```json [ {"title": "Mark Antony", "points": 100}, {"title": "Marks Spencer", "points": 200}, {"title": "Mark Twain", "points": 100}, {"title": "Mark Payne", "points": 300}, {"title": "Marks Henry", "points": 200}, {"title": "Mark Aurelius", "points": 200} ] ``` -------------------------------- ### Start Typesense using Docker in GitHub Actions Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/github-actions.md Set up Typesense directly within your GitHub Actions workflow using Docker without external dependencies. This example shows how to specify the Typesense image version, map ports, mount volumes, and configure API keys and analytics. ```yaml name: Run tests on: [push] jobs: build: runs-on: ubuntu-latest strategy: matrix: # versions are wrapped in quotes to preserve the exact versions # especially numbers that has "0" on right-most side (e.g. 26.0) typesense-version: ['28.0', '29.0'] typesense-port: ['8108:8108'] services: typesense: image: typesense/typesense:${{ matrix.typesense-version }} steps: - name: Start Typesense run: | docker run -d \ -p ${{ matrix.typesense-port }} \ --name typesense \ -v /tmp/typesense-data:/data \ -v /tmp/typesense-analytics-data:/analytics-data \ typesense/typesense:${{ matrix.typesense-version}} \ --api-key=xyz \ --data-dir=/data \ --enable-search-analytics=true \ --analytics-dir=/analytics-data \ --analytics-flush-interval=60 \ --analytics-minute-rate-limit=100 \ --enable-cors - name: Wait for Typesense to be healthy shell: bash run: | start_time=$(date +%s) timeout=30 counter=0 echo "Waiting for Typesense to be healthy..." until curl -s http://localhost:8108/health | grep -q '"ok":true'; do if [ $counter -eq $timeout ]; then echo "Timed out waiting for Typesense to be healthy" exit 1 fi sleep 1 counter=$((counter + 1)) done end_time=$(date +%s) elapsed=$((end_time - start_time)) echo "Typesense healthcheck elapsed: ${elapsed}s" ``` -------------------------------- ### Start Docker Compose Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/install-typesense.md Creates a directory for Typesense data and then starts the Typesense service using Docker Compose. ```shell mkdir "$(pwd)"/typesense-data docker-compose up ``` -------------------------------- ### Install Typesense Client Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/natural-language-search.md Install the Typesense client library for your Next.js application using npm. ```shell npm i typesense@next ``` -------------------------------- ### Setup angular-instantsearch in Angular Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/reference-implementations/guitar-chords-search-in-different-js-frameworks.md This snippet shows the basic setup for `angular-instantsearch` in an Angular application's module. ```typescript import { NgAisModule } from 'angular-instantsearch'; @NgModule({ imports: [ BrowserModule, NgAisModule.forRoot('YourAppID', 'YourSearchAPIKey'), ], // ... }) export class AppModule { } ``` -------------------------------- ### Initialize Go Project and Install Dependencies Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/gin-search-api.md Set up a new Go project and install essential libraries for building a web API with Typesense integration. This includes the Gin framework, CORS middleware, Typesense Go client, and GORM with its PostgreSQL driver. ```bash mkdir typesense-gin-full-text-search cd typesense-gin-full-text-search go mod init github.com//typesense-gin-full-text-search go get github.com/gin-gonic/gin go get github.com/gin-contrib/cors go get github.com/typesense/typesense-go/v4 go get github.com/joho/godotenv go get gorm.io/gorm go get gorm.io/driver/postgres ``` -------------------------------- ### Create lib Directory and File Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/next-js-search-bar.md Create the 'lib' directory and the 'instantSearchAdapter.ts' file within it using bash commands. ```bash mkdir -p lib touch lib/instantSearchAdapter.ts ``` -------------------------------- ### Start Typesense Server with a Configuration File Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/29.1/api/server-configuration.md Use this command to start the Typesense server and specify the path to your configuration file. The configuration file allows for a centralized way to manage server settings. ```bash ./typesense-server --config=/etc/typesense/typesense-server.ini ``` -------------------------------- ### Example Field Definition with Regex Name Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/29.1/api/collections.md Defines all fields starting with 'score_' as integers, enabling them for indexing. ```json {"name": "score_.*", "type": "integer", "index": true} ``` -------------------------------- ### Create Components Directory and Files Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/next-js-search-bar.md Create the 'components' directory and necessary component files, including CSS Modules for styling. ```bash mkdir -p components touch components/SearchBar.tsx components/Searchbar.module.css touch components/BookList.tsx components/BookList.module.css touch components/BookCard.tsx components/BookCard.module.css ``` -------------------------------- ### Create Project Structure Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/gin-search-api.md Sets up the necessary directories and files for the Gin and Typesense project. This includes creating folders for configuration, search, store, routes, and models, along with essential Go files and a .env file. ```bash mkdir -p config search store routes models touch config/config.go touch search/client.go search/collections.go search/sync.go search/worker.go touch store/store.go touch models/book.go touch routes/search.go routes/books.go touch server.go .env ``` -------------------------------- ### Nuxt.js Project Structure after Setup Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/nuxt-js-search-bar.md Initial project structure after creating a basic Nuxt.js app and installing dependencies. ```plaintext typesense-nuxt-search-bar/ ├── node_modules/ ├── public/ │ └── favicon.ico ├── server/ │ └── tsconfig.json ├── .gitignore ├── .nuxt/ ├── app.vue ├── nuxt.config.ts ├── package.json ├── README.md └── tsconfig.json ``` -------------------------------- ### Update Typesense on macOS using Homebrew Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/updating-typesense.md Stop the running Typesense service, install the new version using Homebrew, and then start the service again. ```bash brew services stop typesense-server brew install typesense/tap/typesense-server@{{ $site.themeConfig.typesenseLatestVersion }} brew services start typesense-server@{{ $site.themeConfig.typesenseLatestVersion }} ``` -------------------------------- ### Restrict Collection Access Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/data-access-control.md Use the 'collections' parameter to control which collections an API key can access. This example allows access to collections starting with 'contacts_'. ```json { "actions": ["*"], "collections": ["contacts_.*"], ... } ``` -------------------------------- ### Cloning Operation Response Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/cloud-management-api/v1/cluster-cloning.md Example response after starting a cluster cloning operation. It includes the operation ID, status, and details about the source and target configurations. ```json { "success": true, "cloning_operation": { "id": "fbff4b22-23d3-46e8-a599-144b622f4dd4", "status": "pending", "created_at": 1743046821, "updated_at": 1743046821, "completed_at": null, "source_region": "oregon", "target_region": "oregon", "typesense_server_version": "28.0", "target_cluster_reference_id": null, "notification_email_addresses": [ "email@example.com" ] } } ``` -------------------------------- ### Download and Start Typesense (macOS/Linux) Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/install-typesense.md Download the Typesense server binary, extract it, and start the server with specified data directory, API key, and CORS enabled. ```bash # Download Typesense curl -O https://dl.typesense.org/releases/{{ $site.themeConfig.typesenseLatestVersion }}/typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-darwin-amd64.tar.gz tar -xzf typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-darwin-amd64.tar.gz # Start Typesense export TYPESENSE_API_KEY=xyz mkdir "$(pwd)"/typesense-data ./typesense-server --data-dir="$(pwd)"/typesense-data --api-key=$TYPESENSE_API_KEY --enable-cors ``` -------------------------------- ### Activate Ngrok Tunnel Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/supabase-full-text-search.md Starts an Ngrok tunnel to forward traffic from the web to your local Typesense instance running on port 8108. Requires Ngrok to be installed and configured. ```bash ngrok http 8108 ``` -------------------------------- ### Setup instantsearch.js in Vanilla JS with Vite Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/reference-implementations/guitar-chords-search-in-different-js-frameworks.md This snippet shows how to set up `instantsearch.js` in a Vanilla JavaScript project using Vite. ```javascript import instantsearch from 'instantsearch.js'; import { searchBox, hits } from 'instantsearch.js/es/widgets'; const searchClient = { search(requests) { // ... your Typesense client logic ... }, }; const search = instantsearch({ indexName: 'yourIndexName', searchClient, }); search.addWidgets([ searchBox({ container: '#searchbox', }), hits({ container: '#hits', }), ]); search.start(); ``` -------------------------------- ### Filter Array Field by Range Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/tips-for-filtering.md Filter documents where an integer array field contains values within a specified range. This example uses the `[start..end]` syntax for `deparment_prices`. ```shell deparment_prices:[20..80] ``` -------------------------------- ### Get Number of Related Documents Query Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/30.2/api/joins.md Use the 'related_docs_count' parameter to include the count of related documents for a join in the query. This example shows how to specify a custom field name for the count. ```json { "collection": "authors", "q": "*", "filter_by": "$books(id:*)", "include_fields": "$books(*, related_docs_count: foo_related_count)" } ``` -------------------------------- ### Create InstantSearch Adapter File Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/angular-search-bar.md Commands to create the directory and file for the InstantSearch adapter. ```bash mkdir -p src/app/lib touch src/app/lib/instantsearch-adapter.ts ``` -------------------------------- ### Generate Scoped Search Key for Multi-tenancy Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/29.1/api/api-keys.md Generates a scoped search API key with an embedded filter to restrict access to a user's own data in a multi-tenant setup. This example embeds `filter_by` and `exclude_fields` parameters. ```JavaScript key = client.keys.create({ "collections_access": [ { "collection": "my-collection", "params": { "filter_by": "accessible_to_user_ids:=1", "exclude_fields": "accessible_to_user_ids" } } ] }); ``` -------------------------------- ### Download and Prepare Dataset Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/building-a-search-application.md Download the sample dataset and unzip it to prepare for indexing. ```shell cd /tmp curl -O https://dl.typesense.org/datasets/books.jsonl.gz gunzip books.jsonl.gz ``` -------------------------------- ### Include Reference Fields in Document Retrieval Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/29.1/api/joins.md Use the `include_fields` parameter in the GET document API to fetch data from referenced collections. This example shows how to retrieve a book document and include the author's name from the authors collection. ```bash curl -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" -X GET \ "http://localhost:8108/collections/books/documents/1?include_fields=$authors(name)" ``` -------------------------------- ### Start Typesense Server (Linux AMD64) Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/install-typesense.md Download, extract, and start the Typesense server for Linux AMD64 architecture. Ensure to set the API key and data directory. ```bash # Download curl -O https://dl.typesense.org/releases/{{ $site.themeConfig.typesenseLatestVersion }}/typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-linux-amd64.tar.gz tar -xzf typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-linux-amd64.tar.gz
# Start Typesense export TYPESENSE_API_KEY=xyz mkdir "$(pwd)"/typesense-data # Use a directory like /var/lib/typesense in production ./typesense-server --data-dir="$(pwd)"/typesense-data --api-key=$TYPESENSE_API_KEY --enable-cors ``` -------------------------------- ### Create Qwik Project Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/qwik-js-search-bar.md Scaffold a new Qwik project using npm. Choose 'Empty App' for a minimal setup. ```shell npm create qwik@latest ``` -------------------------------- ### Start Typesense Server (Linux ARM64) Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/install-typesense.md Download, extract, and start the Typesense server for Linux ARM64 architecture. Ensure to set the API key and data directory. ```bash # Download curl -O https://dl.typesense.org/releases/{{ $site.themeConfig.typesenseLatestVersion }}/typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-linux-arm64.tar.gz tar -xzf typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-linux-arm64.tar.gz
# Start Typesense export TYPESENSE_API_KEY=xyz mkdir "$(pwd)"/typesense-data # Use a directory like /var/lib/typesense in production ./typesense-server --data-dir="$(pwd)"/typesense-data --api-key=$TYPESENSE_API_KEY --enable-cors ``` -------------------------------- ### Install Typesense GPU Dependencies (Debian/Ubuntu) Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/install-typesense.md Installs the necessary dependencies for Typesense to utilize Nvidia GPUs on Debian/Ubuntu systems. Ensure CUDA and cuDNN are installed first. ```bash # x64 curl -O https://dl.typesense.org/releases/{{ $site.themeConfig.typesenseLatestVersion }}/typesense-gpu-deps-{{ $site.themeConfig.typesenseLatestVersion }}-amd64.deb sudo apt install ./typesense-gpu-deps-{{ $site.themeConfig.typesenseLatestVersion }}-amd64.deb ``` -------------------------------- ### Initialize Typesense Client (Java) Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/29.1/api/authentication.md Set up the Typesense client in Java. This example shows how to define nodes and configuration for the client. ```java import org.typesense.api.*; import org.typesense.models.*; import org.typesense.resources.*; ArrayList nodes = new ArrayList<>(); nodes.add( new Node( "http", // For Typesense Cloud use https "localhost", // For Typesense Cloud use xxx.a1.typesense.net "8108" // For Typesense Cloud use 443 ) ); Configuration configuration = new Configuration(nodes, Duration.ofSeconds(2),""); Client client = new Client(configuration); ``` -------------------------------- ### Start Typesense Container and Configure Client (Java) Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/testcontainers.md Use TypesenseContainer to start a Typesense instance in Docker and configure the Typesense client to connect to it. Ensure the container is started before client configuration. ```java try ( TypesenseContainer typesense = new TypesenseContainer("typesense/typesense:27.1") ) { typesense.start(); List nodes = Collections.singletonList( new Node("http", typesense.getHost(), typesense.getHttpPort()) ); Configuration configuration = new Configuration(nodes, Duration.ofSeconds(5), typesense.getApiKey()); Client client = new Client(configuration); } ``` -------------------------------- ### Create Components Directory and Files Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/astro-search-bar.md Commands to create the components directory and necessary Astro component files. ```bash mkdir -p src/components touch src/components/BookSearch.astro touch src/components/BookCard.astro touch src/components/Heading.astro ``` -------------------------------- ### Project Structure After Creating lib Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/next-js-search-bar.md The project structure after creating the 'lib' directory and 'instantSearchAdapter.ts' file. ```bash typesense-next-search-bar/ ├── lib/ │ └── instantSearchAdapter.ts ├── pages/ │ └── index.tsx ├── public/ │ ├── file.svg │ ├── globe.svg │ ├── next.svg │ ├── vercel.svg │ └── window.svg ├── .eslintrc.json ├── .gitignore ├── next-env.d.ts ├── next.config.ts ├── package-lock.json ├── package.json └── tsconfig.json ``` -------------------------------- ### Example Document with Part Number Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/tips-for-searching-common-types-of-data.md This is an example document structure containing a product identifier. ```json { "title": "Control Arm Bushing Kit", "part_number": "K83913.39F29.59444AT" //... } ``` -------------------------------- ### Create Components Directory and Files Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/solid-js-search-bar.md Commands to create the 'components' directory and associated component files for the search interface. ```bash mkdir -p src/components touch src/components/BookSearch.tsx src/components/BookSearch.module.css touch src/components/BookList.tsx src/components/BookList.module.css touch src/components/BookCard.tsx src/components/BookCard.module.css ``` -------------------------------- ### Typesense Query JSON Example Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/natural-language-search.md Example of a Typesense query format for filtering and sorting. ```json { "filter_by": "make:Ford && msrp:<40000", "sort_by": "year:desc" } ``` -------------------------------- ### Install Search Dependencies Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/solid-js-search-bar.md Installs required dependencies for implementing search functionality in a Solid.js project. ```shell cd typesense-solid-js-search npm install npm i typesense typesense-instantsearch-adapter instantsearch.js ``` -------------------------------- ### Create Types Directory and Book Interface Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/angular-search-bar.md Commands to create the directory and file for the Book interface. ```bash mkdir -p src/app/types touch src/app/types/book.ts ``` -------------------------------- ### Run Gin Server Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/gin-search-api.md Starts the Gin development server. Use this for local development and testing. ```bash go run server.go ``` -------------------------------- ### Perform Multi-Search for Query Suggestions (Go) Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/29.1/api/analytics-query-suggestions.md This Go example shows how to structure and execute a multi-search request to Typesense. It queries a collection for suggestions and another for product results in parallel, enabling a combined display in your UX. ```go searchRequests := api.MultiSearchSearchesParameter{ Searches: []api.MultiSearchCollectionParameters{ { Collection: pointer.Any("product_queries"), Q: pointer.Any("shoe"), QueryBy: pointer.Any("q"), }, { Collection: pointer.Any("products"), Q: pointer.Any("shoe"), QueryBy: pointer.Any("product_name"), }, }, } client.MultiSearch.Perform(context.Background(), &api.MultiSearchParams{}, searchRequests) ``` -------------------------------- ### Install Typesense Python Client Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/29.1/api/api-clients.md Install the Typesense Python client library using pip. ```shell pip install typesense ``` -------------------------------- ### Create Component Files Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/qwik-js-search-bar.md Create the necessary component files for the search interface. ```bash touch src/components/BookCard.tsx touch src/components/BookList.tsx touch src/components/Heading.tsx ``` -------------------------------- ### Install Search Dependencies Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/next-js-search-bar.md Install the required npm packages for Typesense integration: typesense, typesense-instantsearch-adapter, and react-instantsearch. ```shell npm i typesense typesense-instantsearch-adapter react-instantsearch ``` -------------------------------- ### Create Component Files Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/react-native-search-bar.md Use the touch command to create the necessary component files for the search bar functionality. ```bash touch components/SearchInput.tsx touch components/BookCard.tsx touch components/BookList.tsx ``` -------------------------------- ### Download and Install Typesense (Ubuntu x64) Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/install-typesense.md Downloads the Typesense Server .deb package for x64 architecture and installs it using apt. Ensure you have Ubuntu 20 or later. ```bash # Download & Install curl -O https://dl.typesense.org/releases/{{ $site.themeConfig.typesenseLatestVersion }}/typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-amd64.deb sudo apt install -y ./typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-amd64.deb # Start Typesense sudo systemctl start typesense-server.service ``` -------------------------------- ### Install Laravel Scout Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/laravel-full-text-search.md Install the Laravel Scout package using Composer via Laravel Sail. ```shell ./vendor/bin/sail composer require laravel/scout ``` -------------------------------- ### Install Typesense Ruby Client Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/29.1/api/api-clients.md Install the Typesense Ruby client library using the gem command. ```shell gem install typesense ``` -------------------------------- ### Example Docker Container Output Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/astro-search-bar.md An example output showing a running Typesense Docker container, including its ID, image, status, and ports. This is used to confirm successful container startup. ```text CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 82dd6bdfaf66 typesense/typesense:latest "/opt/typesense-serv…" 1 min ago Up 1 minutes 0.0.0.0:8108->8108/tcp, [::]:8108->8108/tcp nostalgic_babbage ``` -------------------------------- ### Create a Search Interface with React InstantSearch Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/firebase-full-text-search.md This example shows how to set up a search interface using React InstantSearch and the Typesense adapter. It includes configuration for the Typesense client and defines a custom Hit component. ```javascript import { InstantSearch, SearchBox, Hits, Stats } from "react-instantsearch-dom" import TypesenseInstantSearchAdapter from "typesense-instantsearch-adapter" const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({ server: { apiKey: "xyz", // Be sure to use a Search API Key nodes: [ { host: 'xxx.a1.typesense.net', // where xxx is the ClusterID of your Typesense Cloud cluster port: '443', protocol: 'https' }, ], }, // The following parameters are directly passed to Typesense's search API endpoint. // So you can pass any parameters supported by the search endpoint below. // query_by is required. additionalSearchParameters: { query_by: "title,description,tags", }, }) const searchClient = typesenseInstantsearchAdapter.searchClient export default function SearchInterface() { const Hit = ({ hit }) => (

{hit.title} - {hit.description}

) return ( ) } ``` -------------------------------- ### Create Utility and Component Directories Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/nuxt-js-search-bar.md Create necessary directories for organizing utility files and components. ```bash mkdir -p utils types components ``` -------------------------------- ### Initial Project Structure Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/next-js-search-bar.md After creating a basic Next.js app and installing dependencies, this is the initial project structure. ```bash typesense-next-search-bar/ ├── node_modules/ ├── pages/ │ └── index.tsx ├── public/ │ ├── file.svg │ ├── globe.svg │ ├── next.svg │ ├── vercel.svg │ └── window.svg ├── .eslintrc.json ├── .gitignore ├── next-env.d.ts ├── next.config.ts ├── package-lock.json ├── package.json └── tsconfig.json ``` -------------------------------- ### Verify Starspace Installation Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/recommendations.md Run the Starspace executable to check if it's installed correctly and displays the usage information. ```shellsession $ ./starspace Usage: need to specify whether it is train or test. "starspace train ..." or "starspace test ..." ... ``` -------------------------------- ### Install Typesense via RPM package Source: https://github.com/typesense/typesense-website/blob/master/docs-site/content/guide/install-typesense.md Download and install the Typesense server RPM package for aarch64 architecture. ```bash curl -O https://dl.typesense.org/releases/{{ $site.themeConfig.typesenseLatestVersion }}/typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-1.lg.page16.aarch64.rpm sudo yum install ./typesense-server-{{ $site.themeConfig.typesenseLatestVersion }}-1.lg.page16.aarch64.rpm ```