已儲存的搜尋檔案格式
在 Windows Vista 和更新版本中,使用者可以將搜尋儲存為搜尋資料夾,該資料夾是由 XML 檔案所產生,該檔案會將查詢儲存在 Windows 搜尋子系統可以使用的表單中。 本主題描述檔格式 (*.search-ms),並包含下列各節:
已儲存搜尋的概觀
用戶可以將搜尋查詢儲存為搜尋資料夾,這是 Windows 檔案總管中顯示在 [搜尋] 資料夾下的虛擬資料夾。 開啟 [搜尋資料夾] 會執行儲存的搜尋,並顯示 up-to日期結果。 儲存的搜尋檔案會以 Windows 搜尋可以採取動作的格式儲存查詢、指定要搜尋的專案、要搜尋的位置,以及如何呈現結果。
儲存的搜尋是從 %userprofile%\Search 資料夾中的 XML 檔案 (*.search-ms) 產生。 資料分成 XML 檔案中的三個主要元素:
- <viewInfo> 指定簡報資訊
- <查詢> 指定 (搜尋查詢資訊)
- <屬性> 指定 *.search-ms 檔案本身的屬性
下列範例顯示已儲存搜尋檔案的高階結構。
<?xml version="1.0"?>
<persistedQuery version="1.0">
<viewInfo ...>
...
</viewInfo>
<query>
...
</query>
<properties>
...
</properties>
</persistedQuery>
<viewInfo> 元素
<viewInfo> 元素會指定如何向使用者呈現結果。 下列範例顯示 元素的結構。
...
<viewInfo viewMode=""
iconSize=""
stackIconSize=""
autoListFlags=""
folderFlags=""
taskFlags=""
displayName="">
<visibleColumns>
<column viewField=""/>
</visibleColumns>
<frequentlyUsedColumns>
<column viewField= ""/>
</frequentlyUsedColumns>
<columnChooserColumns >
<column viewField=""/>
</columnChooserColumns >
<groupBy viewField=""
direction=""/>
<stackList>
<stack viewField=""/>
</stackList>
<sortList>
<sort viewField=""
direction=""/>
</sortList>
</viewInfo>
...
<viewInfo> 屬性
下表描述 <viewInfo> 元素的屬性。
屬性 | 描述 | 值 |
---|---|---|
viewMode | 指定資料夾檢視。 | 詳細數據 |圖示 |瓷磚 |
iconSize | 在未堆疊時,控制項目圖示和縮圖的預設大小。 | 介於 16 到 256 之間的整數 |
stackIconSize | 僅供內部使用。 請勿使用。 | n/a |
displayName | 僅供內部使用。 請勿使用。 | n/a |
autoListFlags | 僅供內部使用。 請勿使用。 | n/a |
folderFlags | 僅供內部使用。 請勿使用。 | n/a |
taskFlags | 僅供內部使用。 請勿使用。 | n/a |
<viewInfo> 子元素
<viewInfo 的子元素> 元素會指定 Windows 檔案總管搜尋結果中顯示的數據行,以及結果的分組和排序方式。 每個子元素都包含一組已排序的數據行,這些數據行是由系統屬性標準名稱所識別(例如 System.DisplayName)。 如果未在儲存的搜尋檔案中定義,搜尋結果會顯示一組適用於所顯示檔類型的預設數據行。
元素 | 描述 | 值 |
---|---|---|
visibleColumns | 指定要出現在結果檢視中之數據行的已排序列表。 用戶可以變更此清單。 | 任何系統屬性。 |
frequentlyUsedColumns | 僅供內部使用。 請勿使用。 | n/a |
columnChooserColumns | 僅供內部使用。 請勿使用。 | n/a |
groupBy | 指定要分組結果的單一系統屬性。 用戶可以變更此值。 | 任何系統屬性。 |
sortList | 指定要排序結果的數據列清單。 | 最多四個系統屬性。 用戶可以變更此清單。 |
stackList | 僅供內部使用。 請勿使用。 | n/a |
<查詢> 元素
<查詢> 元素會指定定義查詢結果方式的屬性。 下列範例顯示 元素的結構。
...
<query>
<providers>
<provider clsid=""/> <!-- Do not use -->
</providers>
<subQueries>
<subQuery path=""/> <!-- Do not use -->
<subQuery knownSearch=""/> <!-- Do not use -->
</subQueries>
<scope>
<include path="" nonRecursive=""/> <!-- [path of location to include] -->
<include knownFolder="" nonRecursive=""/> <!-- Known folder ID -->
<exclude path="" nonRecursive=""/> <!-- [path of location to exclude] -->
<exclude knownFolder="" nonRecursive=""/> <!-- Known folder ID -->
</scope>
<kindList>
<kind name=""/> <!-- Kind value -->
</kindList>
<conditions>
<condition type="" ...> <!-- andCondition | orCondition | notCondition | leafCondition -->
<attributes>
<attribute attributeID="" .../> <!-- Do not use -->
</attributes>
</condition>
</conditions>
</query>
...
子元素 <查詢>
下表描述 <範圍> 專案的子專案。
元素 | 描述 | 價值 |
---|---|---|
供應商 | 僅供內部使用。 請勿使用。 | n/a |
subQueries | 僅供內部使用。 請勿使用。 | n/a |
範圍 | 識別要包含在搜尋中或排除的位置。 | 路徑或 已知資料夾標識碼 要包含或排除的位置。 這個專案也可以指定搜尋是否應該包含/排除子路徑(淺層或深層搜尋)。 |
kindList | 識別要搜尋的檔案類型。 | 任何 System.Kind 值。 |
條件 | 指定篩選結果的規則。 例如,結果可能僅限於或傳送給特定人員的電子郵件。 | andCondition、orCondition、notCondition、leafCondition。 |
<範圍> 元素
<範圍> 項目會識別要包含在搜尋中或排除的位置。 <範圍> 項目必須至少包含一個 <包含> 子元素存在,零個或多個 <排除> 專案。 位置可以指定為路徑(支援環境變數),或指定為 已知資料夾識別碼。 此外,您可以將非遞歸設定為 「true」 或 「false」 來指定這些位置,以深入或淺層搜尋(預設值為遞歸)。 您可以藉由指定排除元素來排除包含位置清單的元件。
以下顯示 <範圍> 專案,它會搜尋檔特殊資料夾,但不會搜尋其子系、“E:” 磁盘區及其子系,但不會搜尋 “E:\windows” 目錄或其任何子系:
...
<query>
...
<scope>
<include knownFolder="{FDD39AD0-238F-46AF-ADB4-6C85480369C7}" nonRecursive="true"/>
<include path="E:\"/>
<exclude path="E:\Windows" nonRecursive="false"/>
</scope>
...
</query>
...
<kindList> 元素
這些元素會定義應該出現在連結庫中之專案之「種類」的聯集。 有效值為:
- 日曆
- 通信
- 聯繫
- 公文
- 電子郵件
- 飼料
- 資料夾
- 遊戲
- instantmessage
- 雜誌
- 連結
- 電影
- 音樂
- 注意
- 圖片
- 程式
- recordedtv
- searchfolder
- 任務
- 視頻
- webhistory
- 專案
- 其他
元素><條件
條件是比較搜尋結果的篩選條件。 例如,您可以篩選符合特定準則的結果,例如作者名稱或檔案大小。 條件集內建於具有邏輯 AND、OR 和 NOT 分支的單一條件樹狀結構中。
下列範例顯示專案 <條件的結構>。
...
<query>
...
<conditions>
<condition type="" ...>
<attributes>
<attribute attributeID="" .../>
</attributes>
</condition>
</conditions>
</query>
...
條件類型可以是下列其中一項:
類型 | 描述 | 可用的屬性 |
---|---|---|
andCondition | 結合兩個或多個子條件 | n/a |
orCondition | 解除兩個更多兒童條件的分離 | n/a |
notCondition | 否定子條件 | n/a |
leafCondition | 比較屬性與值 | property、propertyType、operator、value、valuetype |
<leafCondition> 元素的屬性會識別篩選結果的屬性和值。
範例:> 元素 <條件
下列範例會篩選 John 所撰寫之所有未讀取項目的結果。 也就是說,System.IsRead 屬性為 false,且字串 “john” 會出現在 System.Author 或 System.ItemAuthors 屬性中。
...
<query>
...
<conditions>
<condition type="andCondition">
<condition type="leafCondition"
property="System.IsRead"
operator="eq"
value="FALSE"/>
<condition type="orCondition">
<condition type="leafCondition"
property="System.Author"
propertyType="string"
operator="wordmatch"
value="John"
valueType="System.StructuredQueryType.String"/>
<condition type="leafCondition"
property="System.ItemAuthors"
propertyType="string"
operator="wordmatch"
value="John"
valueType="System.StructuredQueryType.String"/>
</condition>
</condition>
</conditions>
</query>
...
元素 <屬性>
<屬性> 專案描述已儲存搜尋本身的屬性。 已儲存的搜尋檔案支援四個屬性:<作者>、<種類>、<描述>,以及 <標籤>。 這些僅供內部使用。
search-ms 檔案格式的完整規格
以下是已儲存搜尋檔案的完整 XML 範例。
<?xml version="1.0"?>
<persistedQuery version="1.0">
<!-- The viewInfo section defines how results are displayed to the end user -->
<viewInfo viewMode="" <!-- details | icons | tiles -->
iconSize="" <!-- Integer -->
stackIconSize="" <!-- Do not use -->
displayName="" <!-- Do not use -->
folderFlags="" <!-- Do not use -->
taskFlags="" <!-- Do not use -->
autoListFlags=""> <!-- Do not use -->
<visibleColumns>
<column viewField=""/> <!-- System.[propertyname] -->
</visibleColumns>
<frequentlyUsedColumns>
<column viewField= ""/> <!-- Do not use -->
</frequentlyUsedColumns>
<columnChooserColumns >
<column viewField=""/> <!-- Do not use -->
</columnChooserColumns >
<groupBy viewField="" <!-- System.[propertyname] -->
direction=""/> <!-- ascending | descending -->
<stackList>
<stack viewField=""/> <!-- Do not use -->
</stackList>
<sortList>
<sort viewField="" <!-- System.[propertyname] -->
direction=""/> <!-- ascending | descending -->
</sortList>
</viewInfo>
<!-- The query section defines what gets searched (locations, file kinds) -->
<query>
<providers>
<provider clsid=""/> <!-- Do not use -->
</providers>
<subQueries>
<subQuery path=""/> <!-- Do not use -->
<subQuery knownSearch=""/> <!-- Do not use -->
</subQueries>
<scope>
<include path="" nonRecursive=""/> <!-- [path of location to include] -->
<include knownFolder="" nonRecursive=""/> <!-- Known folder ID -->
<exclude path="" nonRecursive=""/> <!-- [path of location to exclude] -->
<exclude knownFolder="" nonRecursive=""/> <!-- Known folder ID -->
</scope>
<kindList>
<kind name=""/> <!-- Kind value -->
</kindList>
<conditions>
<condition type="" ...> <!-- andCondition | orCondition | notCondition | leafCondition -->
<attributes>
<attribute attributeID="" .../> <!-- Do not use -->
</attributes>
</condition>
</conditions>
</query>
<!-- The properties section identifies properties of the saved search file itself. -->
<properties>
... <!-- Do not use -->
</properties>
</persistedQuery>
已儲存搜尋的範例
以下是 *.search-ms 檔案的範例。
Recent Documents.search-ms
<?xml version="1.0"?>
<persistedQuery version="1.0">
<viewInfo viewMode="details" iconSize="16">
<sortList>
<sort viewField="System.DateModified" direction="descending"/>
</sortList>
</viewInfo>
<query>
<conditions>
<condition type="leafCondition" valuetype="System.StructuredQueryType.DateTime" property="System.DateModified" operator="imp" value="R00UUUUUUUUZZXD-30NU" propertyType="wstr" />
</conditions>
<kindList>
<kind name="Document"/>
</kindList>
<subQueries>
<subQuery knownSearch="{4f800859-0bd6-4e63-bbdc-38d3b616ca48}"/>
</subQueries>
</query>
</persistedQuery>
Recent Music.search-ms
<?xml version="1.0"?>
<persistedQuery version="1.0">
<viewInfo viewMode="details" iconSize="16">
<sortList>
<sort viewField="System.DateModified" direction="descending"/>
</sortList>
</viewInfo>
<query>
<conditions>
<condition type="leafCondition" valuetype="System.StructuredQueryType.DateTime" property="System.DateModified" operator="imp" value="R00UUUUUUUUW-1WNNU" propertyType="wstr"/>
</conditions>
<kindList>
<kind name="Music"/>
</kindList>
<subQueries>
<subQuery knownSearch="{4f800859-0bd6-4e63-bbdc-38d3b616ca48}"/>
</subQueries>
</query>
</persistedQuery>
最近由 Me.search-ms 共用
<?xml version="1.0"?>
<persistedQuery version="1.0">
<viewInfo viewMode="details" iconSize="16">
<visibleColumns>
<column viewField="System.ItemNameDisplay"/>
<column viewField="System.DateModified"/>
<column viewField="System.Keywords"/>
<column viewField="System.SharedWith"/>
<column viewField="System.ItemFolderPathDisplayNarrow"/>
</visibleColumns>
<frequentlyUsedColumns>
<column viewField="System.Author"/>
<column viewField="System.Kind"/>
<column viewField="System.Size"/>
<column viewField="System.Title"/>
<column viewField="System.Rating"/>
</frequentlyUsedColumns>
<sortList>
<sort viewField="System.SharedWith" direction="descending"/>
</sortList>
</viewInfo>
<query>
<conditions>
<condition type="andCondition">
<condition type="leafCondition" property="System.IsShared" operator="eq" value="true"/>
<condition type="leafCondition" property="System.FileOwner" operator="eq" value="[Me]"/>
</condition>
</conditions>
<kindList>
<kind name="item"/>
</kindList>
<scope>
<include knownFolder="{5E6C858F-0E22-4760-9AFE-EA3317B67173}"/>
<include knownFolder="{DFDF76A2-C82A-4D63-906A-5644AC457385}"/>
</scope>
</query>
</persistedQuery>