Parola chiave

Oggetto di System.Keywords che descrive l'elemento.

Gerarchia degli elementi

<Proprietà>
<Parole chiavi>
<Parola chiave>

Sintassi

<Keyword>

  string

</Keyword>

Attributi ed elementi

Attributi

Nessuno.

Elementi figlio

Nessuno.

Elementi padre

Elemento padre Descrizione
Parole chiave

Contiene l'oggetto System.Keywords che descrive l'elemento.

 

Esempio

Questo esempio mostra un semplice file appcontent-ms che descrive un elemento denominato "Sample 1".

Si noti che il file contiene elementi non definiti dallo schema appcontent-ms: IndexerSampleInformation e IndexerSampleSpecificElement. Il file appcontent-ms deve avere un nodo radice che incapsula tutti i dati da indicizzare, ma è possibile assegnare al nodo il nome desiderato.

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

È anche possibile indicare Windows ricerca per indicizzare il contenuto di elementi arbitrari. È sufficiente usare l'attributo IndexableContent per indicare a Ricerca di indicizzare il contenuto. Nell'esempio precedente, Windows ricerca indicizza il contenuto di IndexerSampleSpecificElement perché l'attributo IndexableContent è impostato su 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 ricerca considera il contenuto come contenuto di testo per impostazione predefinita. se il contenuto è base64, usare l'attributo ContentType per specificare il tipo MIME.

L'esempio successivo illustra come copiare un file appcontent-ms nella cartella LocalFolder\Indexed dell'app. Il codice copia tutti i file trovati nella cartella appcontent-ms dell'app nella cartella LocalFolder\Indexed. È anche possibile creare nuovi file appcontent-ms direttamente nella cartella Indicizzata anziché copiarli da un'altra posizione.

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

Per il codice completo, vedere l'esempio di indicizzatore.

Vedi anche

Esempio di indicizzatore

Windows. Archiviazione. Ricerca

Requisiti

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