次の方法で共有


IndexableContent

要素のテキストに検索用のインデックスを作成する必要があるが、 プロパティには関連付け "ない" 必要がある場合を示します。 プロパティは後でプロパティ キーに基づいて取得できますが、テキスト コンテンツは取得できないことに注意してください。

<element
    sc:IndexableContent= "true" | "false" | "1" | "0"
    xmlns:sc="http://schemas.microsoft.com/Search/2013/ApplicationContent">
</element>

データ型

この属性はブール値を受け取る:

  • true
  • false
  • 1
  • 0

この例では、"Sample 1" という名前の項目を記述する単純な appcontent-ms ファイルを示します。

ファイルには、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 属性を使用して、コンテンツのインデックスを作成する検索を指定します。 前の例では、indexableContent 属性が true に設定Windows Search によって IndexerSampleSpecificElement の内容のインデックスが作成されます

  <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 8.1 [デスクトップ アプリのみ]

サポートされている最小のサーバー

Windows Server 2012 R2 [デスクトップ アプリのみ]

関連項目

インデクサーのサンプル

Windows。Storage。検索