共用方式為


應用程式內容架構 (的屬性)

包含描述 Windows Search 索引之專案的屬性。

元素階層

<屬性>

語法

<Properties>

  <!-- Child elements -->
  ( Name
  & Keywords?
  & Comment?
  & AdditionalProperties?
  )

</Properties>

答案

? 選擇性 (零或一)

& 交錯連接器 (可能會以任何順序發生)

屬性和項目

屬性

無。

子元素

子元素 描述
AdditionalProperties

包含描述專案的其他屬性。

註解

包含描述專案的 系統批註

關鍵字

包含描述專案的 system.object

名稱

\指定此專案的ItemNameDisplay

 

父項目

這個最外層的 (檔) 元素可能不會包含在任何其他專案中。

範例

此範例顯示一個簡單的 appcontent-ms 檔案,其描述名為「範例1」的專案。

請注意,此檔案包含未由 appcontent-ms 架構定義的元素: IndexerSampleInformationIndexerSampleSpecificElement 。 您的 appcontent-ms 檔案必須有一個根節點,它會封裝要編制索引的所有資料,但您可以將該節點命名為任何您想要的名稱。

<?xml version="1.0" encoding="utf-8"?>
<IndexerSampleInformation>
  <Properties xmlns="http://schemas.microsoft.com/Search/2013/ApplicationContent">
    <Name>Sample 1</Name>
    <Keywords>
      <Keyword xml:lang="en-US">Sample 1 - keyword 1</Keyword>
      <Keyword>Sample 1 - keyword 2</Keyword>
    </Keywords>
    <Comment>Sample 1 comment</Comment>
    <AdditionalProperties>
      <Property Key="System.Title">Sample 1 Title</Property>
      <Property xml:lang="en-US" Key="System.Contact.EmailAddresses">
        <Value>bryan@contoso.com</Value>
        <Value>vincent@contoso.com</Value>
      </Property>
    </AdditionalProperties>
  </Properties>
  <IndexerSampleSpecificElement sc:IndexableContent="true" 
    xmlns:sc="http://schemas.microsoft.com/Search/2013/ApplicationContent">
    The text included here will be indexed, enabling full-text search.
  </IndexerSampleSpecificElement>
</IndexerSampleInformation>

您甚至可以告訴 Windows Search 為任意元素的內容編制索引。 您只需使用 IndexableContent 屬性來指示搜尋將內容編制索引。 在上述範例中,Windows Search 會將 IndexerSampleSpecificElement 的內容編制索引,因為IndexableContent屬性設定為true

  <IndexerSampleSpecificElement sc:IndexableContent="true" 
    xmlns:sc="http://schemas.microsoft.com/Search/2013/ApplicationContent">
    The text included here will be indexed, enabling full-text search.
  </IndexerSampleSpecificElement>

依預設,搜尋會將內容視為文字內容;如果內容是 base64,請使用 ContentType 屬性來指定 MIME 類型。

下一個範例顯示如何將 appcontent-ms 檔案複製到應用程式的 LocalFolder\Indexed 資料夾。 此程式碼會將在應用程式的 appcontent-ms 資料夾中找到的任何檔案複製到 LocalFolder\Indexed 資料夾。 (您也可以直接在索引資料夾中建立新的 appcontent-ms 檔案,而不是從另一個位置複製它們。 )

/// <summary>
/// For the purposes of this sample, the appcontent-ms files are stored in an "appcontent-ms" folder in the
/// install directory. These are then copied into the app&#39;s "LocalState\Indexed" folder, which exposes them
/// to the indexer.
/// </summary>
public async static Task<string> AddAppContentFilesToIndexedFolder()
{
    var localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
    var installDirectory = Windows.ApplicationModel.Package.Current.InstalledLocation;
    var outputString = "Items added to the \"Indexed\" folder:";
    var appContentFolder = await installDirectory.GetFolderAsync("appcontent-ms");
    var indexedFolder = await localFolder.CreateFolderAsync(
        "Indexed", Windows.Storage.CreationCollisionOption.OpenIfExists);
    var files = await appContentFolder.GetFilesAsync();
    foreach (var file in files)
    {
        outputString += "\n" + file.DisplayName + file.FileType;
        await file.CopyAsync(indexedFolder, 
            file.Name, Windows.Storage.NameCollisionOption.ReplaceExisting);
    }
    return outputString;
}
// For the purposes of this sample, the appcontent-ms files are stored in an "appcontent-ms" folder
// in the install directory.  These are then copied into the app&#39;s "LocalState\Indexed" folder,
// which exposes them to the indexer.
function _addAppContentFilesToIndexedFolder() {
    var localFolder = appData.localFolder,
        appcontentFolder,
        indexedFolder,
        installDirectory = Windows.ApplicationModel.Package.current.installedLocation;
    var output = "Items added to the \"Indexed\" folder:\n";
    installDirectory.getFolderAsync("appcontent-ms").then(function (retrievedAppcontentFolder) {
        appcontentFolder = retrievedAppcontentFolder;
        return localFolder.createFolderAsync(
            "Indexed", Windows.Storage.CreationCollisionOption.openIfExists);
    }).then(function (retrievedIndexedFolder) {
        indexedFolder = retrievedIndexedFolder;
        return appcontentFolder.getFilesAsync(appcontentFolder);
    }).then(function (files) {
        var promiseArray = [];
        for (var i = 0, len = files.length; i < len; i++) {
            promiseArray[i] = files[i].copyAsync(indexedFolder, 
                files[i].name, Windows.Storage.NameCollisionOption.replaceExisting);
            output += files[i].displayName + files[i].fileType;
            if (i < len - 1) {
                output += "\n";
            }
        }
        return WinJS.Promise.join(promiseArray);
    }).done(function () {
        WinJS.log &amp;&amp; WinJS.log(output, "sample", "status");
    });
}

如需完整的程式碼,請參閱 索引子範例

另請參閱

索引子範例

Windows。儲存體。搜索

需求

Namespace http://schemas.microsoft.com/Search/2013/ApplicationContent