To search items possessing certain property, use the command core/search_items:
svc=core/search_items¶ms={"spec":{ "itemsType":<text>, "propName":<text>, "propValueMask":<text>, "sortType":<text>, "propType":<text> }, "force":<uint>, "flags":<long>, "from":<uint>, "to":<uint>, "or_logic":<bool>}
You can find an example of this request in the sample Item search.
Name | Description |
---|---|
spec | search specification |
itemsType | item type (see the list below) |
propName | name of the property which value will be searched (see the list of possible properties below) |
propValueMask | property value mask (character “*” can be used) |
sortType | name of the property used for sorting |
propType | property type (see the list of property types below) |
force | 0 - if such search has been done, then return cached result, 1 - to do a new search |
flags | data flags for the response (the value of this parameter depends on item type; data formats of all item types and their flags are described in the chapter Data format) |
from | index of the first returned item (for new search use 0) |
to | index of the last returned item (if 0 - return all elements beginning from index specified in the “from” parameter) |
or_logic | “OR”-logic flag for propName (see below) |
Item types (field “itemsType”):
Properties of item (fields “propName” and “sortType”):
sys_account_disabled
, UNIX-time;For more values of this parameter, please see the table below.
Property types (field “propType”):
If you need to perform a search in subitems, set the value propitemname for the parameter “propType”. Then, other parameters can have any of these values:
Item (field "itemsType") | Subitem (fields "propName" and "sortType") |
---|---|
avl_unit | unit_sensors |
unit_commands | |
service_intervals | |
avl_resource | drivers |
driver_groups | |
jobs | |
notifications | |
pois | |
trailers | |
trailer_groups | |
zones_library | |
reporttemplates | |
avl_route | rounds |
route_schedules | |
avl_retranslator | retranslator_units |
avl_unit or user or avl_resource | custom_fields |
admin_fields |
By default sorting (direct) works like this:
special sorting
below);Direct (return values by ascending):
"sortType":"<item_property>"
Reverse (return values by descending):
"sortType":"!<item_property>"
Combined (return values sorted by the 1st criterion, then in case of values equality by the 2nd criterion etc):
"sortType":"<property1>,!<property2>"
Special: according to this sorting “-” symbol treated like negative number sign (by default “-” is treated like “hyphen” – simply a symbol):
"sortType":"-<item_property>"
You may do multicriteria search.
Example:
"itemsType":"avl_resource","propName":"rel_is_account,*","propValueMask":"1,qwe","sortType":"sys_name","propType":"property,customfield"
The number of criteria in “propName”, “propType” and “propValueMask” should be the same, because they are calculated by three, respectively.
“AND”-logic is worked by default for propName
. It means that the system will find all accounts (rel_is_account:1) which name starts with “foo” (sys_name:“foo*”).
In order to enable “OR”-logic for propName
please state or_logic
:1 in request.
In propValueMask parameter you may use comparison operatorls like <, >, =, >=, ⇐.
If search criterion is string field then the system will search for numbers in the beginning of such value only.
If search criterion is number field then all value will be analyzed.
Example 1:
"itemsType":"avl_unit","propName":"sys_name,sys_name","propValueMask":">=32,<33.5"
Units which name starts with numbers between 32 and 33.5 will be found.
Example 2:
"itemsType":"avl_resource","propName":"sys_account_balance,sys_account_balance","propValueMask":">2,<=23"
Resources and accounts which balance bigger than 2 and less or equal to 23 will be found.
You may also use “=” operator in case when value starts with “>” or “<”.
Example 3:
"itemsType":"avl_unit","propName":"sys_name","propValueMask":"=>123<,=<123>"
Search will find units with '>123<' and '<123>' names (if they exist).
{ "searchSpec":{ /* search specification */ "itemsType":<text>, /* items type */ "propName":<text>, /* property name */ "propValueMask":<text>, /* property value mask */ "sortType":<text>, /* property name for sorting */ "propType":<text> /* property type */ }, "dataFlags":<uint>, /* applied data flags */ "totalItemsCount":<uint>, /* quantity of found items */ "indexFrom":<uint>, /* beginning index */ "indexTo":<uint>, /* ending index */ "items":[{...}] /* found items */ }
The format of “items” array depends on item type. All formats are described in the chapter Data format.
|