• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

How to Deploy Typesense on Hong Kong VPS: Algolia Alternative (2026)

June 17, 2026

Typesense is an open-source, typo-tolerant search engine — a self-hosted alternative to Algolia that delivers millisecond search responses with a simple REST API and SDKs for every major language. Deployed on a Hong Kong VPS, Typesense gives Asia-Pacific applications a private search backend with sub-10ms query responses for regional users and no per-search-operation billing.

At scale, Algolia’s pricing ($1/1,000 search operations beyond the free tier) compounds quickly for high-traffic applications. A Typesense instance on a Hong Kong VPS replaces this with a flat monthly infrastructure cost — unlimited searches, unlimited records.


Typesense vs Algolia: Key Differences

FeatureAlgoliaTypesense (self-hosted)
Search latency (Asia)50–150ms (nearest PoP)1–5ms (on HK VPS, local)
PricingPer operation (scales with traffic)Flat VPS cost
1M searches/month cost~$500+/monthVPS cost only
Data residencyAlgolia US/EU serversYour HK VPS
Typo toleranceYesYes
Faceted searchYesYes
Geo searchYesYes
Chinese language supportPartialVia tokenisation plugins
API compatibilityAlgolia APITypesense API (Algolia adapter available)

Step 1: Install Typesense

apt update && apt upgrade -y
apt install -y curl apt-transport-https gnupg

# Add Typesense apt repository
curl -sL https://dl.typesense.org/packages/apt/gpg.key | apt-key add -
echo "deb https://dl.typesense.org/packages/apt focal main" > /etc/apt/sources.list.d/typesense.list

apt update
apt install typesense-server -y

Configure Typesense

Edit /etc/typesense/typesense-server.ini:

[server]
api-key = GENERATE_A_STRONG_RANDOM_API_KEY
data-dir = /var/lib/typesense
log-dir = /var/log/typesense
listen-port = 8108
enable-cors = true
# Generate a secure API key
openssl rand -hex 32

systemctl enable --now typesense-server

# Verify it's running
curl http://localhost:8108/health

Expected response: {"ok":true}


Step 2: Secure with Nginx Reverse Proxy

apt install nginx certbot python3-certbot-nginx -y

cat > /etc/nginx/sites-available/typesense << 'EOF'
server {
    listen 80;
    server_name search.yourdomain.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name search.yourdomain.com;

    ssl_certificate /etc/letsencrypt/live/search.yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/search.yourdomain.com/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:8108;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_read_timeout 30s;
    }
}
EOF

ln -s /etc/nginx/sites-available/typesense /etc/nginx/sites-enabled/
certbot --nginx -d search.yourdomain.com
nginx -t && systemctl reload nginx

# Restrict direct port access
ufw deny 8108

Step 3: Create a Collection and Index Documents

Create a Collection (Schema)

curl -X POST https://search.yourdomain.com/collections \
  -H "X-TYPESENSE-API-KEY: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "products",
    "fields": [
      {"name": "id",          "type": "string"},
      {"name": "name",        "type": "string"},
      {"name": "description", "type": "string"},
      {"name": "price",       "type": "float"},
      {"name": "category",    "type": "string", "facet": true},
      {"name": "brand",       "type": "string", "facet": true},
      {"name": "in_stock",    "type": "bool",   "facet": true},
      {"name": "rating",      "type": "float"}
    ],
    "default_sorting_field": "rating"
  }'

Index Documents in Bulk

# JSONL format (one document per line) — highly efficient for bulk imports
curl -X POST "https://search.yourdomain.com/collections/products/documents/import?action=create" \
  -H "X-TYPESENSE-API-KEY: YOUR_API_KEY" \
  -H "Content-Type: text/plain" \
  --data-binary @products.jsonl

Typesense ingests millions of documents in minutes. A 1 million document e-commerce catalogue indexes in approximately 5–10 minutes on a 4 GB VPS.

Search

curl "https://search.yourdomain.com/collections/products/documents/search?q=wireless+headphones&query_by=name,description&facet_by=brand,category&filter_by=in_stock:true&sort_by=rating:desc" \
  -H "X-TYPESENSE-API-KEY: YOUR_SEARCH_ONLY_KEY"

Step 4: Integrate with Your Application

JavaScript / Next.js

npm install typesense typesense-instantsearch-adapter

// typesense-client.js
const Typesense = require('typesense');

const client = new Typesense.Client({
  nodes: [{
    host: 'search.yourdomain.com',
    port: 443,
    protocol: 'https'
  }],
  apiKey: process.env.TYPESENSE_SEARCH_KEY,
  connectionTimeoutSeconds: 2
});

// Search function
async function searchProducts(query, filters = {}) {
  return client.collections('products').documents().search({
    q: query,
    query_by: 'name,description',
    facet_by: 'brand,category',
    filter_by: filters.inStock ? 'in_stock:true' : '',
    sort_by: 'rating:desc',
    per_page: 20
  });
}

module.exports = { searchProducts };

Python / Django

pip install typesense

import typesense

client = typesense.Client({
    'nodes': [{'host': 'search.yourdomain.com', 'port': '443', 'protocol': 'https'}],
    'api_key': 'YOUR_API_KEY',
    'connection_timeout_seconds': 2
})

# Index a document
client.collections['products'].documents.create({
    'id': '1',
    'name': '蓝牙耳机 Pro',
    'description': 'High quality wireless headphones',
    'price': 299.0,
    'category': 'Electronics',
    'brand': 'Sony',
    'in_stock': True,
    'rating': 4.8
})

# Search
results = client.collections['products'].documents.search({
    'q': 'bluetooth headphones',
    'query_by': 'name,description'
})

Algolia Drop-In Replacement

If you have an existing Algolia integration, Typesense provides an Algolia compatibility adapter:

npm install typesense-instantsearch-adapter

import TypesenseInstantSearchAdapter from 'typesense-instantsearch-adapter';

const typesenseAdapter = new TypesenseInstantSearchAdapter({
  server: {
    apiKey: 'YOUR_SEARCH_KEY',
    nodes: [{ host: 'search.yourdomain.com', port: 443, protocol: 'https' }]
  },
  additionalSearchParameters: { query_by: 'name,description' }
});

// Replace algoliasearch with typesenseAdapter.searchClient
const searchClient = typesenseAdapter.searchClient;

This adapter makes Typesense a drop-in replacement for Algolia in InstantSearch.js, React InstantSearch, and Vue InstantSearch — no UI component changes required.


Step 5: Create Search-Only API Keys

Never expose your admin API key in frontend code. Create scoped search-only keys:

curl -X POST https://search.yourdomain.com/keys \
  -H "X-TYPESENSE-API-KEY: YOUR_ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "Search-only key for frontend",
    "actions": ["documents:search"],
    "collections": ["products"]
  }'

This key can only search the products collection — it cannot create, update, or delete documents, and cannot access other collections. Safe to embed in frontend JavaScript.


Step 6: Chinese Language Search

Typesense’s default tokeniser does not handle CJK (Chinese/Japanese/Korean) character segmentation. For Chinese-language search, configure the collection with a custom tokeniser:

{
  "name": "chinese_products",
  "fields": [
    {"name": "name_zh", "type": "string", "locale": "zh"}
  ],
  "token_separators": [",", "。", "、", ":", ";"]
}

For more sophisticated Chinese word segmentation (jieba-style), pre-process documents before indexing — segment Chinese text into space-separated tokens, then index the tokenised version alongside the original.


Monitoring Typesense

# Check cluster health and stats
curl -H "X-TYPESENSE-API-KEY: YOUR_KEY" \
  https://search.yourdomain.com/stats.json

# Monitor resource usage
curl -H "X-TYPESENSE-API-KEY: YOUR_KEY" \
  https://search.yourdomain.com/metrics.json

Key metrics to monitor: latency_ms (should stay under 10ms for cached results), requests_per_second, and memory_used_bytes. Typesense holds its entire index in RAM for fast responses — ensure your VPS has enough RAM for your index size.

Index Size Estimation

  • 1 million simple product documents (5 fields): ~500 MB RAM
  • 1 million rich documents (10+ fields, long descriptions): ~1–2 GB RAM
  • Rule of thumb: allocate 2× your estimated index RAM for comfortable operation

Automated Backups

cat > /opt/typesense-backup.sh << 'EOF'
#!/bin/bash
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR="/opt/typesense-backups"
mkdir -p $BACKUP_DIR

# Stop Typesense, snapshot data directory, restart
systemctl stop typesense-server
tar czf $BACKUP_DIR/typesense_$DATE.tar.gz /var/lib/typesense/
systemctl start typesense-server

# Keep 7 days
find $BACKUP_DIR -name "*.tar.gz" -mtime +7 -delete
echo "Backup complete: $DATE"
EOF
chmod +x /opt/typesense-backup.sh
crontab -l | { cat; echo "0 3 * * * /opt/typesense-backup.sh"; } | crontab -

Conclusion

Self-hosting Typesense on a Hong Kong VPS eliminates Algolia’s per-operation billing and delivers sub-5ms search responses for Asia-Pacific users — versus 50–150ms from Algolia’s nearest PoP. The Algolia InstantSearch compatibility adapter makes migration from existing Algolia setups straightforward: swap the search client, keep all UI components unchanged.

For e-commerce stores, content platforms, and SaaS applications with search functionality serving Asian users, Typesense on Hong Kong VPS with CN2 GIA routing is the optimal combination of performance and cost.

Launch your search backend: Browse Server.HK Hong Kong VPS plans — a 4 GB plan hosts Typesense with indexes up to ~2 million documents comfortably.

Recent Posts

  • How to Set Up Grafana and Prometheus on Hong Kong VPS (2026)
  • How to Set Up Uptime Kuma on Hong Kong VPS: Self-Hosted Monitoring (2026)
  • CI/CD to Hong Kong VPS with GitHub Actions: Automated Deploy Guide (2026)
  • How to Set Up a Mail Server on Hong Kong VPS: Postfix, Dovecot & DKIM (2026)
  • How to Host Multiple Websites on One Hong Kong VPS with Nginx (2026)

Recent Comments

  1. Hong Kong VPS Uptime and SLA: What 99.9% Uptime Really Means for Your Business (2026) - Server.HK on How to Monitor Your Hong Kong VPS: Uptime, Performance, and Alert Setup Guide (2026)
  2. Best Hong Kong VPS Providers in 2026: Compared by Speed, Routing, and Value - Server.HK on How to Migrate Your Website to a Hong Kong VPS: Zero-Downtime Transfer Guide (2026)
  3. vibramycin injection on How to Choose the Right Hong Kong VPS Plan: A Buyer’s Guide for 2026
  4. allopurinol for gout on CN2 GIA vs BGP vs CN2 GT: What’s the Real Difference for China Connectivity?
  5. antibiotics online purchase on How to Set Up a WordPress Site on a Hong Kong VPS with aaPanel (Step-by-Step 2026)

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot