範例物件查詢 - AWS IoT Core

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

範例物件查詢

使用查詢語法指定查詢字串中的查詢。查詢會傳遞至 SearchIndex API。下表列出部分查詢字串範例。

查詢字串 結果
abc

在任何註冊表,影子 (經典未命名的影子和命名的影子) 或 Device Defender 違規欄位中的「abc」查詢。

thingName:myThingName

查詢名稱為「myThingName」的東西。

thingName:my*

可查詢名稱起始為 "my" 的物件。

thingName:ab?

可查詢具有「ab」加上一個額外字元的物件名稱 (例如,「aba」、「abb」、「abc」等)。

thingTypeName:aa

查詢與類型 "aa" 關聯的物件。

thingGroupNames:a 查詢父項物件群組名稱為「a」的物件。
thingGroupNames:a* 查詢父項物件群組名稱符合模式「a*」的物件。
attributes.myAttribute:75

可查詢具有 "myAttribute" 屬性名稱的物件,且其值為 75。

attributes.myAttribute:[75 TO 80]

可查詢具有 "myAttribute" 屬性名稱的物件,且其值介於數字範圍 (75–80,含) 內。

attributes.myAttribute:{75 TO 80]

可查詢具有 "myAttribute" 屬性名稱的物件,且其值介於數字範圍 (>75 且 <=80) 內。

attributes.serialNumber:["abcd" TO "abcf"]

可查詢具有 "serialNumber" 屬性名稱的物件,且其值介於一組字母和數字的字串範圍內。以此查詢而言,傳回的物件必須具有 "serialNumber" 屬性且其值為 "abcd"、"abce" 或 "abcf"。

attributes.myAttribute:i*t

可查詢具有 "myAttribute" 屬性名稱的物件,且其值以 "i" 為首、後方接任意數量的字元,最後則是 "t"。

attributes.attr1:abc AND attributes.attr2<5 NOT attributes.attr3>10

使用布林值運算式,查詢結合詞彙的物件。以此查詢而言,傳回的物件必須具有「attr1」屬性名稱且其值為「abc」具有「attr2」屬性名稱且其值小於 5 以及具有「attr3」屬性名稱且其值不超過 10。

shadow.hasDelta:true

查詢具有差量元素的未命名影子物件。

NOT attributes.model:legacy

可查詢屬性名稱為 "model" 而不是 "legacy" 的物件。

shadow.reported.stats.battery:{70 TO 100} (v2 OR v3) NOT attributes.model:legacy

可查詢符合下列標準的物件:

  • 物件影子 stats.battery 屬性值在 70 至 100 之間。

  • 物件名稱、類型名稱或屬性值出現文字 "v2" 或 "v3"。

  • 物件 model 屬性未設定為 "legacy"。

shadow.reported.myvalues:2

查詢影子回報區段中之 myvalues 陣列包含值為 2 的物件。

shadow.reported.location:* NOT shadow.desired.stats.battery:*

可查詢符合下列標準的物件:

  • location 屬性存在於影子的 reported 區段中。

  • stats.battery 屬性不存在於影子的 desired 區段中。

shadow.name.<shadowName>.hasDelta:true

查詢具有給定名稱的影子和差量元素的物件。

shadow.name.<shadowName>.desired.filament:*

查詢具有給定名稱的影子和所需絲狀結構屬性的物件。

shadow.name.<shadowName>.reported.location:*

查詢具有給定名稱影子的事物以及已命名影子報告區段中有 location 屬性存在的物件。

connectivity.connected:true

查詢所有已連線的裝置。

connectivity.connected:false 查詢所有中斷連線的裝置。
connectivity.connected:true AND connectivity.timestamp : [1557651600000 TO 1557867600000] 查詢連線時間戳記 >= 1557651600000 且 <= 1557867600000 的所有連網裝置。時間戳記是以從 Epoch 算起的毫秒提供。
connectivity.connected:false AND connectivity.timestamp : [1557651600000 TO 1557867600000] 查詢中斷連線時間戳記 >= 1557651600000 且 <= 1557867600000 的所有中斷連網裝置。時間戳記是以從 Epoch 算起的毫秒提供。
connectivity.connected:true AND connectivity.timestamp > 1557651600000 查詢連線時間戳記 > 1557651600000 的所有連網裝置。時間戳記是以從 Epoch 算起的毫秒提供。
connectivity.connected:* 查詢具連線資訊的所有裝置。
connectivity.disconnectReason:* 查詢具有連線 disconnectReason 的所有裝置。
connectivity.disconnectReason:CLIENT_INITIATED_DISCONNECT 查詢因 CLIENT_INITIATED_DISCONNECT 而中斷連線的所有裝置。
deviceDefender.violationCount:[0 TO 100] 查詢 Device Defender 違規計數值落在數字範圍 (0-100,含) 內的物件。
deviceDefender.<device-SecurityProfile>.disconnectBehavior.inViolation:true 查詢違反如安全性設定檔 device-SecurityProfile 所定義行為 disconnectBehavior 的物件。請注意,inViolation:false 不是有效的查詢。
deviceDefender.<device-SecurityProfile>.disconnectBehavior.lastViolationValue.number>2 查詢違反行為的事件 (disconnectBehavior如安全性設定檔裝置中定義SecurityProfile 的最後違規事件值大於 2)。
deviceDefender.<device-SecurityProfile>.disconnectBehavior.lastViolationTime>1634227200000

查詢違反安全性設定檔裝置中disconnectBehavior所定義之行為的事件,且在指定SecurityProfile 的紀元時間之後發生最後一個違規事件。

shadow.name.gps-tracker.reported.coordinates:geo_distance,47.6204,-122.3491,15.5km 查詢距離 47.6204,-122.3491 坐標 15.5 公里的徑向距離內的東西。當您的位置資料儲存在具名陰影中時,此查詢字串適用於。
shadow.reported.coordinates:geo_distance,47.6204,-122.3491,15.5km 查詢距離 47.6204,-122.3491 坐標 15.5 公里的徑向距離內的東西。當您的位置資料儲存在傳統陰影中時,此查詢字串適用於。