These plugins are required to work with Postgres DB collections:
Plus general plugins which implementation may varies:
This is the list of modules (jars) used by Postgres DB collections:
Plus Postgres JDBC driver:
Resolving of DatabaseConnectionPool requires ConnectionOptions.
ConnectionOptions connectionOptions = new SomeConnectionOptions(); IPool pool = IOC.resolve(Keys.getOrAdd("DatabaseConnectionPool"), connectionOptions);
Connection options contains host, port of the server, database name, username and password.
Each collection corresponds to the table in the PostgreSQL database.
If the collection has no fulltext index it is created as this:
CREATE TABLE collection (document jsonb NOT NULL); CREATE UNIQUE INDEX collection_pkey ON collection USING BTREE ((document#>'{collectionID}'));
For each field with ordered index this is created:
CREATE INDEX ON collection USING BTREE ((document#>'{field}'));
For each field with datetime index this is created:
CREATE INDEX ON collection USING BTREE ((parse_timestamp_immutable(document#>'{field}')));
For each field with tags index this is created:
CREATE INDEX ON collection USING GIN ((document#>'{field}'));
If the collection has fulltext index it is created as this:
CREATE TABLE collection (document jsonb NOT NULL, fulltext tsvector); CREATE UNIQUE INDEX collection_pkey ON collection USING BTREE ((document#>'{collectionID}')); CREATE INDEX ON collection USING GIN (fulltext);
Also the trigger and the function collection_fulltext_update_trigger() are created.
This means fulltext search operation works only when the fulltext index was created and looks only to data of indexed fields.
Search queries start from SELECT document FROM collection.
In most cases the access to the field is done using path in the document.
WHERE (document#>'{field,nested}') = to_json(?)::jsonb