1. 連絡先

カスタムコンタクトファセットのインデックス作成

Version:
日本語翻訳に関する免責事項

このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。

カスタム取引先担当者ファセットを作成して、組織が追跡する情報 (住所、国、Eメールアドレスなど) を含めることができます。集約プロセス中にこれらのカスタムコンタクトファセットにインデックスを付けるには、contactindexable.loadfieldsパイプラインを拡張する必要があります。

contactindexable.loadfieldsパイプラインは、インデックス作成に使用できるフィールドを読み込むために、Sitecore.ContentSearch.Analytics.Models.ContactIndexableフィールド タイプによって使用されます。contactindexable.loadfieldsパイプラインのカスタム プロセッサは、Sitecore.ContentSearch.Analytics.Pipelines.ContactIndexableLoadFields.ContactIndexableLoadFieldsProcessor基本クラスから継承する必要があります。

LuceneとSolrのどちらを使用するかによって、Sitecore.ContentSearch.Lucene.Index.Analytics.configファイルまたはSitecore.ContentSearch.Solr.Index.Analytics.configファイルを構成して、適切なインデックスに追加するインデックス作成可能なフィールドを定義する必要があります。

メモ

この機能は、Sitecore 8.1 Update 3以降でのみ使用できます。

カスタムコンタクトファセットをインデックス化するには:

  1. contactindexable.loadfieldsパイプラインを拡張して、カスタムファセットからコンタクトインデックス可能フィールドのコレクションにデータを追加するカスタムプロセッサを実装します。

    using System.Collections.Generic;
    using Sitecore.ContentSearch;
    using Sitecore.ContentSearch.Analytics.Pipelines.ContactIndexableLoadFields;
    using Sitecore.Diagnostics;
    namespace Sitecore.IndexingCustomFacets
    {
      public class LoadFields : ContactIndexableLoadFieldsProcessor
      {
        protected override IEnumerable<IIndexableDataField> GetFields(ContactIndexableLoadFieldsPipelineArgs args)
        {
          Assert.ArgumentNotNull(args, "args");
          var contact = args.Contact;
          Assert.IsNotNull(contact, "contact");
          var fields = new List<IIndexableDataField>();
          var customFacet = contact.GetFacet<ICustomContactFacet>("CustomContactFacetName");
          if (customFacet != null)
          {
            fields.Add(new IndexableDataField<bool>("contact.CustomFieldName", customFacet.CustomField));
          }
          return fields;
        }
      }
    }
  2. \App_Config\Includeフォルダーに、新しいプロセッサをcontacindexable.loadfieldsパイプラインに追加する新しい構成インクルード ファイルを作成します。

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"
      <sitecore>
        <pipelines>
          <contactindexable.loadfields>
            <processor type="Sitecore.IndexingCustomFacets.LoadFields, Sitecore.IndexingCustomFacets" />
          </contactindexable.loadfields>
        </pipelines>
      </sitecore>
    </configuration>
  3. 新しい設定ファイルをWebサイトのApp_Config\Includeフォルダにコピーします。

  4. 新しいフィールドをインデックスに格納するように分析インデックスを構成します。

    • Solrを使用する場合は、新しい構成インクルード・ファイルを作成して、Sitecore.ContentSearch.Solr.Index.Analytics.configファイルで定義されている <fieldNames hint="raw:AddFieldByFieldName"> ノードの下に新しいフィールドを追加します。

      例えば:

      <?xml version="1.0" encoding="utf-8" ?>
      <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"
        <sitecore>
          <contentSearch>
            <configuration>
              <indexes>
                <index id="sitecore_analytics_index">
                  <configuration>
                    <fieldMap>
                      <fieldNames>
                        <field fieldName="contact.CustomFieldName" returnType="bool" />
                      </fieldNames>
                    </fieldMap>
                  </configuration>
                </index>
              </indexes>
            </configuration>
          </contentSearch>
        </sitecore>
      </configuration>
    • Luceneを使用する場合は、新しい構成インクルード ファイルを作成して、Sitecore.ContentSearch.Lucene.Index.Analytics.configファイルで定義されている <fieldNames hint="raw:AddFieldByFieldName"> ノードの下に新しいフィールドを追加します。

      例えば:

      <?xml version="1.0" encoding="utf-8" ?>
      <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"
       <sitecore>
         <contentSearch>
           <configuration>
             <indexes>
               <index id="sitecore_analytics_index">
                 <configuration>
                   <fieldMap>
                     <fieldNames>
                       <field fieldName="contact.CustomFieldName" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.Boolean" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
                     </fieldNames>
                   </fieldMap>
                 </configuration>
               </index>
             </indexes>
           </configuration>
         </contentSearch>
       </sitecore>
      </configuration>
この記事を改善するための提案がある場合は、 お知らせください!