ZomboDB is a Postgres extension that enables efficient full-text searching via the use of indexes backed by Elasticsearch.
This repo build a docker image which integrate ZomboDB extension with Postgres.
You can pull docker image from my docker hub repo.
docker pull dldldldl/zombodb
Or build your own by command:
docker build --build-arg="PG_VER=13" -t <your_tag_name> .
The build argument PG_VER
is optional, 12
, 13
, 14
, 15
are available, default value is 13
.
-
Docker container You can run docker container by command:
docker run -e POSTGRES_PASSWORD=postgresql -p 5432:5432 -d dldldldl/zombodb
Or by docker compose (please refer to
docker-compose.yml
). _Image usage please refer to postgres_ -
Create extension
You should first create zombodb extension into your database. Sample SQL:
CREATE EXTENSION zombodb;
-
Create table with index
Create table sample SQL:
CREATE TABLE sample_table ( id serial, content zdb.fulltext NOT NULL, -- column with `zdb.fulltext` type timstamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP );
Create index sample SQL:
CREATE INDEX idx_sample_table ON sample_table USING zombodb ((sample_table.*)) WITH (url='http://elasticsearch:9200/')
Notice that if your Elasticsearch server required user auth, you can pass username/password in URL format like
http://username:password@elasticsearch:9200/
-
Query data with full-text search
Sample SQL:
SELECT * FROM sample_table WHERE sample_table ==> 'some keywords';