AQS Parameters
Get acquainted with AQS Parameters
AQS Parameters enable variables to be passed into a query and then used as part of the query definition, to build more dynamic queries.
Endpoints
AQS parameters affect the following endpoints:
-
POST /api/aqs/query
-
POST /api/aqs/join
-
POST /api/aqs/statistics
Examples
The following examples illustrate the use of AQS parameters.
Where you have a design, designs_testDesign
, which has an attribute, attributes_numberAttribute
and you want to search for items of this design with the attribute value as 123, this is how your request would look without parameters:
{
"properties": {
"dodiCode": "designs_testDesign",
"attributes": ["All"]
},
"children": [
{
"type": "Equals",
"children": [
{
"type": "Attribute",
"properties": {
"attributeCode": "attributes_numberAttribute"
}
},
{
"type": "Number",
"properties": {
"value": [123]
}
}
]
}
]
}
You can use parameters instead of directly using the search value 123 in the Number node as follows:
{
"aqs": {
"properties": {
"dodiCode": "designs_testDesign",
"attributes": ["All"],
"parameters": [
{
"name": "testParam",
"type": "Number",
"defaultValue": [456]
}
]
},
"children": [
{
"type": "Equals",
"children": [
{
"type": "Attribute",
"properties": {
"attributeCode": "attributes_numberAttribute"
}
},
{
"type": "Number",
"properties": {
"parameterName": "testParam"
}
}
]
}
]
},
"parameterValues": [{ "name": "testParam", "value": [123] }]
}
When using parameters, the AQS query itself is defined in the aqs
property. Under properties
, you can define an array of parameters, for example, with parameter testParam and set its name
, type
and defaultValue
.
In the Number node, you provide parameterName
as testParam.
Now at the end, you can define an array of parameterValues
which contain the names and values for the parameters to be used.
In the example illustrated, you can search for all items of designs_testDesign
with attributes_numberAttribute
value as 123.
If you do not specify a value for testParam
in parameterValues
, the query will return all items with attributes_numberAttribute
value as 456, because the parameter's definition declares defaultValue
as 456.
You can define as many parameters you want and use parameters in AQS in place of any primitive nodes.