Search
Search is used to retrieve data from the MelodyArc Platform. Searches are executed via the Search API, and can be run one time or saved for repeated use.
Below is an example of a one-time search
curl --location 'https://<<DOMAIN>>.melodyarc.app/api/v1/search/bot_configuration' \
--header 'Content-Type: application/json' \
--header 'x-api-key: <<API_KEY>>' \
--data '{
"filters": [
{
"key": "organization_id",
"operator": "eq",
"value": "org_667b209656ec780a477b3335"
}
],
"fields": [
"_id",
"task_id",
"task_type",
"data.crm.id
],
"sort": {
"key": "_id",
"order": "desc"
},
"limit": 50
}'
Defining a Search
The Search API requires a type
to be set and at least one filter
to be defined. Optionally, fields
, sort
and a limit
can be set.
Type
Supported search types are:
- code: Returns code points
- invoke: Returns invoke points
- value: Returns value points
- bot_config: Returns configurations
- task: Returns platform tasks
- component: Returns components rendered for the Portal
Filters
Searches use an array of one or more filters to refine results.
The structure of filters is:
- key: path of key in token
- operator: a supported operator type
- value: value the operator evaluates against the value found in the key
- data_type: Optional - add a value of
date
if a date or date based value is evaluated
Example
"filters": [
{
"key": "db_updated",
"operator": "between",
"data_type": "date",
"value": [
`${startTime.toISOString()}`,
`${endTime.toISOString()}`
]
},
{
"key": "bot_name",
"operator": "eq",
"value": "cx_default_configuration"
},
{
"key": "completed_at",
"operator": "gt",
"value": 0
},
{
"key": "completed_by",
"operator": "like",
"value": "auth0"
},
{
"key": "component.friendly_name",
"operator": "nin",
"value": [
"debug",
"test"
]
}
]
Operator Types
-
eq
(equal):- Checks if the value is equal to the specified value.
- Example:
"key": "status", "operator": "eq", "value": "active"
matches records where the status is exactly "active".
-
ne
(not equal):- Checks if the value is not equal to the specified value.
- Example:
"key": "status", "operator": "ne", "value": "inactive"
matches records where the status is not "inactive".
-
gt
(greater than):- Checks if the value is greater than the specified value.
- Example:
"key": "age", "operator": "gt", "value": 18"
matches records where age is greater than 18.
-
gte
(greater than or equal to):- Checks if the value is greater than or equal to the specified value.
- Example:
"key": "age", "operator": "gte", "value": 18"
matches records where age is 18 or greater.
-
lt
(less than):- Checks if the value is less than the specified value.
- Example:
"key": "age", "operator": "lt", "value": 18"
matches records where age is less than 18.
-
lte
(less than or equal to):- Checks if the value is less than or equal to the specified value.
- Example:
"key": "age", "operator": "lte", "value": 18"
matches records where age is 18 or less.
-
in
(in list):- Checks if the value is within a specified list of values.
- Example:
"key": "status", "operator": "in", "value": ["active", "pending"]
matches records where status is either "active" or "pending".
-
nin
(not in list):- Checks if the value is not within a specified list of values.
- Example:
"key": "status", "operator": "nin", "value": ["inactive", "archived"]
matches records where status is neither "inactive" nor "archived".
-
like
(like):- Checks if the value matches a specified pattern (case-sensitive).
- Example:
"key": "name", "operator": "like", "value": "%John%"
matches records where the name contains "John".
-
nlike
(not like):- Checks if the value does not match a specified pattern (case-sensitive).
- Example:
"key": "name", "operator": "nlike", "value": "%John%"
matches records where the name does not contain "John".
-
ilike
(case-insensitive like):- Checks if the value matches a specified pattern, ignoring case.
- Example:
"key": "name", "operator": "ilike", "value": "%john%"
matches records where the name contains "john", case-insensitively.
-
nilike
(case-insensitive not like):- Checks if the value does not match a specified pattern, ignoring case.
- Example:
"key": "name", "operator": "nilike", "value": "%john%"
matches records where the name does not contain "john", case-insensitively.
-
between
(between):- Checks if the value is within a specified range (inclusive).
- Example:
"key": "age", "operator": "between", "value": [18, 30]
matches records where age is between 18 and 30, inclusive.
-
nbetween
(not between):- Checks if the value is not within a specified range.
- Example:
"key": "age", "operator": "nbetween", "value": [18, 30]
matches records where age is not between 18 and 30.
Fields
Reduce returned results to a set of keys. Supports paths via dot notation. If empty, all keys will be returned.
Example
"fields": [
"_id",
"task_id",
"task_type",
"data.crm.id"
]
Sort
Sort returned results by a key either ascending (asc
) or descending (desc
)
"sort": {
"key": "_id",
"order": "desc"
}
Limit
Set a max number of results. Max value can be 5000
.
"limit": 50
Updated about 1 month ago