- NULL / NOT NULL
- IDENT - comparing two columns
- LIKE and ILIKE
- (not) IN
- Regex
- Similarity
- tsquery
- JSONB contains (@>)
- Subtree
NULL / NOT NULL
To search for (not) NULL entries, use the null value in json:
#/data/extensions/widget/query
{ "conds" : {"me.query" : null }}
#/data/extensions/widget/query
"conds" : {
"me.query" : {
"-not" : null
}
}
IDENT - comparing two columns
#/data/system/entity/query
{ "conds" : {"me.name" : {"-ident": "module.name"}} }
WHERE ( me.name = module.name )
http://search.cpan.org/~ilmari/SQL-Abstract-1.84/lib/SQL/Abstract.pm#-ident
LIKE and ILIKE
#/data/system/entity/query
{ "conds" : {"me.name" : {"-like": "%a%"}} }
{ "conds" : {"me.name" : {"-not_like": "%a%"}} }
{ "conds" : {"me.name" : {"-ilike": "%a%"}} }
{ "conds" : {"me.name" : {"-not_ilike": "%a%"}} }
WHERE ( me.name like ? )
WHERE ( me.name not like ? )
(not) IN
#/data/system/entity/query
{ "conds" : {"me.name" : {"-in": [1,2]}} }
{ "conds" : {"me.name" : {"-not_in": [3,4]}} }
WHERE ( me.name in (?) )
WHERE ( me.name not in (?) )
Regex
The regex operators (~, !~, ~*, !~*) are supported:
#/data/system/entity/query
"conds" : {"me.name" : {"~*": "module.name"}}
WHERE ( me.name ~* ? )
If a column on a big table is not indexed correctly, this search option will not be allowed.
Similarity
This is an extension for IronAPI.
{"attrs" : {"order_by" : {"-similarity" : ["me.name","constant"]}, "columns" : "me.name"}}
This will be translated to sql ORDER BY me.name <-> ? : "constant".
If a column on a big table is not indexed correctly, this search option will not be allowed.
tsquery
This is an extension for IronAPI.
The attrs are just for reference, they are not needed for the search query!
#/data/system/entity/query
{
"conds" : {"-tsquery" : ["english","me.name","data"] },
"attrs" : {"+select" : "to_tsquery('english',me.name)", "+as" : "tsquery_name"}
}
will be translated to
WHERE ( to_tsvector(?,me.name) @@ to_tsquery(?, ? ) ): 'english', 'english', 'data'
If a column on a big table is not indexed correctly, this search option will not be allowed.
JSONB contains (@>)
This is an extension for IronAPI. Does the left JSONB value contain the right JSONB path/value entries at the top level?
#/data/core/customer/query
{
"conds" : {"me.phonenumbers" : {"@>" : {"mobile": "+4354359"} } }
}
Subtree
This is an extension for IronAPI.
For entities which represent a tree structure ("isTree": true in the universe), a search for a subtree of an element possible. The following will return all entries of the current entity which are "under" id 1, i.e. have either "1" or any of it's (children's) children as their parent:
{
"conds": {"me.id": {"-subtree": [1] }
}
The search may be limited to a certain depth, in this example it's "2", so only the main entry (with id "1") and it's direct children will be returned:
{
"conds": {"me.id": {"-subtree": [1, 2] }
}
It can be combined with other search options, like this for example:
{
"conds": [
{"me.id": {"-subtree": [1,2]}},
{"me.name" : {"-ilike" : "%a%"}}
]
}