ThingWorx Model Definition in Composer > System > Subsystems > Utilization Subsystem > Using the GetPropertyVTQCount Service
Using the GetPropertyVTQCount Service
The GetPropertyVTQCount service returns a count of Thing properties defined on a Thing, Thing Template, or Thing Shape that have been ingested or set within ThingWorx at run time. The service queries a select count from the ThingWorx platform’s property_vtq property persistence provider database table. This count result can help determine how to optimize the performance of queries or the ingest of property values due to the total number of indexed property values of a given name, ThingWorx basetype, on a given entity name, etc. at run time. Query and ingest can be affected by database indexing of these property_vtq values.
Service Details
Details
Description
Returns the count of properties specified by the query criteria.
Parameters
query
QUERY base type
See Supported Query Filter Tuple Elements for acceptable values.
Result (invalid query parameter)
Error message stating invalid query.
Result (valid query parameter)
Number
Supported Query Filter Tuple Elements
The GetPropertyVTQCount service supports five element types: entityNameMask, entityTypeMask, propertyNameMask, propertyBaseType, and propertyIsIndexed within its query filters.
* 
These element types are case sensitive.
A combination of the five element types can be passed to the GetPropertyVTQCount service and are called filter tuples. They are implemented as a ThingWorx filter collection like the following:
{ "filters": [ {...}, {...}], "type": "AND" }
Where { ... } is one element type filter. In this example, there are two element type filters within a filter tuple that must be defined as an AND ThingWorx filter collection.
In the table below,
Each of the following element type filters can only exist 0 or 1 times per filter tuple.
Within one element type filter, one defines three fields (for example fieldName, type, value).
For any field that has a suffix of Mask, the values can contain wildcard characters/asterisks.
Field Name (Element Type)
Type
ValueType
Description
Example Value(s)
JSON Examples
entityNameMask
LIKE
STRING
Optional field. The entityNameMask is a name of an implicit field.
Its value type must be a STRING that contains the name of the entity as the value to select only records in the property_vtq that is LIKE the value specified.
*
Thing1
*hing1*
{ "fieldName": "entityNameMask", "type": "LIKE", "value", "*" }
{ "fieldName": "entityNameMask", "type": "LIKE", "value", "Thing1" }
{ "fieldName": "entityNameMask", "type": "LIKE", "value", "*hing1*" }
entityTypeMask
LIKE
STRING
Optional field. The entityTypeMask is a name of an implicit field.
Its value type must be a STRING that contains the type of the entity as the value to select only records in the property_vtq that is LIKE the value specified.
* 
While many entity types can only specify one type, Thing or the wild card version of that string will return any count data. For other entity types, no matches will be found and a zero count is likely.
*
Thing
*hin*
{ "fieldName": "entityTypeMask", "type": "LIKE", "value", "*" }
{ "fieldName": "entityTypeMask", "type": "LIKE", "value", "Thing" }
{ "fieldName": "entityTypeMask", "type": "LIKE", "value", "*Thin*" }
propertyNameMask
LIKE
STRING
Optional field. The propertyNameMask is a name of an implicit field.
Its value type must be a STRING that contains the name of the property that as the value to select only records in the property_vtq that is LIKE the value specified.
*
prop1
*rop1*
*erialNumber
model*umbe*
{ "fieldName": "propertyNameMask", "type": "LIKE", "value", "*" }
{ "fieldName": "propertyNameMask", "type": "LIKE", "value", "prop1" }
{ "fieldName": "propertyNameMask", "type": "LIKE", "value", "*rop1*" }
{ "fieldName": "propertyNameMask", "type": "LIKE", "value", "*erialNumber" }
{ "fieldName": "propertyNameMask", "type": "LIKE", "value", "model*umbe" }
propertyBaseType
LIKE
STRING
Optional field. The propertyBasetype is a name of an implicit field.
* 
This is not a NameMask allowed value.
Its value type must be a STRING that contains the name of a valid base type as the value to select only records in the property_vtq that is LIKE the value specified.
If propertyIsIndexed is true, then the propertyBaseType value must be a valid indexable base type friendly name of one of the following:
STRING
NUMBER
INTEGER
LONG
BOOLEAN
DATETIME
THINGNAME
USERNAME
GROUPNAME
HYPERLINK
MASHUPNAME
MENUNAME
DASHBOARDNAME
TEXT
GUID
NOTIFICATIONCONTENTNAME
NOTIFICATIONDEFINITIONNAME
STYLETHEMENAME
THINGGROUPNAME
If propertyIsIndexed is false, then one of the following can be specified:
PASSWORD
INFOTABLE
LOCATION
IMAGE
XML
JSON
QUERY
HTML
BLOB
VEC2
VEC3
VEC4
THINGCODE
thingname
thingNaMe
THINGNAME
THINGNamE
String
STRING
BOOLean
Boolean
veC2
{ "fieldName": "propertyBaseType", "type": "LIKE", "value", "thingname" }
{ "fieldName": "propertyBaseType", "type": "LIKE", "value", "thingNaMe" }
{ "fieldName": "propertyBaseType", "type": "LIKE", "value", "THINGNAME" }
{ "fieldName": "propertyBaseType", "type": "LIKE", "value", "THINGNamE" }
{ "fieldName": "propertyBaseType", "type": "LIKE", "value", "String" }
{ "fieldName": "propertyBaseType", "type": "LIKE", "value", "STRING" }
{ "fieldName": "propertyBaseType", "type": "LIKE", "value", "BOOLean" }
{ "fieldName": "propertyBaseType", "type": "LIKE", "value", "Boolean" }
{ "fieldName": "propertyBaseType", "type": "LIKE", "value", "veC2" }
propertyIsIndexed
EQ
BOOLEAN
Optional field. The propertyIsIndexed is a name of an implicit field.
* 
This is not a NameMask allowed value.
Its value type must be a valid BOOLEAN value that is used to filter indexed and unindexed properties in the property_vtq that is EQ the value specified.
Valid values are true and false.
true
false
{ "fieldName": "propertyIsIndexed", "type": "EQ", "value", true}
{ "fieldName": "propertyIsIndexed", "type": "EQ", "value", false}
Query Use Cases
What
Why
GetPropertyVTQCount Query JSON Example
Determine the number of properties in the ThingWorx platform run time that contain an indexed ThingName value.
You are looking for how many times a Thing (Thing1) is specified in any ( * ) Thing property to determine how many times it is used within the custom application model within the platform. This may be the case for a more optimized Where Used query on properties' functionality that could be provided as the query parameter input to the QueryImplementingThingOptimized service:
{
"filters": {
"fieldName": "*",
"type": "LIKE",
"value": "Thing1"
}
}
{
"filters": {
"filters": [
{
"fieldName": "propertyBaseType",
"type": "LIKE",
"value": "ThingName"
},
{
"fieldName": "propertyIsIndexed",
"type": "EQ",
"value": true
}
],
"type": "AND"
},
"type": "SELF"
}
Determine the number of properties (and thus Things) in the ThingWorx platform run time that contain a model number of B-X42 that is not indexed and has a STRING base type.
You want to know how many batteries that are modeled as Things in your platform are of the new B-X42 battery type based on the model number.
{
"filters": {
"fieldName": "modelNumber",
"type": "LIKE",
"value": "B-X42"
}
}
{
"filters": {
"filters": [
{
"fieldName": "propertyBaseType",
"type": "LIKE",
"value": "String"
},
{
"fieldName": "propertyIsIndexed",
"type": "EQ",
"value": false
},
{
"fieldName": "propertyNameMask",
"type": "LIKE",
"value": "B-X42"
}
],
"type": "AND"
},
"type": "SELF"
}
Determine the number of properties (and thus Things) in the ThingWorx platform run time that contain a model number that is for a B-X* that is indexed and has a STRING base type.
You want to know how many batteries that are modeled as Things in your platform are of the battery type but don’t care about the specific model number (i.e. 1, 2, 3,41, 43, etc).
{
"filters": {
"fieldName": "modelNumber",
"type": "LIKE",
"value": "B-X*"
}
}
{
"filters": {
"filters": [
{
"fieldName": "propertyBaseType",
"type": "LIKE",
"value": "String"
},
{
"fieldName": "propertyIsIndexed",
"type": "EQ",
"value": true
},
{
"fieldName": "propertyNameMask",
"type": "LIKE",
"value": "B-X*"
}
],
"type": "AND"
},
"type": "SELF"
}
Invalid Filter Tuples
To avoid invalid query results, do not use the following invalid filter tuples:
Invalid Query
Example that will Cause an Error Result
Filter tuple fields that specify OR filter collections.
* 
Filter tuples must be combined as a AND filter collection.
{
"filters": {
"filters": [
{
"fieldName": "propertyBaseType",
"type": "LIKE",
"value": "String"
},
{
"fieldName": "propertyIsIndexed",
"type": "EQ",
"value": true
}
],
"type": "OR"
},
"type": "SELF"
}
One of the five element types as field names occur more than once.
* 
Each of the supported field names must occur a maximum of one time per filter tuple.
{
"filters": {
"filters": [
{
"fieldName": "propertyBaseType",
"type": "LIKE",
"value": "String"
},
{
"fieldName": "propertyBaseType",
"type": "LIKE",
"value": "Long"
}
],
"type": "AND"
},
"type": "SELF"
}
Invalid values for propertyBaseType.
* 
Only specify one of the base types noted in the description column in the table above for propertyBaseType, based on if propertyIsIndexed is set to true or false.
{
"filters": {
"filters": [
{
"fieldName": "propertyBaseType",
"type": "LIKE",
"value": "InvalidType"
},
{
"fieldName": "propertyIsIndexed",
"type": "EQ",
"value": true
}
],
"type": "AND"
},
"type": "SELF"
}
Invalid values for fieldName.
* 
Only specify one of entityNameMask, entityTypeMask, propertyNameMask, propertyBaseType, propertyIsIndexed.
{
"filters": {
"filters": [
{
"fieldName": "invalidFieldName",
"type": "LIKE",
"value": "*"
}
],
"type": "AND"
},
"type": "SELF"
}
Was this helpful?