Ключевое слово
Одно из ключевых слов System. keywords , описывающее элемент.
Иерархия элементов
- <Свойства>
-
- <Ключевые слова>
- <Ключевое слово>
Синтаксис
<Keyword>
string
</Keyword>
Атрибуты и элементы
Атрибуты
Отсутствует.
Дочерние элементы
Отсутствует.
Родительские элементы
Родительский элемент | Описание |
---|---|
Ключевые слова | Содержит ключевое слово System. keywords , описывающее элемент. |
Примеры
В этом примере показан простой файл аппконтент-MS, описывающий элемент с именем Sample 1.
Обратите внимание, что файл содержит элементы, не определенные в схеме аппконтент-MS: IndexerSampleInformation
и IndexerSampleSpecificElement
. Файл аппконтент-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 поиска, чтобы индексировать содержимое произвольных элементов. Просто используйте атрибут индексаблеконтент , чтобы указать, что поиск будет индексировать содержимое. в предыдущем примере Windows поиск будет индексировать содержимое индексерсамплеспеЦифицелемент, так как атрибут индексаблеконтент имеет значение 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.
В следующем примере показано, как скопировать файл аппконтент-MS в папку Локалфолдер\индексед приложения. Код копирует все найденные файлы из папки аппконтент-MS приложения в папку Локалфолдер\индексед. (Можно также создать новые файлы аппконтент-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'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");
});
}
Полный код см. в примере индексатора.
См. также раздел
Windows. служба хранилища. Осуществлять
Требования
Значение | |
---|---|
Пространство имен | http://schemas.microsoft.com/Search/2013/ApplicationContent |