애플리케이션 콘텐츠 스키마

Windows 앱에 대한 애플리케이션 콘텐츠 또는 appcontent-ms 스키마를 사용하면 개발자가 앱 콘텐츠에 대한 추가 정보를 Windows Search 인덱스에 제공하여 앱 내 검색을 향상시킬 수 있습니다.

작동 방식

앱 내 검색을 위해 앱 데이터를 인덱싱할 Windows 요청하려면 LocalFolder 아래에 "Indexed"라는 폴더를 만들고 인덱싱할 파일을 저장합니다. Windows 이 "인덱싱된" 폴더 및 모든 하위 폴더의 파일 콘텐츠 및 메타데이터(속성)를 인덱싱합니다.

appcontent-ms 스키마를 사용하여 파일 또는 항목에 대한 정보를 인덱싱하려면 appcontent-ms 파일을 만들고 앱의 LocalFolder\Indexed 폴더에 추가합니다(앱이 설치된 후 런타임에 이 작업을 수행해야 함). 앱에서 Windows.Storage 사용하는 경우 API를 검색하여 인덱싱된 폴더에서 쿼리를 수행합니다. 검색에는 appcontent-ms 파일의 정보가 포함됩니다.

appcontent-ms 파일의 정보는 포함된 앱이 Windows.Storage 사용하는 경우에만 사용됩니다. 검색 API를 사용하여 검색을 수행합니다. 예를 들어 정보가 Windows UI 또는 다른 앱에 표시되지 않습니다.

이 예제에서는 "샘플 1"이라는 항목을 설명하는 간단한 appcontent-ms 파일을 보여 줍니다.

파일에 appcontent-ms 스키마 IndexerSampleInformation 로 정의되지 않은 요소 및 IndexerSampleSpecificElement. 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 검색에 임의 요소의 콘텐츠를 인덱싱하도록 지시할 수도 있습니다. IndexableContent 특성을 사용하여 콘텐츠를 인덱싱하도록 Search에 지시하기만 하면됩니다. 앞의 예제에서 Windows Search는 IndexableContent 특성이 true로 설정되어 있으므로 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");
    });
}

전체 코드는 인덱서 샘플을 참조하세요.

요소 참조

다음 표에서는 이름별로 사전순으로 정렬된 이 스키마의 모든 요소를 나열합니다.

요소 Description
AdditionalProperties

항목을 설명하는 추가 속성을 포함합니다.

설명

항목을 설명하는 System.Comment 을 포함합니다.

키워드

항목을 설명하는 System.Keywords 중 하나입니다.

C++ 키워드

항목을 설명하는 System.Keywords 를 포함합니다.

이름

항목의 System.ItemNameSystem.ItemNameDisplay \ 를 지정합니다.

속성

Windows Search 인덱스에 대한 항목을 설명하는 속성을 포함합니다.

속성

항목을 설명하는 속성입니다.

속성에 대해 인덱싱할 값입니다.

 

앱 관련 요소의 특성

이러한 특성을 사용하여 앱별 XML 요소의 콘텐츠를 인덱싱합니다.

attribute Description

Contenttype

요소에 이 속성을 설정하면 요소의 콘텐츠가 지정된 MIME 형식/콘텐츠 형식의 base64 인코딩으로 처리되고 해당 콘텐츠 형식에 대한 처리기를 사용하여 인덱싱됨을 나타냅니다.

IndexableContent

요소의 텍스트가 검색을 위해 인덱싱되어야 하지만 속성과 연결되지 않음을 나타냅니다. 속성 키에 따라 나중에 속성을 검색할 수 있지만 텍스트 콘텐츠는 검색할 수 없습니다.

 

인덱서 샘플

Windows. Storage. 검색

검색 추가(HTML)

검색 추가(XAML)