Deploy PGroonga

Enable super-fast, multilingual full-text search within PostgreSQL.

Deploy PGroonga

/var/lib/postgresql

Deploy and Host PGroonga on Railway

Enable super-fast, multilingual full-text search within PostgreSQL.

About Hosting PGroonga

PGroonga is a PostgreSQL extension that adds advanced full-text search capabilities for all languages. Unlike PostgreSQL’s built-in full-text search, which mainly supports alphabets and digits, PGroonga can index and query text in languages such as Japanese or Chinese - all with zero ETL.

Also, PGroonga can instantly search newly inserted or updated data without reindexing or read locks, making it ideal for real-time workloads. Since it runs entirely inside PostgreSQL, it maintains ACID compliance, replication, and transaction safety.

Railway’s scalable infrastructure makes it easy to deploy PGroonga with automatic scaling, persistent storage, and one-click setup.

Common Use Cases

  • Multilingual Search Applications: Powering e-commerce sites, content platforms, and documentation systems that need instant, language-agnostic full-text search within PostgreSQL.
  • Real-Time Search Applications: Delivering low-latency search results on frequently updated data, such as chat logs, knowledge bases, or user-generated content, with immediate index updates and no read locks.
  • Integrated Search Infrastructure: Running directly inside PostgreSQL, PGroonga eliminates the need for separate search services. Teams can leverage their existing PostgreSQL operations and monitoring workflows, reducing maintenance overhead and simplifying infrastructure while gaining powerful full-text search capabilities.

Dependencies for PGroonga Hosting

None.

PGroonga is a self-contained PostgreSQL extension that integrates directly with the database engine. It requires no external services or dependencies and leverages PostgreSQL's built-in functionality to deliver high-performance, real-time full-text search across all languages.

Deployment Dependencies

Implementation Details

Setup Configuration

This template provides PostgreSQL with the PGroonga extension pre-installed. A TCP proxy is configured to allow access to the database from anywhere, enabling external connections to the PGroonga database.

Please configure the following environment variables according to your environment:

  • POSTGRES_USER
  • POSTGRES_PASSWORD
  • POSTGRES_DB

Database Connection

Use the DATABASE_URL variable from your Railway service to connect to the PGroonga database.

$ psql $DATABASE_URL

Or, if you want to reference it from another Railway service's variable, you can use it as the reference variables:

${{PGroonga.DATABASE_URL}}

How To Use

Once connected, enable the PGroonga extension using the following SQL:

CREATE EXTENSION pgroonga;

Create a full-text search index

Create a column that you want to enable full-text search on, using the text type.

CREATE TABLE memos (
  id integer,
  content text
);

Create a PGroonga index on the target column.

CREATE INDEX pgroonga_content_index ON memos USING pgroonga (content);

(Optional) Insert some sample data.

INSERT INTO memos VALUES (1, 'PostgreSQL is a relational database management system.');
INSERT INTO memos VALUES (2, 'Groonga is a fast full-text search engine that supports all languages.');
INSERT INTO memos VALUES (3, 'PGroonga is a PostgreSQL extension that uses Groonga as index.');
INSERT INTO memos VALUES (4, 'There is groonga command.');

Now your setup is complete! You can start running full-text searches instantly.

Full text search

You can use &@~ operator to perform full-text search:

SELECT * FROM memos WHERE content &@~ 'Groonga';

Result:

 id |                                content                                 
----+------------------------------------------------------------------------
  2 | Groonga is a fast full-text search engine that supports all languages.
  3 | PGroonga is a PostgreSQL extension that uses Groonga as index.
  4 | There is groonga command.
(3 rows)
Match all search words

Use spaces between words for AND search:

SELECT * FROM memos WHERE content &@~ 'Groonga PostgreSQL';

Result:

 id |                            content                             
----+----------------------------------------------------------------
  3 | PGroonga is a PostgreSQL extension that uses Groonga as index.
(1 row)
Match any search words

Use OR between words for OR search:

SELECT * FROM memos WHERE content &@~ 'PostgreSQL OR engine' ORDER BY id;

Result:

 id |                                content                                 
----+------------------------------------------------------------------------
  1 | PostgreSQL is a relational database management system.
  2 | Groonga is a fast full-text search engine that supports all languages.
  3 | PGroonga is a PostgreSQL extension that uses Groonga as index.
(3 rows)

Score

You can use the pgroonga_score function to get a relevance score for each record. Higher scores indicate stronger matches with the query terms.

SELECT *, pgroonga_score(tableoid, ctid) AS score
  FROM memos
 WHERE content &@~ 'PostgreSQL OR PGroonga'
 ORDER BY score DESC;

Result:

 id |                            content                             | score 
----+----------------------------------------------------------------+-------
  3 | PGroonga is a PostgreSQL extension that uses Groonga as index. |     2
  1 | PostgreSQL is a relational database management system.         |     1
(2 rows)

PGroonga provides many more features such as prefix search, highlighting, and JSON field search. See the official documentation for more information.

Resources

Why Deploy PGroonga on Railway?

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 PGroonga 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.


Template Content

More templates in this category

View Template
Postgres-to-R2 Backup
Auto back up PostgreSQL databases to Cloudflare R2 with optional encryption

View Template
ReadySet
A lightweight caching engine for Postgres

View Template
Simple S3
Deploy a S3-compatible storage service with a pre-named bucket.