### Install and Start Typesense (Windows WSL) Source: https://typesense.org/docs/guide/install-typesense.html Install Typesense on Windows using WSL by downloading the .deb package and installing it with apt. The server can then be started using the provided command. ```bash wsl curl -O https://dl.typesense.org/releases/30.2/typesense-server-30.2-amd64.deb sudo apt install ./typesense-server-30.2-amd64.deb # Start Typesense sudo /usr/bin/./typesense-server --config=/etc/typesense/typesense-server.ini ``` -------------------------------- ### Install Go Client Source: https://typesense.org/docs/30.2/api/api-clients.html Install the Typesense Go client using the go get command. Import the necessary packages for API interaction. ```go // $ go get github.com/typesense/typesense-go/v3/typesense import ( "github.com/typesense/typesense-go/v3/typesense" "github.com/typesense/typesense-go/v3/typesense/api" "github.com/typesense/typesense-go/v3/typesense/api/pointer" ) ``` -------------------------------- ### Project Structure after Initial Setup Source: https://typesense.org/docs/guide/qwik-js-search-bar.html This is the initial project structure after creating a basic Qwik app and installing dependencies. ```bash 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 ``` -------------------------------- ### Setup Search and Sync Routes in Gin Source: https://typesense.org/docs/guide/gin-search-api.html Sets up the HTTP GET and POST routes for search, sync, and sync status using the Gin framework. This function should be called during application startup. ```go package routes import ( "net/http" "time" "github.com/gin-gonic/gin" "github.com/typesense/typesense-go/v4/typesense/api" "github.com/typesense/typesense-go/v4/typesense/api/pointer" "github.com//typesense-gin-full-text-search/config" "github.com//typesense-gin-full-text-search/search" "github.com//typesense-gin-full-text-search/store" ) func SetupSearchRoutes(router *gin.Engine) { router.GET("/search", searchBooks) router.POST("/sync", syncDatabaseToTypesense) router.GET("/sync/status", getSyncStatus) } func searchBooks(c *gin.Context) { query := c.Query("q") if query == "" { c.JSON(http.StatusBadRequest, gin.H{"error": "Search query 'q' is required"}) return } searchParams := &api.SearchCollectionParams{ Q: pointer.String(query), QueryBy: pointer.String("title,authors"), QueryByWeights: pointer.String("2,1"), // title matches rank 2x higher FacetBy: pointer.String("authors,publication_year,average_rating"), // aggregation counts for filters } result, err := search.Client.Collection(config.BookCollection).Documents().Search(c.Request.Context(), searchParams) if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": "Search failed: " + err.Error()}) return } c.JSON(http.StatusOK, gin.H{ "query": query, "results": *result.Hits, "found": *result.Found, "took": result.SearchTimeMs, "facet_counts": result.FacetCounts, }) } // syncDatabaseToTypesense triggers an on-demand incremental sync. // Useful after bulk database changes without restarting the server. func syncDatabaseToTypesense(c *gin.Context) { ctx := c.Request.Context() lastSyncTime := search.GetLastSyncTime() newSyncTime, err := search.SyncBooksToTypesense(ctx, lastSyncTime) if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": "Sync failed", "message": err.Error()}) return } deletedBooks, err := store.GetDeletedBooks(ctx, lastSyncTime) if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to fetch deleted books"}) return } if len(deletedBooks) > 0 { deletedIDs := make([]uint, 0, len(deletedBooks)) for _, book := range deletedBooks { deletedIDs = append(deletedIDs, book.ID) } if err := search.SyncSoftDeletesToTypesense(ctx, deletedIDs); err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to sync deletions"}) return } } search.SetLastSyncTime(newSyncTime) c.JSON(http.StatusOK, gin.H{ "message": "Sync completed", "newSyncTime": newSyncTime.Format(time.RFC3339), "syncedAt": time.Now().Format(time.RFC3339), "deletedBooks": len(deletedBooks), }) } func getSyncStatus(c *gin.Context) { c.JSON(http.StatusOK, gin.H{ "lastSyncTime": search.GetLastSyncTime().Format(time.RFC3339), "syncWorkerRunning": search.IsSyncWorkerRunning(), }) } ``` -------------------------------- ### Start Typesense Server (Systemd) Source: https://typesense.org/docs/guide/install-typesense.html Use this command to start the Typesense server service if installed via a package manager. Configuration and log files are located in /etc/typesense/ and /var/log/typesense/ respectively. ```bash sudo systemctl start typesense-server.service ``` -------------------------------- ### Install and Start Typesense via Homebrew on macOS Source: https://typesense.org/docs/guide/install-typesense.html Installs the Typesense server package using Homebrew and starts it as a service. This method is recommended for macOS Ventura (13.x) or above. ```shell brew install typesense/tap/typesense-server@30.2 brew services start typesense-server@30.2 ``` -------------------------------- ### Install Project Dependencies Source: https://typesense.org/docs/guide/react-native-search-bar.html Navigate to the project directory and install necessary npm packages, including `react-instantsearch-core` and `typesense-instantsearch-adapter`. ```bash cd typesense-react-native-search-bar npm install npm i react-instantsearch-core typesense-instantsearch-adapter ``` -------------------------------- ### Initialize Go Project and Install Dependencies Source: https://typesense.org/docs/guide/gin-search-api.html Sets up a new Go project and installs necessary libraries including Gin, CORS, Typesense client, and GORM. ```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 ``` -------------------------------- ### Start Typesense with environment variables Source: https://typesense.org/docs/30.2/api/server-configuration.html Configure Typesense by setting environment variables. Use CAPS and underscores instead of hyphens, prefixed with TYPESENSE_. For example, TYPESENSE_DATA_DIR for --data-dir. ```shell TYPESENSE_DATA_DIR=/var/lib/typesense TYPESENSE_API_KEY=AS3das2awQ2 ./typesense-server ``` -------------------------------- ### Install and Start Typesense RPM Package on CentOS/RHEL (x64) Source: https://typesense.org/docs/guide/install-typesense.html Downloads and installs the Typesense server RPM package for x64 architecture and starts the service. ```shell # Download & Install curl -O https://dl.typesense.org/releases/30.2/typesense-server-30.2-1.x86_64.rpm sudo yum install ./typesense-server-30.2-1.x86_64.rpm # Start Typesense sudo systemctl start typesense-server.service ``` -------------------------------- ### Install Ruby Client Source: https://typesense.org/docs/0.11.0/api/api-clients.html Install the Ruby client library using gem. ```ruby gem install typesense ``` -------------------------------- ### Install Dependencies for Solid.js Search Source: https://typesense.org/docs/guide/solid-js-search-bar.html Navigate to your project directory and install the necessary dependencies: typesense, typesense-instantsearch-adapter, and instantsearch.js. ```bash cd typesense-solid-js-search npm install npm i typesense typesense-instantsearch-adapter instantsearch.js ``` -------------------------------- ### Install and Start Typesense DEB Package on Ubuntu/Debian (x64) Source: https://typesense.org/docs/guide/install-typesense.html Downloads and installs the Typesense server DEB package for x64 architecture and starts the service. Ensure you are using Ubuntu 20 or later. ```shell # Download & Install curl -O https://dl.typesense.org/releases/30.2/typesense-server-30.2-amd64.deb sudo apt install ./typesense-server-30.2-amd64.deb # Start Typesense sudo systemctl start typesense-server.service ``` -------------------------------- ### Install Project Dependencies Source: https://typesense.org/docs/guide/vanilla-js-search-bar.html Navigate to the project directory and install the necessary dependencies: typesense, typesense-instantsearch-adapter, and instantsearch.js. This command assumes you are already in the project directory. ```bash cd typesense-vanilla-js-search npm install npm i typesense typesense-instantsearch-adapter instantsearch.js ``` -------------------------------- ### Install Typesense InstantSearch Adapter Source: https://typesense.org/docs/guide/search-ui-components.html Install the typesense-instantsearch-adapter package using npm to enable InstantSearch.js to connect with Typesense. ```shell $ npm install --save typesense-instantsearch-adapter ``` -------------------------------- ### Install Python Client Source: https://typesense.org/docs/0.11.0/api/api-clients.html Install the Python client library using pip. ```python pip install typesense ``` -------------------------------- ### Install Qwik Project Dependencies Source: https://typesense.org/docs/guide/qwik-js-search-bar.html Navigate to the project directory and install the necessary npm packages for Typesense integration. ```bash cd typesense-qwik-search npm i typesense typesense-instantsearch-adapter instantsearch.js instantsearch.css ``` -------------------------------- ### Install Typesense Client Source: https://typesense.org/docs/guide/natural-language-search.html Install the Typesense client library for your Next.js application. ```bash npm i typesense@next ``` -------------------------------- ### Example Data for `bucket_size` Source: https://typesense.org/docs/30.2/api/search.html This is an example dataset used to demonstrate 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} ] ``` -------------------------------- ### Create a Simple Search Preset in Dart Source: https://typesense.org/docs/0.25.0/api/search.html This Dart example shows how to create a preset for a standard GET search endpoint. The preset value should be a simple dictionary of search configurations. ```dart await client.presets.upsert('listing_view', { 'value': { { 'collection': 'products', 'q': '*', 'sort_by': 'popularity', } } }); ``` -------------------------------- ### Install Search Dependencies Source: https://typesense.org/docs/guide/angular-search-bar.html Navigate into the Angular project directory and install the necessary npm packages: typesense, typesense-instantsearch-adapter, and instantsearch.js. ```bash cd typesense-angular-search-bar npm i typesense typesense-instantsearch-adapter instantsearch.js ``` -------------------------------- ### Example Typesense Container Output Source: https://typesense.org/docs/guide/astro-search-bar.html An example of the expected output from 'docker ps' showing a running Typesense container. ```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 ``` -------------------------------- ### Start Typesense with Docker Compose Source: https://typesense.org/docs/guide/install-typesense.html Initializes the Typesense data directory and starts the Typesense service using Docker Compose. ```shell mkdir "$(pwd)"/typesense-data docker-compose up ``` -------------------------------- ### Create New Qwik Project Source: https://typesense.org/docs/guide/qwik-js-search-bar.html Initialize a new Qwik project with the 'Empty App' starter. ```bash npm create qwik@latest ``` -------------------------------- ### Install and Start Typesense RPM Package on CentOS/RHEL (aarch64) Source: https://typesense.org/docs/guide/install-typesense.html Downloads and installs the Typesense server RPM package for aarch64 architecture and starts the service. ```shell # Download & Install curl -O https://dl.typesense.org/releases/30.2/typesense-server-30.2-1.aarch64.rpm sudo yum install ./typesense-server-30.2-1.aarch64.rpm # Start Typesense sudo systemctl start typesense-server.service ``` -------------------------------- ### Create lib Directory and Adapter File Source: https://typesense.org/docs/guide/angular-search-bar.html Create the 'lib' directory and the instantsearch-adapter file. ```bash mkdir -p src/app/lib touch src/app/lib/instantsearch-adapter.ts ``` -------------------------------- ### Install and Start Typesense DEB Package on Ubuntu/Debian (arm64) Source: https://typesense.org/docs/guide/install-typesense.html Downloads and installs the Typesense server DEB package for arm64 architecture and starts the service. Ensure you are using Ubuntu 20 or later. ```shell # Download & Install curl -O https://dl.typesense.org/releases/30.2/typesense-server-30.2-arm64.deb sudo apt install ./typesense-server-30.2-arm64.deb # Start Typesense sudo systemctl start typesense-server.service ``` -------------------------------- ### Typesense API Reference v28.0 Source: https://typesense.org/docs/28.0 This section of the documentation details all the API Endpoints available in Typesense and all the parameters you can use with them. Use the links on the side navigation bar to get to the appropriate section you're looking for. To learn how to install and run Typesense, see the Guide section instead. ```APIDOC ## What's new in v28.0 This release contains important new features, performance improvements and bug fixes. ### New Features * Support union / merging of search results across collections containing similar type of fields. (PR#2051(opens new window)) * Dictionary based stemming: stemming is now configurable through an import of a custom dictionary that maps a word to a root form. (PR#2062(opens new window)) * Allow search results to be randomized via `sort_by=_rand(seed)` clause. (PR#1918(opens new window)) * Ability to re-rank hybrid search hits by augmenting their keyword / semantic match score when the hit was identified by only either keyword or vector search. (PR#1968(opens new window)) * Support decay functions in `sort_by` to support gaussian, linear, and exponential decay of values. (PR#2036(opens new window)) * Field level `token_separators` and `symbols_to_index` are now supported. (PR#2118(opens new window)) * Support bucketing of text match scores based on `bucket_size` parameter. (PR#2120(opens new window)) * Ability to truncate a collection. (PR#2127(opens new window)) * Index and search on geo polygons. (PR#2150(opens new window)) * Support `validate_field_names` parameter to disable field name validation in faceting, filtering and grouping operations. ### Enhancements * Support `distance_threshold` parameter for vector query that uses inner product distance. * Allow updating of remote model's `api_key` parameter. (PR#1944(opens new window)) * Support `max_filter_by_candidates` search parameter that controls the number of similar words that Typesense considers during fuzzy search on `filter_by` values (default is `4`). * Performance and stability fixes for joins. * API endpoint that returns status of alter schema operations that are in-progress. (PR#2123(opens new window)) * Faceting performance improvements. ### Bug Fixes * Fixed fields with `async_reference` property not being restored correctly on restart. * Fixed sorting with nested reference fields. * Addressed edge cases in conversation API. * Assign default sorting score if reference is not found while sorting by a reference field. * Fix `distance_threshold` in `vector_query` not working correctly while sorting. * Add validation to ensure that embedding fields are of type `float[]`. * Fix vector query format validation error messages. * Fix race condition in high concurrency image embedding. * Fix `flat_search_cutoff` not working for hybrid search. ### Deprecations / behavior changes There are no deprecations / behavior changes in this release. ## Upgrading to v28.0 Before upgrading your existing Typesense cluster to v28.0, please review the behavior changes above to prepare your application for the upgrade. We'd recommend testing on your development / staging environments before upgrading. ### Typesense Cloud If you're on Typesense Cloud: 1. Go to https://cloud.typesense.org/clusters(opens new window). 2. Click on your cluster 3. Click on "Cluster Configuration" on the left-side pane, and then click on "Modify" 4. Select a new Typesense Server version in the dropdown 5. Schedule a time for the upgrade. ### Self Hosted If you're self-hosting Typesense, here's how to upgrade: #### Single node deployment 1. Trigger a snapshot to create a backup(opens new window) of your data, for safety purposes. 2. Stop Typesense server. 3. Replace the binary via the tar package or via the DEB/RPM installer. 4. Start Typesense server back again. ``` -------------------------------- ### Create Book Interface Source: https://typesense.org/docs/guide/angular-search-bar.html Create the types directory and the Book interface file. ```bash mkdir -p src/app/types touch src/app/types/book.ts ``` -------------------------------- ### Perform 'Starts With' Matching using filter_by Source: https://typesense.org/docs/guide/faqs.html Utilize the ':=' operator within 'filter_by' for 'starts with' matching. This example finds records where the 'job_title' field begins with 'software'. ```json { "q": "*", "filter_by": "job_title:=software*" } ``` -------------------------------- ### Initialize Gin Server and Typesense Integration Source: https://typesense.org/docs/guide/gin-search-api.html Sets up the Gin server, initializes the Typesense client, connects to PostgreSQL, and configures routes. It also starts a background sync worker for Typesense. Ensure environment variables are loaded and Typesense collections are initialized before starting the server. ```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(": ``` ```go + port) } ``` -------------------------------- ### Run the Server Source: https://typesense.org/docs/guide/gin-search-api.html Execute the `server.go` file using `go run` to start the application. This command compiles and runs the server, making it accessible on the configured port. ```bash go run server.go ``` -------------------------------- ### Setup Book Routes in Gin Source: https://typesense.org/docs/guide/gin-search-api.html Defines the API endpoints for book management, including POST, GET, PUT, and DELETE operations. ```go package routes import ( "context" "log" "net/http" "strconv" "github.com/gin-gonic/gin" "github.com//typesense-gin-full-text-search/models" "github.com//typesense-gin-full-text-search/search" "github.com//typesense-gin-full-text-search/store" ) func SetupBookRoutes(router *gin.Engine) { books := router.Group("/books") { books.POST("", createBook) books.GET("/:id", getBook) books.GET("", getAllBooks) books.PUT("/:id", updateBook) books.DELETE("/:id", deleteBook) } } ``` -------------------------------- ### Download and Start Typesense (Linux x64 Binary) Source: https://typesense.org/docs/guide/install-typesense.html Download the Typesense server binary for Linux x64, extract it, and start the server. Set the API key and specify a data directory. CORS is enabled by default. ```bash # Download curl -O https://dl.typesense.org/releases/30.2/typesense-server-30.2-linux-amd64.tar.gz tar -xzf typesense-server-30.2-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 ``` -------------------------------- ### Facet by Numerical Ranges Source: https://typesense.org/docs/30.2/api/search.html This example demonstrates how to facet numerical fields by defining custom ranges with labels. Note that range start values are inclusive and end values are exclusive. Leaving a range end blank covers all values greater than or equal to the start. ```json { "facet_by": "rating(Average:[0, 3], Good:[3, 4], Great:[4, 5])" } ``` ```json { "facet_by": "price(economy:[0, 100], others:[100, ])" } ``` -------------------------------- ### Create Components Directory and Files Source: https://typesense.org/docs/guide/solid-js-search-bar.html Commands to create the 'components' directory and necessary component files, including CSS modules. ```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 ``` -------------------------------- ### Update Typesense on macOS via Homebrew Source: https://typesense.org/docs/guide/updating-typesense.html Stop the Typesense service, install the new version using the typesense/tap/typesense-server@30.2 formula, and then start the service again. ```shell brew services stop typesense-server brew install typesense/tap/typesense-server@30.2 brew services start typesense-server@30.2 ``` -------------------------------- ### Start Typesense with a configuration file Source: https://typesense.org/docs/30.2/api/server-configuration.html Use the --config flag to specify the path to your Typesense server configuration file. ```shell ./typesense-server --config=/etc/typesense/typesense-server.ini ``` -------------------------------- ### Create Project Directories Source: https://typesense.org/docs/guide/react-native-search-bar.html Creates the necessary directories for components, types, and utilities. ```bash mkdir -p components types utils ``` -------------------------------- ### Retrieve an API Key via HTTP Source: https://typesense.org/docs/30.2/api/api-keys.html This example shows how to retrieve an API key using a direct HTTP GET request. Ensure you include the 'X-TYPESENSE-API-KEY' header with your API key. ```shell curl 'http://localhost:8108/keys/1' \ -X GET \ -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" ``` -------------------------------- ### Download and Start Typesense (Linux arm64 Binary) Source: https://typesense.org/docs/guide/install-typesense.html Download the Typesense server binary for Linux arm64, extract it, and start the server. Set the API key and specify a data directory. CORS is enabled by default. ```bash # Download curl -O https://dl.typesense.org/releases/30.2/typesense-server-30.2-linux-arm64.tar.gz tar -xzf typesense-server-30.2-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 ``` -------------------------------- ### Search for Books via HTTP GET Request Source: https://typesense.org/docs/guide/building-a-search-application.html This example demonstrates how to perform a search query using a curl command, including query parameters for search term, fields to search, and sorting. ```shell curl -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \ "${TYPESENSE_HOST}/collections/books/documents/search\ ?q=harry+potter&query_by=title&sort_by=ratings_count:desc" ``` -------------------------------- ### Install Laravel Scout with Typesense Driver Source: https://typesense.org/docs/guide/laravel-full-text-search.html Install Laravel Scout and select the 'typesense' driver during the Sail installation process. ```shell php artisan sail:install ``` -------------------------------- ### Create a Multi-Search Preset Source: https://typesense.org/docs/30.2/api/search.html This example demonstrates creating a preset that can be used for multi-search operations. It defines two searches: one for 'products' and another for 'blog_posts', each with its own query and sorting parameters. ```javascript await client.presets().upsert("listing_view", { value: { searches: [ { collection: "products", q: "*", sort_by: "popularity", }, { collection: "blog_posts", q: "*", sort_by: "published_at:desc", } ], }, }) ``` -------------------------------- ### Initialize Java Client Source: https://typesense.org/docs/0.25.0/api/authentication.html Set up the Typesense client in Java. Define nodes, configuration, and create a client instance. ```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); ``` -------------------------------- ### PHP Search Example Source: https://typesense.org/docs/0.25.0/api/search.html This PHP snippet shows how to execute a search query with various parameters. Ensure your client is properly initialized. ```php $searchParameters = [ 'q' => 'stark', 'query_by' => 'company_name', 'filter_by' => 'num_employees:>100', 'sort_by' => 'num_employees:desc' ]; $client->collections['companies']->documents->search($searchParameters); ``` -------------------------------- ### Example JSONL Output Source: https://typesense.org/docs/guide/recommendations.html An example of the JSONL file format generated for products with embeddings. ```json {"id":"apple","embedding":[-0.129717,0.173566,0.105385,0.0413297,-0.0290213,-0.0255852,0.0825889,-0.0261474,-0.0672213,-0.020061,-0.0227523,-0.232531,0.126667,0.053292,0.0092951,-0.117847,-0.0203866,0.067803,0.0669588,-0.0958568,-0.126915,0.120737,0.0547092,0.00512978,0.0257105,-0.0784047,-0.0348654,-0.125596,0.087177,0.132318,0.151595,-0.0326471,-0.169206,-0.00846743,0.184474,-0.148861,0.0110634,-0.0613974,0.0422888,-0.137809,0.0259965,-0.0851748,0.0202873,-0.120347,0.182447,0.110794,-0.200759,0.130639,-0.157653,-0.0173171,0.101569,-0.224391,-0.0160616,-0.0754992,-0.0967191,0.00498547,-0.144638,0.046945,-0.11333,-0.0533871,0.0118368,0.0670858,-0.0714718,-0.0474113,0.0123388,0.0553516,-0.163903,0.0201541,-0.0880148,0.0344916,-0.0213696,0.111026,0.0823451,-0.0152207,0.0427815,0.00890293,-0.163427,-0.165768,0.0409641,0.0668304,0.0868884,-0.0690655,-0.120059,-0.157864,-0.12657,0.0895369,-0.0551588,-0.138711,-0.0834502,0.0384778,-0.122425,0.00729352,-0.108975,-0.201364,-0.0596544,-0.0512629,-0.0172166,-0.147633,0.048211,0.0167111]} {"id":"banana","embedding":[-0.151976,0.167556,0.0984403,0.0582992,-0.0267645,-0.0632901,0.0818063,-0.0577236,-0.0661825,-0.0224044,-0.0083418,-0.235444,0.106222,0.098582,-0.0422992,-0.16124,-0.0754309,0.0859816,0.0505005,-0.0773229,-0.0878463,0.126327,0.0319473,0.0662375,0.0288876,-0.099176,-0.0356668,-0.118937,0.085241,0.145321,0.127992,-0.0275212,-0.164231,0.007687,0.15164,-0.149566,0.0513335,-0.0522685,0.00915292,-0.127394,0.0438007,-0.0371664,0.0524856,-0.126597,0.187275,0.0891057,-0.229951,0.138657,-0.146845,0.0245155,0.0622531,-0.22075,-0.0497431,-0.0837679,-0.092076,0.00150625,-0.158956,-0.00107306,-0.104141,-0.0596481,0.00658634,0.0868983,-0.0158821,-0.0623965,0.0369001,0.0743422,-0.218009,0.0531221,-0.033627,0.036802,-0.0232749,0.149437,0.0692087,0.0290572,-0.00513245,-0.0166902,-0.162802,-0.15936,0.0567595,0.101776,0.125398,-0.114981,-0.0962633,-0.110599,-0.0872082,0.0987341,-0.0343689,-0.0974114,-0.0465906,0.00473119,-0.133105,0.0337405,-0.0637639,-0.194511,-0.0586302,0.0310114,0.004405,-0.108879,-0.0131596,0.0469659]} ... ``` -------------------------------- ### Create Component Files Source: https://typesense.org/docs/guide/qwik-js-search-bar.html Create the necessary component files for the search interface: BookCard.tsx, BookList.tsx, and Heading.tsx. ```bash touch src/components/BookCard.tsx touch src/components/BookList.tsx touch src/components/Heading.tsx ``` -------------------------------- ### Install Nuxt.js Dependencies Source: https://typesense.org/docs/guide/nuxt-js-search-bar.html Install necessary dependencies for Typesense integration: typesense, typesense-instantsearch-adapter, and vue-instantsearch. ```bash npm install typesense typesense-instantsearch-adapter vue-instantsearch ``` -------------------------------- ### Initialize PHP Client Source: https://typesense.org/docs/0.25.0/api/authentication.html Set up the Typesense client in PHP. Ensure the API key and node details are correctly configured. ```php use Typesense\Client; $client = new Client( [ 'api_key' => 'abcd', 'nodes' => [ [ 'host' => 'localhost', // For Typesense Cloud use xxx.a1.typesense.net 'port' => '8108', // For Typesense Cloud use 443 'protocol' => 'http', // For Typesense Cloud use https ], ], 'connection_timeout_seconds' => 2, ] ); ``` -------------------------------- ### Install Dependencies for VuePress v2 Source: https://typesense.org/docs/guide/docsearch.html Install the necessary packages for Typesense DocSearch in your VuePress v2 project. ```bash npm i typesense-docsearch.js typesense-docsearch-css ``` -------------------------------- ### Initialize Ruby Client Source: https://typesense.org/docs/0.25.0/api/authentication.html Set up the Typesense client in Ruby. Provide node configuration and your API key. ```ruby require 'typesense' client = Typesense::Client.new( nodes: [{ host: 'localhost', # For Typesense Cloud use xxx.a1.typesense.net port: 8108, # For Typesense Cloud use 443 protocol: 'http' # For Typesense Cloud use https }], api_key: '', connection_timeout_seconds: 2 ) ``` -------------------------------- ### Install Typesense InstantSearch Dependencies Source: https://typesense.org/docs/guide/firebase-full-text-search.html Install the necessary npm packages for integrating Typesense with InstantSearch.js and React. ```bash npm install typesense-instantsearch-adapter react-instantsearch-dom @babel/runtime ``` -------------------------------- ### Start Laravel Sail Docker Containers Source: https://typesense.org/docs/guide/laravel-full-text-search.html Start the Docker containers for your Laravel application in detached mode. ```shell ./vendor/bin/sail up -d ``` -------------------------------- ### Install Typesense Server (Large Page Size Build) Source: https://typesense.org/docs/guide/install-typesense.html Download and install the Typesense server for ARM64 systems with a 16K page size. Supports Linux binary, DEB, RPM, and Docker. ```bash # Linux Binary curl -O https://dl.typesense.org/releases/30.2/typesense-server-30.2-linux-arm64-lg-page16.tar.gz tar -xzf typesense-server-30.2-linux-arm64-lg-page16.tar.gz # DEB curl -O https://dl.typesense.org/releases/30.2/typesense-server-30.2-arm64-lg-page16.deb sudo apt install ./typesense-server-30.2-arm64-lg-page16.deb # RPM curl -O https://dl.typesense.org/releases/30.2/typesense-server-30.2-1.lg.page16.aarch64.rpm sudo yum install ./typesense-server-30.2-1.lg.page16.aarch64.rpm # Docker docker pull typesense/typesense:30.2-arm64-lg-page16 ``` -------------------------------- ### Start Typesense using jirevwe/typesense-github-action Source: https://typesense.org/docs/guide/github-actions.html Use this pre-built GitHub Action to easily add a Typesense server to your workflow. Configure the Typesense version and port as needed. This is useful for testing against multiple Typesense versions. ```yaml name: Run tests on: [push] jobs: build: runs-on: ubuntu-latest strategy: matrix: typesense-version: [0.22.0, 0.23.1] steps: - name: Start Typesense uses: jirevwe/typesense-github-action@v1.0.1 with: typesense-version: ${{ matrix.typesense-version }} typesense-port: 20863 - name: Curl Typesense run: sleep 10 && curl http://localhost:8108/health ``` -------------------------------- ### Initial Project Structure Source: https://typesense.org/docs/guide/vanilla-js-search-bar.html This is the initial project structure after creating a basic Vite app and installing dependencies. ```bash typesense-vanilla-js-search/ ├── node_modules/ ├── public/ │ └── vite.svg ├── src/ │ ├── main.js │ └── style.css ├── .gitignore ├── index.html ├── package-lock.json └── package.json ``` -------------------------------- ### Project Structure Initialization Source: https://typesense.org/docs/guide/solid-js-search-bar.html Initial project structure after creating a basic Solid.js app and installing dependencies. ```bash typesense-solid-js-search/ ├── node_modules/ ├── public/ │ └── favicon.svg ├── src/ │ ├── App.tsx │ ├── index.css │ └── index.tsx ├── .gitignore ├── index.html ├── package-lock.json ├── package.json ├── tsconfig.app.json ├── tsconfig.json └── vite.config.ts ``` -------------------------------- ### Initialize Typesense Client in PHP Source: https://typesense.org/docs/guide/building-a-search-application.html Set up the PHP client with connection details and API key for interacting with Typesense. ```php use Typesense\Client; $client = new Client( [ 'api_key' => '', 'nodes' => [ [ 'host' => 'localhost', // For Typesense Cloud use xxx.a1.typesense.net 'port' => '8108', // For Typesense Cloud use 443 'protocol' => 'http', // For Typesense Cloud use https ], ], 'connection_timeout_seconds' => 2, ] ); ``` -------------------------------- ### Example JSONL Data Source: https://typesense.org/docs/0.25.0/api/documents.html This is an example of a JSON Lines (JSONL) file format, where each line is a valid JSON object. ```json {"id": "1", "company_name": "Stark Industries", "num_employees": 5215, "country": "USA"} {"id": "2", "company_name": "Orbit Inc.", "num_employees": 256, "country": "UK"} ``` -------------------------------- ### Install Search Dependencies Source: https://typesense.org/docs/guide/next-js-search-bar.html Install the necessary npm packages for integrating Typesense search with React InstantSearch in your Next.js project. ```bash npm i typesense typesense-instantsearch-adapter react-instantsearch ``` -------------------------------- ### Install Starlight DocSearch Typesense Plugin Source: https://typesense.org/docs/guide/docsearch.html Install the necessary npm package for integrating Typesense search with Astro Starlight. ```bash $ npm install starlight-docsearch-typesense ``` -------------------------------- ### Project Structure after Component Setup Source: https://typesense.org/docs/guide/qwik-js-search-bar.html The project structure after creating the component files for the search interface. ```bash typesense-qwik-search/ ├── src/ │ ├── components/ │ │ ├── router-head/ │ │ ├── BookCard.tsx │ │ ├── BookList.tsx │ │ └── Heading.tsx │ ├── routes/ │ │ └── index.tsx │ ├── types/ │ │ └── Book.ts │ ├── utils/ │ │ └── typesense.ts │ ├── entry.dev.tsx │ ├── entry.preview.tsx │ ├── entry.ssr.tsx │ ├── global.css │ └── root.tsx ├── .env ├── .gitignore ├── package.json ├── tsconfig.json └── vite.config.ts ``` -------------------------------- ### Create Queue Table and Migrate Source: https://typesense.org/docs/guide/laravel-full-text-search.html Run these commands to create the necessary database table for queue jobs and apply migrations. ```shell ./vendor/bin/sail artisan make:queue-table ./vendor/bin/sail artisan migrate ``` -------------------------------- ### Install Search Dependencies Source: https://typesense.org/docs/guide/astro-search-bar.html Install the necessary npm packages for integrating Typesense search with Astro: typesense, typesense-instantsearch-adapter, and instantsearch.js. ```bash npm i typesense typesense-instantsearch-adapter instantsearch.js ``` -------------------------------- ### Create Project Structure Source: https://typesense.org/docs/guide/gin-search-api.html Organizes the project by creating necessary directories and files for configuration, models, routes, search logic, store, and server setup. ```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 ```