Composer 中的 ThingWorx 模型定义 > 系统 > 子系统 > 效用子系统 > 使用 GetPropertyVTQCount 服务
使用 GetPropertyVTQCount 服务
GetPropertyVTQCount 服务会返回运行时在 ThingWorx 中接入或设置的事物属性计数,其中事物属性是针对事物、事物模板或事物形态定义的。该服务会从 ThingWorx 平台的 property_vtq 属性持久化方案提供工具数据库表中查询选择计数。此计数结果有助于确定如何优化查询性能,或如何根据给定名称、ThingWorx 基本类型、给定实体名称等索引属性值的总数优化运行时的属性值接入。查询和接入会受到这些 property_vtq 值的数据库索引的影响。
服务详细信息
详细信息
说明
返回通过查询条件指定的属性计数。
参数
query
QUERY 基本类型
有关可接受值的信息,请参阅支持的查询筛选器元组元素
结果 (无效查询参数)
错误消息指示查询无效。
结果 (有效查询参数)
Number
支持的查询筛选器元组元素
GetPropertyVTQCount 服务的查询筛选器支持五种元素类型:entityNameMaskentityTypeMaskpropertyNameMaskpropertyBaseTypepropertyIsIndexed
* 
这些元素类型区分大小写。
可将五个元素类型的组合传递给 GetPropertyVTQCount 服务,这称为筛选器元组。它们将作为 ThingWorx 筛选器集合来实现,如下所示:
{ "filters": [ {...}, {...}], "type": "AND" }
其中,{ ... } 是一个元素类型筛选器。在本示例中,筛选器元组中有两个元素类型筛选器,必须将这两者定义为 AND ThingWorx 筛选器集合。
在下表中,
以下每个元素类型过滤器只能在每个筛选器元组中存在 0 或 1 次。
在一个元素类型筛选器中,每一个可定义三个字段 (例如,fieldNametypevalue)。
对于任何后缀为 Mask 的字段,这些值可包含通配符/星号。
字段名称 (元素类型)
类型
值类型
说明
示例值
JSON 示例
entityNameMask
LIKE
STRING
可选字段。entityNameMask 是隐式字段的名称。
其值类型必须为包含实体名称的字符串,因为要选择的值仅记录在与指定 value 类似的 property_vtq 中。
*
Thing1
*hing1*
{ "fieldName": "entityNameMask", "type": "LIKE", "value", "*" }
{ "fieldName": "entityNameMask", "type": "LIKE", "value", "Thing1" }
{ "fieldName": "entityNameMask", "type": "LIKE", "value", "*hing1*" }
entityTypeMask
LIKE
STRING
可选字段。entityTypeMask 是隐式字段的名称。
其值类型必须为包含实体类型的字符串,因为要选择的值仅记录在与指定 value 类似的 property_vtq 中。
* 
虽然许多实体类型只能指定一个类型,但该字符串的 事物 或通配符版本会返回任何计数数据。对于其他实体类型,将找不到任何匹配项,并且可能会出现零计数。
*
Thing
*hin*
{ "fieldName": "entityTypeMask", "type": "LIKE", "value", "*" }
{ "fieldName": "entityTypeMask", "type": "LIKE", "value", "Thing" }
{ "fieldName": "entityTypeMask", "type": "LIKE", "value", "*Thin*" }
propertyNameMask
LIKE
STRING
可选字段。propertyNameMask 是隐式字段的名称。
其值类型必须为包含属性名称的字符串,因为要选择的值仅记录在与指定 value 类似的 property_vtq 中。
*
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
可选字段。propertyBasetype 是隐式字段的名称。
* 
这不是 NameMask 允许值。
其值类型必须为包含有效基本类型名称的字符串,因为要选择的值仅记录在与指定 value 类似的 property_vtq 中。
如果 propertyIsIndexed 为 true,则 propertyBaseType 值必须是以下任一项的有效可索引基本类型易记名称:
STRING
NUMBER
INTEGER
LONG
BOOLEAN
DATETIME
THINGNAME
USERNAME
GROUPNAME
HYPERLINK
MASHUPNAME
MENUNAME
DASHBOARDNAME
TEXT
GUID
NOTIFICATIONCONTENTNAME
NOTIFICATIONDEFINITIONNAME
STYLETHEMENAME
THINGGROUPNAME
如果 propertyIsIndexed 为 false,则可以指定以下项之一:
PASSWORD
INFOTABLE
LOCATION
IMAGE
XML
JSON
QUERY
HTML
BLOB
VEC2
VEC3
VEC4
THINGCODE
thingname
thingNaMe
THINGNAME
THINGNamE
字符串
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
可选字段。propertyIsIndexed 是隐式字段的名称。
* 
这不是 NameMask 允许值。
其值类型必须是一个有效的布尔值,用于在等于指定 valueproperty_vtq 中筛选索引和未索引的属性。
有效值为 true 和 false。
true
false
{ "fieldName": "propertyIsIndexed", "type": "EQ", "value", true}
{ "fieldName": "propertyIsIndexed", "type": "EQ", "value", false}
查询用例
内容
原因
GetPropertyVTQCount 查询 JSON 示例
确定包含索引 ThingName 值的 ThingWorx 平台运行时中的属性数。
您将查找在任何 ( * ) Thing 属性中指定事物 (Thing1) 的次数,以确定其在平台内自定义应用程序模型中使用的次数。对于可作为查询参数输入提供给 QueryImplementingThingOptimized 服务的属性功能,这可能是更优化的 "Where Used" 的查询:
{
"filters": {
"fieldName": "*",
"type": "LIKE",
"value": "Thing1"
}
}
{
"filters": {
"filters": [
{
"fieldName": "propertyBaseType",
"type": "LIKE",
"value": "ThingName"
},
{
"fieldName": "propertyIsIndexed",
"type": "EQ",
"value": true
}
],
"type": "AND"
},
"type": "SELF"
}
确定 ThingWorx 平台运行时中的属性 (和这些事物) 的数量,其中包含未建立索引且具有 STRING 基本类型的型号 B-X42。
您希望了解平台内根据型号建模为“事物”、类型为 battery 且属于新型号 B-X42 的电池的数量。
{
"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"
}
确定 ThingWorx 平台运行时中的属性 (和这些事物) 的数量,其中包含未建立索引且具有 STRING 基本类型的型号 B-X*。
您希望了解平台内根据型号建模为“事物”且类型为 battery 的电池的数量,而不管其具体型号 (即,1, 2, 3,41, 43 等) 为何。
{
"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"
}
无效筛选器元组
为避免无效查询结果,请勿使用以下无效筛选器元组:
无效查询
将产生错误结果的示例
指定了 筛选器集合的筛选器元组字段。
* 
筛选器元组必须以 AND 筛选器集合组合。
{
"filters": {
"filters": [
{
"fieldName": "propertyBaseType",
"type": "LIKE",
"value": "String"
},
{
"fieldName": "propertyIsIndexed",
"type": "EQ",
"value": true
}
],
"type": "OR"
},
"type": "SELF"
}
五种元素类型中,某一元素类型不止一次作为字段名称出现。
* 
每个受支持的字段名称在每个筛选器元组中最多只能出现一次。
{
"filters": {
"filters": [
{
"fieldName": "propertyBaseType",
"type": "LIKE",
"value": "String"
},
{
"fieldName": "propertyBaseType",
"type": "LIKE",
"value": "Long"
}
],
"type": "AND"
},
"type": "SELF"
}
propertyBaseType 值无效。
* 
根据 propertyIsIndexed 设置为 true 还是 false,仅指定在上表“说明”列中注明的基本类型之一作为 propertyBaseType
{
"filters": {
"filters": [
{
"fieldName": "propertyBaseType",
"type": "LIKE",
"value": "InvalidType"
},
{
"fieldName": "propertyIsIndexed",
"type": "EQ",
"value": true
}
],
"type": "AND"
},
"type": "SELF"
}
fieldName 值无效。
* 
仅指定以下参数之一:entityNameMaskentityTypeMaskpropertyNameMaskpropertyBaseTypepropertyIsIndexed
{
"filters": {
"filters": [
{
"fieldName": "invalidFieldName",
"type": "LIKE",
"value": "*"
}
],
"type": "AND"
},
"type": "SELF"
}
这对您有帮助吗?