ZomboDB
Updated at:
ZomboDB is a PostgreSQL extension that provides powerful text indexing and analysis features for PostgreSQL databases.
Prerequisites
PolarDB for PostgreSQL instance must be compatible with PostgreSQL 11.Background information
ZomboDB provides a comprehensive query language to query relational data. You can also create ZomboDB-type indexes. When you create these indexes, ZomboDB takes full control of the remote Elasticsearch instance and ensures transactional correctness for text searches.
ZomboDB lets you directly use the powerful features of Elasticsearch without needing to manage issues such as synchronization and communication.
Create and delete the extension
- Create the extension
CREATE EXTENSION zombodb; - Delete the extension
DROP EXTENSION zombodb;
Example
- Create a table.
CREATE TABLE products ( id SERIAL8 NOT NULL PRIMARY KEY, name text NOT NULL, keywords varchar(64)[], short_summary text, long_description zdb.fulltext, price bigint, inventory_count integer, discontinued boolean default false, availability_date date ); - Add a ZomboDB-type index to the table.
CREATE INDEX idxproducts ON products USING zombodb ((products.*)) WITH (url='localhost:9200/');Note- ZomboDB does not support Elasticsearch 7.x or 8.x instances.
WITHclause is followed by the address of an active Elasticsearch instance.
- Run a query using a ZomboDB-formatted query statement.
SELECT * FROM products WHERE products ==> '(keywords:(sports OR box) OR long_description:"wooden away"~5) AND price:[1000 TO 20000]';Note For more information about the ZomboDB query language, see the official ZomboDB documentation.
Is this page helpful?