---
title: "Deploy Typesense Nested Fields"
description: "object and nested field schemas"
category: "Analytics"
url: https://railway.com/deploy/typesense-nested-fields
---

# Deploy Typesense Nested Fields

object and nested field schemas

**[Deploy Typesense Nested Fields on Railway](https://railway.com/template/typesense-nested-fields)**

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

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

## Template content

### typesense-railway

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

## Documentation

# Deploy and Host self hosted Typesense Nested Fields (Open-Source Instant Search) on Railway

Typesense Nested Fields lets you index objects and arrays of objects so InstantSearch can filter and facet nested attributes without flattening every path. This Railway listing runs official typesense/typesense:30.2 on port 8108 with a /data volume, TYPESENSE_API_KEY, and --enable-cors.

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

There's a moment when flattening document fields stops working. You've got a product with `variants` — each holding price, color, size, stock. Flatten into `variants_0_price`, `variants_1_color`, and the schema breaks the moment a seller adds a third variant. Typesense nested fields exist for this: you define objects and arrays of objects in your collection schema, index them as structured nested documents, and filter or facet on `variants.color` or `variants.price` directly.

Hosting on Railway means running the official `typesense/typesense:30.2` Docker image with a persistent volume for `/data`. Railway handles restarts, logs, health checks, and scaling. The API listens on port 8108; a health check there tells Railway when the node is ready.

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

Algolia won't let you self-host. If your catalog uses nested objects for variants, inventory, or localized fields, you're locked into SaaS pricing where every search request and record adds to the bill. Typesense is GPL-3.0 open source, runs on your own infrastructure, and gives full control over nested schemas. Deploy it on Railway and you get a self-hosted search node with no per-search invoice.

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 Nested Fields 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 Nested Fields self hosting

| Provider | Setup experience for nested field schemas | Pricing model | Best for |
|---|---|---|---|
| Railway | Docker-native, volume attach, health check on 8108 | Compute + volume, $5 GitHub trial | Quick deploy with managed container |
| DigitalOcean | Droplet + manual Docker | Per-droplet hourly | Static VPS with full root control |
| AWS | ECS/EC2 + EBS | Pay-as-you-go, many moving parts | Enterprise with existing AWS accounts |
| Hetzner | Dedicated server or cloud VM | Cheap, predictable | Budget European hosting |

## Common Use Cases for hosted Typesense Nested Fields

A clothing store with `variants` arrays — each object holding `size`, `color`, `price`, `stock` — is canonical. With nested fields, you facet on `variants.color` and get counts across all products, not just where a flattened `color` field happens to be populated. InstantSearch's `facetFilters` accepts the nested path directly.

Marketplaces where sellers define their own attributes per listing work well too. Index `attributes` as an array of `{name, value, unit}` objects and query `attributes.name:material && attributes.value:wool`. Adding a new attribute type doesn't require a schema migration.

Localized content is another use case. A document with `title: {en: "Jacket", fr: "Veste", de: "Jacke"}` lets you filter `title.fr:*` without creating three top-level fields per localized attribute.

## Dependencies for Typesense Nested Fields Docker hosted on Railway

This template runs official typesense/typesense:30.2, a volume at /data, TYPESENSE_API_KEY, and --enable-cors on port 8108. No extra database or Redis.

### Deployment Dependencies for Managed Typesense Nested Fields Service (Nested Document Schemas)

The only runtime dependency is the Docker image `typesense/typesense:30.2` — never use `latest`. You need a persistent volume mounted at `/data` so indexes survive restarts. Set `TYPESENSE_API_KEY`; without it, Typesense refuses to start. If browser-based InstantSearch clients query the node directly, pass `--enable-cors`.

### Implementation Details for Typesense Nested Fields (Using Typesense official docker image)

The container starts with:

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

Typesense loads the API key from the environment, writes index files to `/data`, and enables CORS. The API listens on port 8108 — set that as your Railway service port and health check at `/health`.

Define nested fields in the schema using `fields` with `type: "object"` or `"object[]"`. Example:

```json
{
  "name": "products",
  "fields": [
    {"name": "name", "type": "string"},
    {"name": "variants", "type": "object[]"},
    {"name": "variants.color", "type": "string", "facet": true},
    {"name": "variants.price", "type": "float", "facet": true},
    {"name": "variants.stock", "type": "int32"}
  ]
}
```

Filter with `filter_by: variants.color:=red` or facet with `facet_by: variants.color,variants.price`. InstantSearch passes these through `facetFilters` and `numericFilters` as dotted paths.

## How does Typesense Nested Fields compare against other Nested Search Field Schemas platforms

### Typesense Nested Fields vs Algolia (Algolia Alternative)

Algolia handles nested attributes and has polished UI tooling. But it's SaaS-only. Their Grow plan bills by search requests and records stored, which gets expensive for catalogs with many variants. Typesense gives the same nested filter/facet capability under GPL-3.0, self-hosted, with no per-search cost. Algolia wins on managed infrastructure and dashboard analytics; Typesense wins on predictable cost and schema control.

### Typesense Nested Fields vs Elasticsearch (Elasticsearch Alternative)

Elasticsearch supports `nested` field types with full query DSL, but operational weight is significant: JVM heap, shards, replicas, mapping conflicts. Typesense nested fields are simpler: define `object` or `object[]`, filter by dotted path. Elasticsearch wins for complex aggregations or cross-index joins; Typesense wins for InstantSearch faceting on nested attributes without an ops team.

### Typesense Nested Fields vs Meilisearch (Meilisearch Alternative)

Meilisearch supports nested fields in filters but with limitations on deeply nested arrays and facet granularity. Typesense has stronger nested array handling and better InstantSearch compatibility for complex e-commerce schemas. Meilisearch wins on simplicity for flat documents; Typesense wins on nested object depth and facet fidelity.

### Typesense Nested Fields vs MongoDB Atlas Search (MongoDB Atlas Search Alternative)

MongoDB Atlas Search can index nested documents natively, but requires Atlas infrastructure and search-specific index definitions. Typesense is purpose-built for search — faceting, filtering, typo tolerance are first-class. Atlas Search wins if data already lives in MongoDB and you want one less service; Typesense wins on search performance, InstantSearch integration, and full self-hosting outside any cloud vendor.

## How to use Typesense Nested Fields (the OSS Nested Document Schemas)?

Define your collection schema with `object` and `object[]` field types. Every nested field you plan to filter or facet on needs an explicit definition using dot notation — Typesense doesn't auto-discover nested attributes.

Index documents with nested structure intact:

```json
{
  "name": "Wool Overshirt",
  "variants": [
    {"color": "red", "price": 89.99, "stock": 12},
    {"color": "blue", "price": 94.50, "stock": 0}
  ]
}
```

Query with `filter_by: variants.color:=red && variants.stock:>0` to return products with a red variant in stock. Facet with `facet_by: variants.color,variants.price`.

One gotcha: filtering on multiple nested fields applies across all objects in the array, not within a single object. So `variants.color:=red && variants.stock:>0` matches a product with a red variant and a different in-stock variant, even if the red one is out of stock. For within-object matching, restructure or post-filter client-side.

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

### Clone the Repository

Typesense is open source, but you don't need to build from source — the official Docker image is recommended. If you do want to build, clone `typesense/typesense` from GitHub and follow the README.

### Install Dependencies

For Docker, only Docker itself. On Ubuntu: `sudo apt install docker.io`. On macOS, install Docker Desktop. For from-source builds, you'll need C++ build tools and CMake.

### Configure Environment Variables

Set `TYPESENSE_API_KEY` to a long random string — treat it like a password. Never lose it; Typesense has no password reset, and losing it means wiping the data directory and reindexing. Set `TYPESENSE_ENABLE_CORS=true` if browser clients query directly.

### Start the Typesense Nested Fields Application

```
docker run -d \
  --name typesense \
  -p 8108:8108 \
  -v typesense-data:/data \
  -e TYPESENSE_API_KEY=your-long-random-key \
  typesense/typesense:30.2 \
  --data-dir /data --api-key=$TYPESENSE_API_KEY --enable-cors
```

Health check on port 8108, then create your collection schema with nested field definitions and start indexing.

## Official Pricing of Typesense Nested Fields (Typesense Nested Fields pricing)

Typesense the software is free under GPL-3.0. Typesense Cloud bills by dedicated RAM/vCPU hours plus bandwidth — no per-search fee. A 0.5 GB burst node is about $21.60/month; a 2 GB burst node is roughly $43-$51/month. Self-hosting on Railway means you pay only Railway compute plus volume, typically single-digit to low-teens USD per month for a small node.

## Typesense Neste

## Similar templates

- [Typesense PHP](https://railway.com/deploy/typesense-php) — official PHP client against Railway
- [Typesense vs Meilisearch](https://railway.com/deploy/typesense-vs-meilisearch) — self-hosted Typesense vs Meilisearch
- [Matomo Analytics + MariaDB](https://railway.com/deploy/matomo-analytics-mariadb) — Privacy-friendly analytics with MariaDB and persistent volumes.

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