This is a document for PGroonga 2.0.0 or later. See PGroonga 1.X document when you're using PGroonga 1.X.
This guide explains how to use the Railway template. The Railway’s scalable infrastructure makes it easy to deploy PGroonga with persistent storage and one-click setup.
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.
Security note: The TCP proxy makes your database reachable from the public internet. Please take the following precautions before using this template for production workloads:
Please configure the following environment variables according to your environment:
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:
$
Once connected, enable the PGroonga extension using the following SQL:
CREATE EXTENSION pgroonga;
Create a table with a text column that you want to enable full-text search on.
CREATE TABLE memos (
id integer,
content text
);
Create a full-text search index with PGroonga 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.');
Run a full-text search query.
SELECT * FROM memos WHERE content &@~ 'groonga';
-- 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)
Now your setup is complete! You can start running full-text searches instantly.