Skip to content

Define Filter Language

3 min read | Last updated :

The platform provides support for advanced filtering through Kisai’s own filtering language. The language is simple to use and provides flexibility to query data in complex scenarios like accessing jsonb fields, recursive jsonbs, references.

NOTE

Kisai filtering language is not turing complete.

Filter Structure

Below is the basic structure for filtering

NameDescription
Field NameFields of the entity
OperatorOperation to be performed
Filter CriteriaFilter to be applied

Operators

Kisai provides support for the following operators.

NOTE

All operator keywords are case sensitive.

Comparison Operators

OperatorDescriptionExample
<Less Thanprice < 20
>Greater Thanquantity > 40
=Equalquantity = 100
<=Less than equalquantity <= 200
>=Greater than equalquantity >= 200
isTo check if value is null or booleanid is false
is notTo check if value is not null or booleanid is not null
notTo check if value is not null or booleanid not true

Pattern Matching

OperatorDescriptionExample
likeLikename like ‘sam%‘
notlikenot likename not like ‘A_b%‘
ilikeUse ilike to match for case insensitivename ilike ‘SAM%‘
not ilikeNot like with case insensitivename not ilike ‘%a_B_c%‘
match
not match
imatch
not imatch

Logical Operators

OperatorDescriptionExample
andReturns true only when all conditions are metid = 200 and name = ‘Peter’
orReturns true when any one of the condition is metid = 200 or name = ‘Peter’

IN Operator

OperatorDescriptionExample
inReturns true only when any of the value in the list is metid IN (200,300,400)

Index for Array Fields

Index operator can be used for fields which are array datatype.

OperatorDescriptionExample
indexOfReturns true when if the expression is metserviceoptions.array[]=‘Takeaway’

NOTE

Jsonb fields can be accessed using dot notation like pastaddresses.array[].city = ‘Hyderabad’

Example 1 - Filter by id

Let’s find out how the item with id = “01GE17TDS8DFPXF34ANP60JS53”

Request

1
URI : /data/rest/:entity?filter=id="01GE17TDS8DFPXF34ANP60JS53"

Response

1
{
2
"data": {
3
"items": {
4
...
5
"id": "01GE17TDS8DFPXF34ANP60JS53",
6
...
7
"itemname": "Deluxe Veggie",
8
...
9
}
10
}
11
}

Example 2 - Filter using like operator

Let’s find out items who have name like ‘%Veg%‘

Request

1
URI : /data/rest/:entity?filter=itemname like '%25Veg%25'

Response

1
{
2
"data": {
3
"items": {
4
...
5
"itemdesc": "Veg delight - onion, capsicum,grilled mushroom , corn & paneer",
6
"itemname": "Deluxe Veggie",
7
...
8
}
9
}
10
}

Example 3 - Filter using AND operator

Let’s find out all items which have veg (case insensitive) in their name and price is less than 600

Request

1
URI : /data/rest/:entity?filter=itemname ilike '%25veg%25' and price < 600

Response

1
{
2
"data": {
3
"items": [
4
{
5
...
6
"itemdesc": "Veg delight - onion, capsicum,grilled mushroom , corn & paneer",
7
"itemname": "Deluxe Veggie",
8
...
9
},
10
{
11
...
12
"itemdesc": "The fresh garden combination of lettuce, cucumber,tomato, onion and cheese",
13
"itemname": "The Special Veggie Club Sandwich",
14
...
15
}
16
]
17
}
18
}

Example 4 - Filter using indexOf

Let’s find all the outlets which support Dine in

Request

1
URI : /data/rest/:entity?filter=serviceoptions.array[] in ['Dine in']

Response

1
{
2
"data": {
3
"outlets": {
4
....
5
"outletid": "01GE1DBGFC8D8545YM6YXFWK6C",
6
"serviceoptions": [
7
"Takeaway",
8
"Dine in",
9
"No Contact Delivery"
10
],
11
...
12
}
13
}
14
}