---
title: "Deploy Typesense Ranking"
description: "ranking, weights, and sort_by"
category: "Analytics"
url: https://railway.com/deploy/typesense-ranking
---

# Deploy Typesense Ranking

ranking, weights, and sort_by

**[Deploy Typesense Ranking on Railway](https://railway.com/template/typesense-ranking)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/typesense-ranking/manifest.json

- **Creator:** onepush
- **Category:** Analytics

## Template content

### typesense-railway

- **Source:** Shinyduo/typesense-railway
- **Public domain:** Yes

## Documentation

# Deploy and Host self hosted Typesense Ranking (Search Ranking) on Railway

A search box where the first result decides whether someone stays or bounces. That’s ranking’s job. Typesense gives you Algolia-grade relevance controls—field weights, `sort_by`, pinned hits, overrides—under GPL-3.0, and Railway runs the official image on a persistent volume with CORS ready. You pay for compute and storage, not per-search invoices.

## About Hosting Typesense Ranking open-source software on Railway (self hosted Typesense template)

Typesense is a GPL-3.0 open-source search engine built for instant, typo-tolerant search. The ranking features are first-class: field weights, explicit sorting, pinned documents, and query overrides. The official image `typesense/typesense:30.2` is self-contained—no sidecars, no database. Railway lets you deploy that image with a volume at `/data`, an API key env var, and a health endpoint on `8108/health`. Add `--enable-cors` for browser clients.

## Why Deploy Typesense Ranking, the Algolia alternative on Railway (Railway Free Trial)

Algolia is excellent but SaaS-only and bills per search request and per record. Typesense gives you the same ranking vocabulary under GPL-3.0, and you can run it yourself. Railway’s $5 GitHub trial spins up a node fast. A small self-hosted instance typically runs single-digit to low-teens USD per month, versus Typesense Cloud’s 0.5 GB burst node at about $21.60/month. You manage updates and backups, but you own the data and control the cost.

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Typesense Ranking on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

### Railway vs Other Hosting Providers and VPS for Typesense Ranking self hosting

| Provider | Ease | Storage | Scaling | Small node cost |
|----------|------|---------|---------|-----------------|
| Railway | Docker deploy, env vars, volume attach | Built-in volumes | Horizontal replicas | ~$5–12/mo + volume |
| DigitalOcean | Manual Docker on droplet | Block storage | Manual | ~$6–12/mo |
| AWS | EC2/ECS, lots of config | EBS snapshots | Auto-scaling groups | $10–30/mo |
| Hetzner | SSH install on VM | Local NVMe | Manual | ~$5–10/mo |

Railway wins on developer experience; Hetzner and DigitalOcean are cheaper raw compute. AWS gives the most control but highest complexity.

## Common Use Cases for hosted Typesense Ranking

E-commerce product search weights `title` over `description` and lets users sort by price or popularity. Documentation search benefits from typo tolerance and heading boosts. Geospatial apps use `sort_by _geopoint(lat,lng):asc`. Editorial teams pin featured articles with `pinned_hits`. Multi-tenant SaaS collections get different ranking profiles per client. Autocomplete and instant suggestions use `prefix=true` with weighted short fields.

## Dependencies for Typesense Docker hosted on Railway

Typesense needs persistent storage and memory.

### Deployment Dependencies for Managed Typesense Ranking Service (Search Ranking)

- Railway account (free trial works) and a project.
- Persistent volume mounted at `/data`.
- Environment variable `TYPESENSE_API_KEY` (required; never lose it—it encrypts data at rest).
- Optional `TYPESENSE_ENABLE_CORS=true` for browser clients.
- Docker image `typesense/typesense:30.2`. No other services needed.

### Implementation Details for Typesense Ranking (Using Typesense official docker image)

Create a service from `typesense/typesense:30.2`. Start command:

```
--data-dir /data --api-key=$TYPESENSE_API_KEY --enable-cors
```

Attach a volume to `/data`, expose port `8108`, health check `/health`. For ranking, set `query_by_weights` in the schema (e.g., `"3,2,1"`), mark sortable fields, and use `sort_by` or overrides with `pinned_hits` at query time.

## How does Typesense Ranking compare against other search ranking and sort platforms

### Typesense Ranking vs Algolia (Algolia Alternative)

Algolia’s dashboard and tie-breaking are polished, but it’s closed-source and bills per search and per record. Typesense matches most ranking features—field weights, `sort_by`, overrides, pinned hits. Algolia wins if you want a fully managed GUI; Typesense wins for self-hosting, predictable pricing, and GPL-3.0 code.

### Typesense Ranking vs Elasticsearch (Elasticsearch Alternative)

Elasticsearch can do almost any ranking with function scores and script scoring, but the learning curve is steep. Typesense covers common needs—field weights, multi-level sort, pinned hits—in a simple schema. Elasticsearch wins for exotic custom scoring or log analytics; Typesense wins for Algolia-like relevance without a search engineer.

### Typesense Ranking vs Meilisearch (Meilisearch Alternative)

Meilisearch is friendly and easy to deploy. Typesense gives more granular control: per-query `query_by_weights`, multiple `sort_by` criteria, and overrides that pin documents. Meilisearch’s ranking rules are global and less flexible. For basic search, Meilisearch is simpler; for relevance tuning, Typesense is closer to Algolia.

### Typesense Ranking vs Solr (Solr Alternative)

Solr is battle-tested and can do complex function queries, but configuration is XML and Java with JVM tuning. Typesense is instant to set up with a clean HTTP API and JSON. Solr remains strong for enterprise legacy integrations; Typesense wins for modern web and mobile apps needing typo tolerance and low latency.

## How to use Typesense Ranking (the OSS Search Ranking)?

Define a collection with fields like `name`, `description`, `brand`, `price`. Set `query_by_weights` to `"3,2,1"` so name matches matter most. Mark `price` as sortable. Query:

```
/search?q=laptop&query_by=name,description,brand&query_by_weights=3,2,1
```

Add `&sort_by=price:asc` to force sorting. Pin a document with an override using `pinned_hits`. For browser clients, enable CORS and use the Typesense InstantSearch adapter.

## How to self host Typesense Ranking on other VPS Services (Typesense Ranking self hosting guide)

A generic path using a repository with your app code and Typesense config.

### Clone the Repository

Clone your project repo containing the Typesense schema, seed data, and app code. If you don’t have one, create a minimal Node.js or Python app with the Typesense client. Include a `docker-compose.yml` or start script.

### Install Dependencies

For Node.js, run `npm install` to get the `typesense` client. Typesense itself has no external dependencies—it’s a single binary or Docker image. If not using Docker, download the binary from official releases and add it to your PATH.

### Configure Environment Variables

Set `TYPESENSE_API_KEY` (long random string, stored securely), `TYPESENSE_HOST` (VPS IP or domain), `TYPESENSE_PORT=8108`, and `TYPESENSE_PROTOCOL=http`. The app uses the same key and host.

### Start the Typesense Ranking Application

Start the server with Docker:

```
docker run -d -p 8108:8108 -v /data:/data typesense/typesense:30.2 --data-dir /data --api-key=$TYPESENSE_API_KEY --enable-cors
```

Then run your app (`node server.js` or `python app.py`). Point the frontend at port 8108, or set up Nginx for HTTPS. Check `http://your-vps:8108/health`.

## Official Pricing of Typesense Ranking (Typesense Ranking pricing)

Open-source Typesense is free under GPL-3.0. Typesense Cloud bills for dedicated RAM/vCPU hourly plus bandwidth, no per-search or per-record fees. A 0.5 GB burst node is about $21.60/month; 2 GB burst is about $43–51/month. No free cloud tier, but self-hosting is free.

## Typesense Ranking cloud vs self hosted comparison (Pricing, features, costs, and more)

### Monthly cost of self hosting Typesense Ranking on Railway

Railway charges per second for compute and per GB for volumes. A small node (1 vCPU, 512 MB RAM, 5 GB volume) typically lands $5–10/month, with the $5 trial nearly covering the first month. Typesense Cloud’s 0.5 GB burst node costs $21.60/month—self-hosting saves roughly 50–70%. You trade savings for ops: image updates, disk monitoring, backups.

### System Requirements for Hosting Typesense Ranking on a VPS

Typesense is in-memory, so RAM is critical. Under 100k documents: 512 MB RAM works. Production with multiple collections: start at 2 GB. 1–2 vCPUs is plenty. Disk: 5–10 GB persistent volume. Port 8108 must be reachable. Keep the API key safe—it encrypts data at rest; losing it means losing access.

## Frequently Asked Questions (FAQs)

### Can I use Typesense Ranking for free in production?

Yes. GPL-3.0 lets you self-host for free on any infrastructure, including Railway. You pay only for compute and storage. If you modify Typesense source code, you must release changes under GPL-3.0; using the unmodified image has no license cost.

### How do I set field weights in Typesense?

Use `query_by_weights` per query or `default_query_by_weights` in the schema. The weights correspond to fields in `query_by`. Example: `query_by=title,description&query_by_weights=3,1` makes title matches three times more important. Adjust per query to experiment.

### What’s the difference between `sort_by` and `query_by_weights`?

`query_by_weights` affects relevance scoring—higher-weighted fields rank higher. `sort_by` overrides relevance and forces a specific order, like `price:asc`. If `sort_by` is present, relevance is ignored. Use `sort_by` for user-selected sorting and weights for default relevance.

### Can I override ranking for specific queries?

Yes. Create an override for a query like “best laptops” and either pin document IDs with `pinned_hits` or replace ranking with a custom `sort_by`. Overrides live in a separate collection and are managed via API—perfect for merchandi


## Similar templates

- [Typesense vs Meilisearch](https://railway.com/deploy/typesense-vs-meilisearch) — self-hosted Typesense vs Meilisearch
- [Betterlytics](https://railway.com/deploy/betterlytics) — Betterlytics is a cookieless analytics platform GDPR-compliant.
- [Finance Tracker](https://railway.com/deploy/finance-tracker-1) — Private multi-user household finance ledger with budgets and CSV import.

Open this page in a browser: https://railway.com/deploy/typesense-ranking
