Search Criteria
Data being returned from an API call may be filtered to a specific subset before being returned based on a search string passed to the API in the request body using the searchCriteria request parameter. A filter is applied as filterName(fieldname,comparisonValue) where the comparison value is applicable based on the filter being used.
Syntax: filterName(fieldname,comparisonValue)
For example, searchCriteria: "where equals(menuItems.active,Y)" would return the menu items records which are in active state.
Using Multiple Search Criteria
Multiple search criteria may be strung together using 'AND' and 'OR' logical operators, and grouped by using parentheses in case of nested search criteria.
Syntax: filterName(fieldname,comparisonValue) <Logical Operator> filterName(fieldname,comparisonValue)
For example searchCriteria: "equals(active,1)" will limit the response to only contain rows where the top level field 'active' has a value of 1, and the statement searchCriteria: "(equals(active,1) and equals(type,1))" would further limit the response to only rows that were both active and of type 1.
Negating the Filter Condition
The symbol '!' may be applied to mean 'NOT' to any filter which would reverse the filter condition.
Syntax: !(filterName(fieldname,comparisonValue))
For example, the statement searchCriteria: "!(equals(active,1))" would further limit the response to the rows that were not active.
Search Criteria Filters
Request and Response from Menu Item Master API
URL: baseURL/config/sim/v1/menuItems/getMenuItemMasters
HTTP Method: POST
Request
{
"hierUnitID": 1,
"searchCriteria": "where equals(objectNum,1000)",
"include": "hierUnitID,name",
"languages": "en-US,es-SS,lt-LT",
"offset":0,
"limit":10,
"orderBy": "objectNum:asc"
}
Response
{
"totalResults": 100,
"hasMore": true,
"count": 9,
"items": [{
<Menu Item Master Object>
}],
"offset":0,
"limit":10
}
To filter the response, the following search criteria filters are available to be used in the API request:
Filter Name | Filter Description | Data Type Supported | Parameter 1 | Parameter 2 | Example |
---|---|---|---|---|---|
equals |
Searches for records where specified column's value is exactly equal to the comparison value |
All |
Column Name |
Comparison value |
equals(guestChecks.chkNum,7) |
equalsIgnoreCase |
Searches for records where specified column's value is equal to the comparison value without considering the string value's case |
String |
Column Name |
Comparison value |
equalsIgnoreCase(guestChecks.chkName,'Paul's Tab') |
greaterThan |
Searches for records where specified column's value is greater than the comparison value |
Any numeric type |
Column Name |
Comparison value |
greaterThan(guestChecks.dscTtl,0) |
lessThan |
Searches for records where specified column's value is lesser than the comparison value |
Any numeric type |
Column Name |
Comparison value |
lessThan(guestChecks.chkTtl, 5) |
isNull |
Searches for records where specified column's value is "null" |
All |
Column Name |
N/A |
isNull(guestChecks.tblName) |
contains |
Searches for records in a case insensitive manner where specified column's value contains the comparison value |
String |
Column Name |
Comparison value |
contains(guestChecks.chkInfo,'review') |
startsWith |
Searches for records where specified column's value starts with the comparison value |
String |
Column Name |
Comparison value |
startsWith(guestChecks.chkName,'Paul') |
endsWith |
Searches for records where specified column's value ends with the comparison value |
String |
Column Name |
Comparison value |
endsWith(guestChecks.chkName,'Tab') |
Search Criteria Considerations
Search criteria is applied on the entire result set and matching records are returned as per the default inclusion or parameters mentioned in the "include" request parameter.
The type of data applied for "comparisonValue" must be of the same as the underlying type of "fieldName"
Strings should be enclosed in single quotes when used in the "comparisonValue".
Nested objects must be indicated by prepending the parent object name(s) to the field.
For example, the response returned inside the RVCs listed may be limited based on Service Charge Number 12345 by passing "searchCriteria: equals(revenueCenters.serviceCharges.svcNum,12345)" in the API request body.
{ "locRef":"1234", "busDt: "2020-07-20", "revenueCenters":[{ "rvcNum": 1372, "serviceCharges":[{ "svcNum": 12345, "ttl": 1234.56, "cnt": 123 }] } |