Propriétés (schéma de contenu d’application)

contient des propriétés qui décrivent l’élément à la Windows Index de recherche.

Hiérarchie d’éléments

<Propriétés>

Syntaxe

<Properties>

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

</Properties>

Clé

? facultatif (zéro ou un)

& connecteur entrelacé (peut se produire dans n’importe quel ordre)

Attributs et éléments

Attributs

Aucun.

Éléments enfants

Élément enfant Description
AdditionalProperties

Contient des propriétés supplémentaires qui décrivent l’élément.

Commentaire

Contient un System. Comment qui décrit l’élément.

Mots clés

Contient les System. Keywords qui décrivent l’élément.

Nom

Spécifie System. ItemName \System. ItemNameDisplay de l’élément.

 

Éléments parents

Cet élément (document) le plus à l’extérieur ne peut pas être contenu dans d’autres éléments.

Exemples

Cet exemple montre un simple fichier appcontent-MS qui décrit un élément nommé « Sample 1 ».

Notez que le fichier contient des éléments non définis par le schéma appcontent-ms : IndexerSampleInformation et IndexerSampleSpecificElement . Votre fichier appcontent-MS doit avoir un nœud racine qui encapsule toutes les données à indexer, mais vous pouvez nommer ce nœud comme vous le souhaitez.

<?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>

vous pouvez même indiquer à Windows recherche d’indexer le contenu des éléments arbitraires. Utilisez simplement l’attribut IndexableContent pour indiquer à Search d’indexer le contenu. dans l’exemple précédent, Windows Search indexera le contenu du IndexerSampleSpecificElement, car l’attribut IndexableContent est défini sur 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>

La recherche traitera le contenu comme du texte par défaut ; Si le contenu est en base64, utilisez l’attribut ContentType pour spécifier le type MIME.

L’exemple suivant montre comment copier un fichier appcontent-ms dans le dossier LocalFolder\Indexed de votre application. Le code copie tous les fichiers qu’il trouve dans le dossier appcontent-ms de l’application dans le dossier LocalFolder\Indexed. (Vous pouvez également créer des fichiers appcontent-MS directement dans le dossier indexé plutôt que de les copier à partir d’un autre emplacement.)

/// <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");
    });
}

Pour obtenir le code complet, consultez l' exemple d’indexeur.

Voir aussi

Exemple d’indexeur

Windows. Stockage. Recherche

Spécifications

Valeur
Espace de noms http://schemas.microsoft.com/Search/2013/ApplicationContent