The advanced search query definition
Main structure
- The version of the JSON format of the advanced search query definition
(
jsonFormatfield) - Where to perform the search (
datasourcefield) - Whose data must be searched (
populationfield) - What extra conditions the source entries must match to be returned by the search
(
filtersfield) - How to format and to present the results (
outputfield)
jsonFormat
The jsonFormat field includes the version of the JSON format of the advanced
search query definition.
v1: It defines the initial format of the JSON format and is the default value. When using this format, you must always declare fields in your query by using a simple string representing the field name. In this format, no support is available for business data fields that are defined at the task level (exposed from client-side human services) and you can reference only the following:- The following APIs return the Business data variables that are defined at the process instance
level:
- Business Automation Workflow:
/rest/bpm/federated/v1/searches/tasks/meta/businessDataFields - Process Federation Server:
/rest/bpm/federated/v1/searches/tasks/meta/businessDataFields
- Business Automation Workflow:
- The following APIs return the system fields:
- Business Automation Workflow:
- Fields:
/rest/bpm/wle/v1/searches/tasks/meta/fields - Constraints:
/rest/bpm/wle/v1/searches/tasks/meta/constraintFields
- Fields:
- Process Federation Server:
- Fields:
/rest/bpm/federated/v1/searches/tasks/meta/fields - Constraints:
/rest/bpm/federated/v1/searches/tasks/meta/constraintFields
- Fields:
- Business Automation Workflow:
- The following APIs return the Business data variables that are defined at the process instance
level:
v2: This version of the format is added in Business Automation Workflow 25.0.0 and provides the support of variables that are defined at the task level (exposed from client-side human services). In this format, when you declare fields to output, to filter on using thefilters.json_querysection, to use as an alias or to sort on, you must provide the field name and the field kind that can be set toSystem,Instance, orTask.
{
"name": "customer",
"kind": "Instance"
}
- Business Automation Workflow:
/rest/bpm/federated/v1/searches/tasks/meta/businessDataFields?includeTaskFields=true - Process Federation Server:
/rest/bpm/federated/v1/searches/tasks/meta/businessDataFields?includeTaskFields=true
- Business Automation Workflow:
- Fields:
/rest/bpm/wle/v1/searches/tasks/meta/fields - Constraints:
/rest/bpm/wle/v1/searches/tasks/meta/constraintFields
- Fields:
- Process Federation Server:
- Fields:
/rest/bpm/federated/v1/searches/tasks/meta/fields - Constraints:
/rest/bpm/federated/v1/searches/tasks/meta/constraintFields
- Fields:
datasource
datasource section includes the following fields that are all optional:datatype(string) defines the type of data to retrieve:TASKSorINSTANCES.TASKSis the default value.systemTypes(array of strings) defines the type of systems where the data is to be retrieved from:Process,BPEL,Case. The default value depends on the type of data:ProcessandBPELfor tasksProcessandCasefor instances
systemFilter(object) defines a list of systems to include or not when searching. This is an object with two fields (arrays of strings),includesandexcludesto list IDs of systems to include or exclude for the search.
datasource section to search for
BPD (Process) and BPEL tasks on all systems except the one with system ID
"4a8a5317-808e-48fe-964e-ff489ed356ce":"datasource": {
"datatype": "TASKS",
"systemTypes": ["Process", "BPEL"],
"systemFilter": {
"excludes": ["4a8a5317-808e-48fe-964e-ff489ed356ce"]
}
}datasource section to search for case
instances on all systems:"datasource": {
"datatype": "INSTANCES",
"systemTypes": ["Case"]
}population
population section defines which tasks and instances must be returned by the
search and can contain a single field that is named target, which can take one of
these following values:SELF: Returns tasks and instances that are either owned by or available to the current user.MANAGED_TEAMS: Returns tasks and instances that are either owned by or available to users who belong to teams managed by the current user.
population
section:"population": {
"target": "SELF"
}filters
filters section are
returned by the search. The filters section includes the following fields that are
all optional:interaction(string) leverages private fields to allow easy filtering by state. It is the equivalent of theinteractionfield of Saved Searches and supports the same values:claimed: Tasks that have been claimed and are not yet completed (not valid for instances search)available: Tasks that have not yet been claimed and are not yet completed (not valid for instances search)claimed_and_available: Tasks that are not yet completed (not valid, for instance, search)completed: Tasks or instances that are completedactive: Instances that are not yet completed (not valid for task search)failed: Instances that are failed (not valid for task search)all: All tasks and instances whatever their current state.
all.caseScope(string) is the scope of the search for case instances. Possible values are:Allowed: all case instances that the population is allowed to seeAssigned: only case instances that are assigned to the population
Assigned.v1_conditions: Saved Search conditions (array of conditions that must all match)v1_queryFilter(string): SQL-like syntax, same as the queryFilter parameter of GET /v1/tasks and PUT /v1/instances REST API.v1_searchFilter(string): full text search syntax, same as thesearchFilterparameter of the GET /v1/tasks REST API.Note:The
v1_conditions,v1_queryFilterand,v1_searchFilterfields ease the migration from the V1 saved searches to the V2 advanced search queries and from now on use the new syntax available by using thejson_queryfield.In the v1_* fields, whichever value is given to
jsonFormat, system fields, and business data variables are only referenced as a simple string representing their name. The v1_* fields do not provide any support for business data variables that are defined at the task level.json_query(object): New JSON syntax that supports AND, OR, and NOT combination of conditions. Thejson_queryfilter is a JSON Object (tree). The fields are conditions (field, operator, value) that can be combined with and, or, and not.The following example illustrates a query in JSON syntax (v2 format):"json_query": { "not": { "or": [ { "field": { "name": "taskPriority", "kind": "System" }, "operator": "GreaterThan", "value": 100 }, { "and": [ { "field": { "name": "customer", "kind": "Instance" }, "operator": "Equals", "value": "ACME corp." }, { "field": { "name": "product", "kind": "Task" }, "operator": "Equals", "value": "CP4BA" } ] } ] } }
filters section to retrieve claimed
tasks that have a priority higher than 100, and that have at least one field that includes the
"ACME" word (full-text search across all the task fields values):
"filters": {
"interaction": "claimed",
"json_query": {
"and": [
{
"field": {
"name": "taskPriority",
"kind": "System"
},
"operator": "GreaterThan",
"value": 100
},
{
"operator": "FullTextSearch",
"value": "ACME"
}
]
}
}"filters": {
"interaction": "claimed",
"json_query": {
"field": {
"name": "taskPriority",
"kind": "System"
},
"operator": "GreaterThan",
"value": 100
},
"v1_searchFilter": "ACME"
}output
output section defines how to present the results, based on the following
fields that are all optional:fields: Array of fields to return for each task or instance. IfjsonFormatis set to “v2”, then the fields to return must be specified with the field name and the field kind that can be set to System, Instance, or Task.Example:"fields": [ { "name": "taskPriority", "kind": "System" }, { "name": "customer", "kind": "Instance" }, { "name": "product", "kind": "Task" } ]If
jsonFormatis not set or set to “v1”, the fields value is an array of strings:Example:"fields": ["taskPriority","customer"]includeAllBusinessData(Boolean): Return all business data fields at once.falseis the default value.usersFullName(Boolean): Specifies how to format the user's information in the results (full name or user ID).trueis the default value.aliases(array of objects): List of aliases. IfjsonFormatis set to “v2”, then each alias is defined with the field name and the field kind that can be set to System, Instance or Task, and the alias name.Example:"aliases": [ { "field": { "name": "product", "kind": "Task" }, "alias": "myAlias" } ]If
jsonFormatis not set or set to “v1”, the fields value is an alias is simply defined with the field name and the alias name.Example:"aliases": [ { "field": "product", "alias": "myAlias" } ]sort(array of objects): Specifies how to sort the results. Each object in the array has the following two properties:- Field that identifies the field to sort on. If
jsonFormatis set to “v2”, then the field value is a JSON object with name and kind properties. IfjsonFormatis not set or set to “v1”, the field value is a simple string. - Order (string), either ASC or DESC (default to ASC) depending on whether the results should be sorted by ascending or descending field value.
- Field that identifies the field to sort on. If
alphabeticalSort(string): sort by alphabetical versus lexicographical order (for string fields that are referenced in thesortfield).size(integer): maximum number of results in the response (the default number is 25).stats(object): statistics to return with the results. Currently, there is a single type of statistics that can be returned (same than when executing a Saved Search with thecalcStatsparameter set totrue), specified by setting thetype(string) parameter of thestatsobject toBasic
output section for a task search
requesting task narrative, task ID, instance ID, task at risk time and all business data for the
matching tasks, which are sorted by ascending task at risk time, with a maximum of 50 results, and
basic statistics alongside the results:"output": {
"fields": [
{
"name": "taskNarrative",
"kind": "System"
},
{
"name": "taskId",
"kind": "System"
},
{
"name": "instanceId",
"kind": "System"
},
{
"name": "taskAtRiskTime",
"kind": "System"
}
],
"includeAllBusinessData": true,
"sort": [
{
"field": {
"name": "taskAtRiskTime",
"kind": "System"
},
"order": "ASC"
}
],
"size": 50,
"stats": {
"type": "Basic"
}
}Reusable search queries metadata
Similarly to Saved Searches, advanced search queries definitions can be stored and shared with team, by using the Reusable search queries REST API.
metadata
metadata (object) field, which has
the following fields: name(string): a mandatory unique name for the reusable search query;description(string): an optional description for the reusable search query;sharing(object): optional information about the reusable search query is shared. It includes the following fields:shared(Boolean):trueto share with other users,false(default value) otherwiseteams(array of objects): list of process teams to share the search query with. Ifnull,undefinedor empty whilesharedistrue, then the search query is shared with everybody. To share with a specific process team that you are a member or manager of, define this team in the array (currently, a single value is supported) by using an object with fieldteamIdfor the process team identifier.
owner(object): information about the user that owns the reusable search querycreator(object): information about the user that created the reusable search querylastUpdater(object): information about the user that last updated the reusable search querycreationDate(string): ISO8601 timestamp of when the reusable search query was createdlastUpdateDate(string): ISO8601 timestamp of when the reusable search query was last updated
metadata section for a reusable
search query: "metadata": {
"name": "my tasks list",
"description": "a search query that retrieves my task list",
"sharing": {
"shared": true,
"teams": [{
"teamId": "24.6615a4b0-fd38-4ea5-8bc0-69d2f107369e",
"teamName": "Human Resources",
"processAppName": "Hiring Sample"
}]
},
"owner": {
"id": "jane.doe@acme.com",
"fullName": "Jane Doe"
},
"creator": {
"id": "admin@acme.com",
"fullName": "Administrator"
},
"lastUpdater": {
"id": "user.name@ibm.com",
"fullName": "User Name"
},
"creationDate": "2024-01-31T12:34:42.183Z",
"lastUpdateDate": "2024-02-01T16:03:12.874Z"
}