ContentType
La définition de cette propriété sur un élément indique que le contenu de l’élément est traité comme un encodage Base64 du type MIME/type de contenu spécifié et est indexé à l’aide du gestionnaire de ce type de contenu.
<element
sc:ContentType= "application/hta" | "application/mac-binhex40" | "application/vnd.ms-xpsdocument"
| "application/windows-appcontent+xml" | "application/x-compress" | "application/x-compressed"
| "application/x-gzip" | "application/x-jtx+xps" | "application/x-latex"
| "application/x-mplayer2" | "application/x-ms-wmz" | "application/x-stuffit"
| "application/x-tar" | "application/x-wmplayer" | "application/x-zip-compressed"
| "application/xml" | "audio/aiff" | "audio/basic" | "audio/mid" | "audio/midi"
| "audio/mp3" | "audio/mpeg" | "audio/mpegurl" | "audio/mpg" | "audio/wav"
| "audio/x-aiff" | "audio/x-mid" | "audio/x-midi" | "audio/x-mp3"
| "audio/x-mpeg" | "audio/x-mpegurl" | "audio/x-mpg" | "audio/x-ms-wax"
| "audio/x-ms-wma" | "audio/x-wav" | "image/bmp" | image/gif"
| "image/jpeg" | "image/pjpeg" | "image/png" | "image/vnd.ms-photo"
| "image/x-emf" | "image/x-icon" | "image/x-png" | "image/x-wmf"
| "midi/mid" | "model/vnd.dwfx+xps" | "model/vnd.easmx+xps"
| "model/vnd.edrwx+xps" | "model/vnd.eprtx+xps" | "pkcs7-mime"
| "text/css" | "text/html" | "text/plain" | "text/xml"
| "video/avi" | "video/mpeg" | "video/mpg" | "video/msvideo"
| "video/quicktime" | "video/x-mpeg" | "video/x-mpeg2a"
| "video/x-ms-asf" | "video/x-ms-asf-plugin" | "video/x-ms-wm"
| "video/x-ms-wmv" | "video/x-ms-wmx" | "video/x-ms-wvx"
| "video/x-msvideo"
xmlns:sc="http://schemas.microsoft.com/Search/2013/ApplicationContent">
</element>
Type de données
Cet attribut accepte l’une des valeurs suivantes :
application/hta
application/mac-binhex40
application/vnd.ms-xpsdocument
application/windows-appcontent+xml
application/x-compress
application/x-compressed
application/x-gzip
application/x-jtx+xps
application/x-latex
application/x-mplayer2
application/x-ms-wmz
application/x-stuffit
application/x-tar
application/x-wmplayer
application/x-zip-compressed
application/xml
audio/aiff
audio/basic
audio/mid
audio/midi
audio/mp3
audio/mpeg
audio/mpegurl
audio/mpg
audio/wav
audio/x-aiff
audio/x-mid
audio/x-midi
audio/x-mp3
audio/x-mpeg
audio/x-mpegurl
audio/x-mpg
audio/x-ms-wax
audio/x-ms-wma
audio/x-wav
image/bmp
image/gif
image/jpeg
image/pjpeg
image/png
image/vnd.ms-photo
image/x-emf
image/x-icon
image/x-png
image/x-wmf
midi/mid
model/vnd.dwfx+xps
model/vnd.easmx+xps
model/vnd.edrwx+xps
model/vnd.eprtx+xps
pkcs7-mime
text/css
text/html
text/plain
text/xml
video/avi
video/mpeg
video/mpg
video/msvideo
video/quicktime
video/x-mpeg
video/x-mpeg2a
video/x-ms-asf
video/x-ms-asf-plugin
video/x-ms-wm
video/x-ms-wmv
video/x-ms-wmx
video/x-ms-wvx
video/x-msvideo
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'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'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 && WinJS.log(output, "sample", "status");
});
}
Pour obtenir le code complet, consultez l' exemple d’indexeur.
Configuration requise
Client minimal pris en charge |
Windows 8.1 [applications de bureau uniquement] |
Serveur minimal pris en charge |
Windows Server 2012 R2 [applications de bureau uniquement] |
Voir aussi
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour