Search Criteria
Search Criteria can be used to retrieve get list response of an entity based on specific conditions. Here are some samples for search criteria.
Fields
field refers to input entity fields for criteria construction.
Example
{
"field": "state.name",
"condition": "is",
"values": [
"In Store",
"In Use"
]
}
In the above example the possible values of the above criteria are In Store and In Use which is mentioned within an array.
Condition
Conditions are the operators for criteria construction.
Supported Conditions
| Description | Operator | Operator Short Hand |
|---|---|---|
| Equals | is | =, eq |
| Not Equal | is not | !=, neq |
| Greater than | greater than | gt |
| Greater than or Equal | greater or equal | gte |
| Less than | lesser than | lt |
| Less than or Equal | lesser or equal | lte |
| Range | between | |
| Not in Range | not between | |
| Starts with | starts with | |
| Ends with | ends with | |
| Contains | contains | |
| Not Contains | not contains |
Example
{
"field": "created_time",
"condition": "greater than",
"value": "1488451440000"
}
In the above example the greater than is the operator which refers to greater
than symbol (>).
Comparison – (field > value)
Value/Values
Value/Values provided in the value field depends on the data type of the field name and the operator used in the criteria.
- In case of multiple values, values key needs to be used.
- In case of single value, value key needs to be used.
Example (Value)
{
"field": "created_time",
"condition": "greater than",
"value": "1488451440000"
}
In the above example the value of the above criteria is Long which is based on the field created_time.
Example (Values)
{
"field": "state.name",
"condition": "is",
"values": [
"In Store",
"In Use"
]
}
In the above example the possible values of the above criteria are In Store and In Use which is mentioned within an array.
Children
The children criteria key holds sub criteria or nested criteria.
Example
{
"list_info": {
"row_count": 100,
"search_criteria": {
"field": "state",
"condition": "is",
"value": {
"id": "100000000000008033",
"name": "In Store"
},
"children": [
{
"field": "created_time",
"condition": "greater than",
"value": "1488451440000",
"logical_operator": "AND"
}
]
}
}
}
The conditional rule for the above search criteria is given below,
Criteria – (state = 'In Store' AND (created_time > 1488451440000))
1) A&B – A(and)B
The following list info object will retrieve all the unassigned assets with state “In repair”
{
"list_info": {
"row_count": 15,
"search_criteria": [
{
"field": "user",
"condition": "is",
"values": null
},
{
"field": "state.name",
"condition": "is",
"logical_operator": "and",
"values": [
"In Repair"
]
}
]
}
}
2) A&B&(C&D) - A(and)B(and)[C(and)D]
The following list info object will retrieve all the unassigned assets with state “In repair” created today
{
"list_info": {
"row_count": 15,
"search_criteria": [
{
"field": "user",
"condition": "is",
"values": null
},
{
"field": "state.name",
"condition": "is",
"logical_operator": "and",
"values": [
"In Repair"
]
},
{
"field": "created_time",
"condition": "greater than",
"logical_operator": "and",
"values": [
"1553731200000"
],
"children": [
{
"field": "created_time",
"condition": "lesser than",
"logical_operator": "and",
"values": [
"1553817599000"
]
}
]
}
]
}
}
3)(AB)&(CD) – [A(or)B]and[C(or)D]
{
"list_info": {
"row_count": 15,
"search_criteria": [
{
"field": "user",
"condition": "is",
"values": null,
"logical_operator": "AND",
"children": [
{
"field": "state.name",
"condition": "is",
"values": [
"In Store"
],
"logical_operator": "OR"
}
]
},
{
"field": "product.name",
"condition": "is",
"logical_operator": "AND",
"values": [
"Unknown workstation"
],
"children": [
{
"field": "asset_tag",
"condition": "starts_with",
"values": "ap",
"logical_operator": "OR"
}
]
}
]
}
}