使用 GetPropertyVTQCount 服務
GetPropertyVTQCount 服務會傳回在執行時間針對已在 ThingWorx 內擷取或設定之物件內容 (於物件、物範本或物形式上定義) 的計數。服務會從 ThingWorx Platform 的 property_vtq 內容持續性提供者資料庫表格中查詢選取計數。此計數結果可在執行時間協助決定如何最佳化查詢的效能,或因指定名稱的索引內容值總數、ThingWorx 基礎類型、針對指定實體名稱等而最佳化內容值的擷取。查詢與擷取可能會受到這些 property_vtq 值之資料庫索引的影響。
服務詳細資訊
詳細資訊
描述
傳回由查詢條件指定的內容計數。
參數
query
查詢基礎類型
請參閱支援的查詢篩選器元組元素以取得可接受值。
結果 (無效查詢參數)
指出無效查詢的錯誤訊息。
結果 (有效查詢參數)
數值
支援的查詢篩選器元組元素
GetPropertyVTQCount 服務在其查詢篩選器內支援五種元素類型:entityNameMaskentityTypeMaskpropertyNameMaskpropertyBaseTypepropertyIsIndexed
* 
這些元素類型區分大小寫。
五個元素類型的組合可以傳遞至 GetPropertyVTQCount 服務,並且稱為篩選器元組。它們是作為 ThingWorx 篩選器集合實行的,如下所示:
{ "filters": [ {...}, {...}], "type": "AND" }
其中 { ... } 是一個元素類型篩選器。在此範例中,篩選器元組內有兩個元素類型篩選器,必須將其定義為 AND ThingWorx 篩選器集合。
在下表中,
下列每個元素類型篩選器只能針對每個篩選器元組存在 0 或 1 次。
在一個元素類型篩選器內,一個定義了三個欄位 (例如 fieldNametypevalue)。
對於具有 Mask 後綴的任何欄位,值都可以包含萬用字元/星號。
欄位名稱 (元素類型)
類型
ValueType
描述
範例值
JSON 範例
entityNameMask
LIKE
STRING
選用欄位。entityNameMask 是隱含欄位的名稱。
其值類型必須是包含實體名稱的 STRING,因為值只會在 LIKE 所指定 valueproperty_vtq 中選取記錄。
*
Thing1
*hing1*
{ "fieldName": "entityNameMask", "type": "LIKE", "value", "*" }
{ "fieldName": "entityNameMask", "type": "LIKE", "value", "Thing1" }
{ "fieldName": "entityNameMask", "type": "LIKE", "value", "*hing1*" }
entityTypeMask
LIKE
STRING
選用欄位。entityTypeMask 是隱含欄位的名稱。
其值類型必須是包含實體類型的 STRING,因為值只會在 LIKE 所指定 valueproperty_vtq 中選取記錄。
* 
儘管許多實體類型只能指定一個類型,但物件或該字串的萬用字元版本將會產生任何計數資料。對於其他實體類型,將找不到相符項目,且可能會產生零計數。
*
Thing
*hin*
{ "fieldName": "entityTypeMask", "type": "LIKE", "value", "*" }
{ "fieldName": "entityTypeMask", "type": "LIKE", "value", "Thing" }
{ "fieldName": "entityTypeMask", "type": "LIKE", "value", "*Thin*" }
propertyNameMask
LIKE
STRING
選用欄位。propertyNameMask 是隱含欄位的名稱。
其值類型必須是包含內容名稱的 STRING,因為值只會在 LIKE 所指定 valueproperty_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 允許的值。
其值類型必須是包含有效基礎類型名稱的 STRING,因為值只會在 LIKE 所指定值的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 允許的值。
其值類型必須是有效 BOOLEAN 值,且用於在 EQ 所指定property_vtq 中篩選索引及取消索引的內容。
有效值為 true 和 false。
true
false
{ "fieldName": "propertyIsIndexed", "type": "EQ", "value", true}
{ "fieldName": "propertyIsIndexed", "type": "EQ", "value", false}
查詢使用案例
內容
原因
GetPropertyVTQCount 查詢 JSON 範例
決定在 ThingWorx Platform 執行時間中包含索引 ThingName 值的內容數。
您會尋找在任何 ( * ) 物件內容中指定物件 (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 Platform 執行時間中包含未索引且具有 STRING 基礎類型之 B-X42 模型數的內容數 (及物件數)。
您想要知道在您的平台中有多少電池被建模為物件,而且根據型號屬於新的 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 Platform 執行時間中包含已索引且具有 STRING 基礎類型之 B-X* 模型數的內容數 (及物件數)。
您想要知道在您的平台中有多少電池被建模為物件,而且屬於電池類型,但特定型號 (即 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"
}
無效篩選元組
為了避免無效查詢結果,請勿使用下列無效篩選器元組:
無效查詢
將導致錯誤結果的範例
指定 OR 篩選器集合的篩選器元組欄位。
* 
篩選器元組必須組合為 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"
}
這是否有幫助?