分享方式:


在知識文章附件內容中搜尋

您可以使用知識文章附件,將可下載的檔案包含在知識庫文章中。 您也可以使用 Web 檔案,建立提供可下載內容的常見問題集頁面。

重要

您只能搜尋已附加至知識文章的檔案。 附加至 Web 檔案的檔案無法搜尋。

您可以將 Power Pages 網站設定為允許使用者在知識庫文章的附件內容中搜尋。 這可協助使用者尋找他們想要的資訊。

在知識庫文章中,任何具有已定義之首碼的附件都已編製索引。

若要為知識文章附件編製索引,您必須建立下列網站設定,並將其值設定為 True

網站設定 描述
Search/IndexNotesAttachments 表示是否應該為知識庫文章中的附件內容編製索引。 預設會設定為 False
KnowledgeManagement/DisplayNotes 表示是否顯示知識庫文章的附件。 預設會設定為 False

當您搜尋字詞時,搜尋結果也會包含附件。 如果搜尋字詞符合知識文章附件,也會提供對應知識庫文章的連結。 若要查看可下載附件,請左窗格的記錄類型下方選取下載。 若要修改下載標籤,請編輯 Search/Facet/Downloads 內容片段。 預設會將此值設定為下載

注意

必須在環境中啟用Dataverse 搜尋,才能使用此功能。

搜尋知識文章附件

如果您的網站使用 Lucene .NET 搜尋,則可以在 Dynamics 365 Customer Service 系統管理中心或客戶服務中心應用程式中,設定將知識文章附件同步至網站選項為,使網站能夠搜尋知識文章附件。 如果網站使用的是 Dataverse 搜尋,則不需要設定此選項,根據預設,您原本就可以搜尋知識庫文章附件。

這會允許搜尋瀏覽知識文章附件,讓知識消費者可以輕鬆存取資訊。 使用此附件功能後,您就不需要使用網站的附註附件。 知識文章附件會自動同步至附註附件。 其他資訊:更新入口網站的知識文章附件

更新網站設定

如果您在 2018 年 4 月之前已經有網站,並且已將網站升級為最新版本,則必須使用下列設定,才能獲得與新安裝相同的使用者體驗。

內容片段

若要在註釋和 Web 下載檔案中修改搜尋結果所顯示的標籤,請建立 Search/Facet/Downloads 內容片段,然後視需要設定其值。 預設值為下載

網站範本

「多層面搜尋 - 結果範本」網站範本已修訂,為的是要將與知識庫文章相關聯的檔案顯示為包含相關文章連結的主要搜尋結果項目。 您必須將「多層面搜尋 - 結果範本」網站範本更新為下列來源:

{% assign openTag = '{{' %}
{% assign closingTag = '}}' %}
{%raw%}
  <script id="search-view-results" type="text/x-handlebars-template">
    {{#if items}}
      <div class="page-header">
        <h2>{%endraw%}{{openTag}} stringFormat "{{ resx.Search_Results_Format_String }}" firstResultNumber lastResultNumber itemCount {{closingTag}}{%raw%}
          <em class="querytext">{{{query}}}</em>
          {{#if isResetVisible}}
            <a class="btn btn-default btn-sm facet-clear-all" role="button" title="{%endraw%}{{ snippets['Search/Facet/ClearConstraints'] | default: res['Search_Filter_Clear_All'] }}{%raw%}" tabIndex="0">{%endraw%}{{ snippets['Search/Facet/ClearConstraints'] | default: res['Search_Filter_Clear_All'] }}{%raw%}</a>
          {{/if}}
        </h2>
      </div>
      <ul>
        {{#each items}}
          <li>
            <h3><a title="{{title}}" href="{{url}}">{{#if parent}}<span class="glyphicon glyphicon-file pull-left text-muted" aria-hidden="true"></span>{{/if}}{{title}}</a></h3>
            <p class="fragment">{{{fragment}}}</p>
            {{#if parent}}
              <p class="small related-article">{%endraw%}{{ resx.Related_Article }}{%raw%}: <a title="{{parent.title}}" href="{{parent.absoluteUrl}}">{{parent.title}}</a></p>
            {{/if}}
            <ul class="note-group small list-unstyled">
            {{#if relatedNotes}}
              {{#each relatedNotes}}
                <li class="note-item">
                  {{#if isImage}}
                    <a target="_blank" title="{{title}}" href="{{absoluteUrl}}"><span class="glyphicon glyphicon-file" aria-hidden="true"></span>&nbsp;{{title}}</a>
                  {{else}}
                    <a title="{{title}}" href="{{absoluteUrl}}"><span class="glyphicon glyphicon-file" aria-hidden="true"></span>&nbsp;{{title}}</a>
                  {{/if}}
                  <p class="fragment text-muted">{{{fragment}}}</p>
                </li>
              {{/each}}
            {{/if}}
            {{#if relatedAttachments}}
              {{#each relatedAttachments}}
                <li class="note-item">
                  {{#if isImage}}
                    <a id="kbattachment-{{entityID}}" href="javascript:downloadKbAttachmentFile('kbattachment-{{entityID}}', '{{title}}', {{fileSize}}, '{{fileType}}', '{{downloadBlockUrl}}', '{{initializeDownloadUrl}}')"><span class="glyphicon glyphicon-file" aria-hidden="true"></span>&nbsp;{{title}}</a>
                  {{else}}
                    <a id="kbattachment-{{entityID}}" title="{{title}}" href="javascript:downloadKbAttachmentFile('kbattachment-{{entityID}}', '{{title}}', {{fileSize}}, '{{fileType}}', '{{downloadBlockUrl}}', '{{initializeDownloadUrl}}')"><span class="glyphicon glyphicon-file" aria-hidden="true"></span>&nbsp;{{title}}</a>
                  {{/if}}
                  <p class="fragment text-muted">{{{fragment}}}</p>
                </li>
              {{/each}}
            {{/if}}
            </ul>
          </li>
        {{/each}}
      </ul>
    {{else}}
      <h2>{%endraw%}{{ resx.Search_No_Results_Found }}{%raw%}<em class="querytext">{{{query}}}</em>
        {{#if isResetVisible}}
          <a class="btn btn-default btn-sm facet-clear-all" role="button" title="{%endraw%}{{ snippets['Search/Facet/ClearConstraints'] | default: res['Search_Filter_Clear_All'] }}{%raw%}" tabIndex="0">{%endraw%}{{ snippets['Search/Facet/ClearConstraints'] | default: res['Search_Filter_Clear_All'] }}{%raw%}</a>
        {{/if}}
      </h2>
   {{/if}}
  </script>
  <script type="text/javascript">
    function downloadKbAttachmentFile(attachmentElementId, fileName, fileSize, mimeType, downloadBlockUrl, initializeUrl) {
      // Download block API supports max 4MB block size
      const blockSizeInBytes = 4096 * 1024;
      const totalNumberOfBlocks = parseInt(fileSize / blockSizeInBytes + 1);
      var fileContinuationToken = "";
      var contentString = "";
      var numberOfBlocksDownloaded = 0;
      var blockNumberToContentMap = {};
      function downloadBlockCallback(i, result) {
        numberOfBlocksDownloaded++;
        blockNumberToContentMap[i] = result;
        if (numberOfBlocksDownloaded == totalNumberOfBlocks) {
          for (var j = 0; j < totalNumberOfBlocks; j++) {
            contentString += blockNumberToContentMap[j];
          }
          var isImage = mimeType.startsWith('image/');
          const attachmentElement = document.getElementById(attachmentElementId);
          if (isImage) {
            const bodyByteString = atob(contentString);
            const bodyBuffer = new ArrayBuffer(bodyByteString.length);
            const bodyView = new Uint8Array(bodyBuffer);
            for (var k = 0; k < bodyByteString.length; k++) {
              bodyView[k] = bodyByteString.charCodeAt(k);
            }
            var imageUrl = URL.createObjectURL(new Blob([bodyBuffer], { type: mimeType }));
            attachmentElement.href = imageUrl;
            attachmentElement.target = "_blank";
          }
          else {
            const linkSource = 'data:' + mimeType + ';base64,' + contentString;
            attachmentElement.href = linkSource;
            attachmentElement.download = fileName;
          }
          attachmentElement.click();
        }
      }
      shell.ajaxSafePost({
        type: 'GET',
        url: initializeUrl,
        success: function (result) {
          fileContinuationToken = encodeURIComponent(result);
          for (var i = 0; i < totalNumberOfBlocks; i++) {
            url = downloadBlockUrl + "&blockNumber=" + i + "&fileContinuationToken=" + fileContinuationToken + "&blockSize=" + blockSizeInBytes;
            var x = downloadBlockCallback.bind(this,i);
            shell.ajaxSafePost({
              type: 'GET',
              url: url,
              success: (result) => { x(result) }
            });
          }
        }
      });
    }
  </script>
{%endraw%}

網站設定

您必須將 \_logicalname:annotation~0.9^0.25 值新增至 Search/Query 網站設定。 新增之後,此值應該如下所示:

+(@Query) \_title:(@Query) \_logicalname:knowledgearticle~0.9^0.3 \_logicalname:annotation~0.9^0.25 \_logicalname:adx_webpage~0.9^0.2 -\_logicalname:adx_webfile~0.9 adx_partialurl:(@Query) \_logicalname:adx_blogpost~0.9^0.1 -\_logicalname:adx_communityforumthread~0.9

若要將層面設定為單一層面中與知識庫文章及 Web 檔案相關聯的群組註釋,請編輯 Search/RecordTypeFacetsEntities 網站設定名稱,並將 ;Downloads:annotation,adx_webfile 附加至其值。

若要允許與知識庫文章相關聯的附件出現在網站及搜尋結果中,請編輯 KnowledgeManagement/DisplayNotes 網站設定,並將其值設定為 TrueKnowledgeManagement/NotesFilter 網站設定包含必須在在附註上加在附註文字欄位前面的首碼值;只有包含指定之首碼值的附註才會在網頁中出現。 此值預設為 *WEB*,但您可以透過網站設定進行變更。

若要啟用與附註相關聯檔案附件的索引編製,請建立 Search/IndexNotesAttachments 網站設定,並將其值設定為 True