jsquery
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
jsquery | 1.2 | FEAT | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 2770 | jsquery | No | Yes | No | Yes | No | Yes | - |
| Related | pgbson pgjq pg_jsonschema jsonschema pg_projection documentdb mongo_fdw jsonb_plperl jsonb_plpython3u jsonb_plperlu |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PGDG | 1.2 | 1817161514 | jsquery | - |
| RPM | PGDG | 1.2 | 1817161514 | jsquery_$v | - |
| DEB | PGDG | 1.2 | 1817161514 | postgresql-$v-jsquery | - |
Install
You can install jsquery directly. First, make sure the PGDG repository is added and enabled:
Install the extension using pig or apt/yum/dnf:
Create Extension:
Usage
JsQuery provides a query language for JSONB data, similar to what tsquery does for full-text search. It offers a concise way to search nested objects and arrays with index support via GIN.
Operators
| Operator | Description |
|---|---|
@@ | Match operator: test whether a jsonb value matches a jsquery expression |
Query Syntax
Expressions follow the pattern path operator value:
Binary operators:
=(equality),>,>=,<,<=(comparison)IN(list membership)&&(overlap),@>(contains),<@(contained in)
Unary operators:
= *(existence check)IS ARRAY,IS NUMERIC,IS OBJECT,IS STRING,IS BOOLEAN(type checking)
Path Expressions
| Symbol | Meaning |
|---|---|
# | Any array index |
#N | Specific array index N |
% | Any object key |
* | Any sequence of keys/indexes |
@# | Array/object length |
$ | Entire document |
“Every” semantics (all elements must match):
#:– all array elements%:– all object keys*:– all nested paths
Examples
Simple value matching:
Logical combinations:
Array element matching (find array elements where both conditions hold):
Object key range matching:
GIN Indexing
Two operator classes for different query patterns:
Optimizer hints for index usage:
Schema Validation via CHECK Constraints
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)