1. 行政

チュートリアル : カスタム インデックスの作成

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

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

デフォルトのインデックスが目的に合わない場合は、検索プロバイダー用に独自のカスタムインデックスを作成できます。このチュートリアルでは、新しいカスタム インデックスを作成する方法、インデックスの増分更新のポリシーを作成する方法、およびインデックス自体を更新するための更新戦略を構成する方法について説明します。

このチュートリアルでは、新しいカスタム インデックスは検索プロバイダーとしてSolrを使用し、Sitecore MasterデータベースのCommerceカタログ アイテムを含みます。

新しいSolrコアを作成する

新しいSolrコアを作成するには、次のようにします。

  • 新しいSolrコアを作成して初期化し、名前を付けます (例: mysite_master_products.

新しいCommerce Engineリストを作成して、増分変更を追跡します

すべてのインデックス作成設定は、Plugin.CatalogIndexing.PolicySet-1.0.0.jsonファイルに保存されます。カスタムインデックスの増分更新を追跡するための新しいリストを作成するようにCommerce Engineに指示する新しいポリシーを追加する必要があります。

Sitecore XCでのインデックスの増分更新の詳細については、「 インデックスの増分更新 」トピックを参照してください。

メモ

この設定は、すべてのCommerce Engine環境に追加する必要があります。

Commerce Engineで新しいリストを作成して増分変更を追跡するには:

  1. c:\inetpub\wwwroot\<environment>\wwwroot\data\Environmentsフォルダに移動し、Plugin.CatalogIndexing.PolicySet-1.0.0.jsonファイルを開きます。

  2. "$values"リストの下に、カスタムインデックスの増分更新用のマネージドリストを作成するためのポリシーブロックを追加します。

      {
        "$type": "Sitecore.Commerce.Plugin.Catalog.SitecoreCatalogIndexingPolicy, Sitecore.Commerce.Plugin.Catalog",
        "Name": "MySiteSellableItemsIndexMaster",
        "IncrementalListName": "MySiteSellableItemsIncrementalMasterProducts",
        "DeletedListName": "MySiteSellableItemsDeletedMasterProducts",
        "EntityTypeNames": {
          "$type": "System.Collections.Generic.List`1[[System.String, mscorlib]], mscorlib",
          "$values": [
             "Sitecore.Commerce.Plugin.Catalog.SellableItem, Sitecore.Commerce.Plugin.Catalog"
          ]
        },
        "IsMasterIndex": true
      },
      {
        "$type": "Sitecore.Commerce.Plugin.Catalog.SitecoreCatalogIndexingPolicy, Sitecore.Commerce.Plugin.Catalog",
        "Name": "MySiteCategoriesMasterProducts",
        "IncrementalListName": "MySiteCategoriesIncrementalMasterProducts",
        "DeletedListName": "MySiteCategoriesDeletedMasterProducts",
        "EntityTypeNames": {
          "$type": "System.Collections.Generic.List`1[[System.String, mscorlib]], mscorlib",
          "$values": [
            "Sitecore.Commerce.Plugin.Catalog.Category, Sitecore.Commerce.Plugin.Catalog"
          ]
        },
        "IsMasterIndex": true
      },
      {
        "$type": "Sitecore.Commerce.Plugin.Catalog.SitecoreCatalogIndexingPolicy, Sitecore.Commerce.Plugin.Catalog",
        "Name": "MySiteCatalogsMasterProducts",
        "IncrementalListName": "MySiteCatalogsIncrementalMasterProducts",
        "DeletedListName": "MySiteCatalogsDeletedMasterProducts",
        "EntityTypeNames": {
          "$type": "System.Collections.Generic.List`1[[System.String, mscorlib]], mscorlib",
          "$values": [
             "Sitecore.Commerce.Plugin.Catalog.Catalog, Sitecore.Commerce.Plugin.Catalog"
          ]
        },
        "IsMasterIndex": true
      }
  3. Commerce Engineをブートストラップして、変更を保持します。

  4. IISマネージャーでIISのリセットを実行します。

インデックス設定ファイルの作成

新しいカスタムインデックスの設定ファイルを作成する必要があります。インデックス設定ファイルには、次のものが含まれている必要があります。

  • インデックス名、インデックスが関連付けられているSolrコア、プロパティ ストアなど、インデックスに関する一般的な情報。

  • インデックスの増分更新のために変更または削除された項目を取得するために使用される更新戦略への参照。

  • インデックスと開始するコンテンツ ツリー内のルートの場所を設定するクローラの定義。

  • インデックスによって参照される各更新戦略の詳細な定義。

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:search="http://www.sitecore.net/xmlconfig/search/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
  <sitecore search:require="solr">
    <contentSearch>
      <configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
        <indexes hint="list:AddIndex">
          <index id=" mysite_master_products" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
            <param desc="name">$(id)</param>
            <param desc="core"> mysite_master_products</param>
            <param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />
            <configuration ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration" />
            <strategies hint="list:AddStrategy">
              <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/mysite_products_sellableItemsIntervalAsynchronousStrategyMaster" />
              <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/mysite_products_categoriesIntervalAsynchronousStrategyMaster" />
              <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/mysite_products_catalogsIntervalAsynchronousStrategyMaster" />
            </strategies>
            <locations hint="list:AddCrawler">
              <crawler type="Sitecore.Commerce.Engine.Connect.Search.Crawlers.AllCatalogItemsCrawler, Sitecore.Commerce.Engine.Connect">
                <ItemsToTake>100</ItemsToTake>
                <Environments hint="list">
                  <environment>HabitatAuthoring</environment>
                </Environments>
                <Database>master</Database>
              </crawler>
            </locations>
          </index>
        </indexes>
      </configuration>
      <indexConfigurations>
        <indexUpdateStrategies>
          <mysite_products_sellableItemsIntervalAsynchronousStrategyMaster type="Sitecore.Commerce.Engine.Connect.Search.Strategies.SellableItemsIntervalAsynchronousStrategy, Sitecore.Commerce.Engine.Connect">
            <IncrementalIndexListName>MySiteSellableItemsIncrementalMasterProducts</IncrementalIndexListName>
            <DeletedIndexListName>MySiteSellableItemsDeletedMasterProducts</DeletedIndexListName>
            <ItemsToTake>100</ItemsToTake>
            <Environments hint="list">
              <environment>HabitatAuthoring</environment>
            </Environments>
            <param desc="interval">00:10:00</param>
            <param desc="database">master</param>
          </mysite_products_sellableItemsIntervalAsynchronousStrategyMaster>
          <mysite_products_categoriesIntervalAsynchronousStrategyMaster type="Sitecore.Commerce.Engine.Connect.Search.Strategies.CategoriesIntervalAsynchronousStrategy, Sitecore.Commerce.Engine.Connect">
            <IncrementalIndexListName>MySiteCategoriesIncrementalMasterProducts</IncrementalIndexListName>
            <DeletedIndexListName>MySiteCategoriesDeletedMasterProducts</DeletedIndexListName>
            <ItemsToTake>100</ItemsToTake>
            <Environments hint="list">
              <environment>HabitatAuthoring</environment>
            </Environments>
            <param desc="interval">00:10:00</param>
            <param desc="database">master</param>
          </mysite_products_categoriesIntervalAsynchronousStrategyMaster>
          <mysite_products_catalogsIntervalAsynchronousStrategyMaster type="Sitecore.Commerce.Engine.Connect.Search.Strategies.CatalogsIntervalAsynchronousStrategy, Sitecore.Commerce.Engine.Connect">
            <IncrementalIndexListName>MySiteCatalogsIncrementalMasterProducts</IncrementalIndexListName>
            <DeletedIndexListName>MySiteCatalogsDeletedMasterProducts</DeletedIndexListName>
            <ItemsToTake>100</ItemsToTake>
            <Environments hint="list">
              <environment>HabitatAuthoring</environment>
            </Environments>
            <param desc="interval">00:10:00</param>
            <param desc="database">master</param>
          </mysite_products_catalogsIntervalAsynchronousStrategyMaster>
        </indexUpdateStrategies>
      </indexConfigurations>
    </contentSearch>
  </sitecore>
</configuration>

カスタムインデックス設定ファイルを作成するには:

  1. App_Config\Includeフォルダー内の新しいテキスト ファイルを開き、関連するファイル名と.config拡張子 (my_site_master-products_index.configなど) を付けて保存します。

  2. ファイルを開き、インデックス設定を追加します (前の例をガイドとして使用します)。

    インデックス構成プロパティの構成に加えて、インデックス・クローラを定義し、インデックス更新戦略の構成を含める必要があります。

  3. 変更を保存します。

    手記

    この例では、カスタム インデックスはMasterデータベースの項目を含むように構成されています。このため、カスタム インデックス設定ファイルは、CMデプロイメントのApp_Config\Includeフォルダに格納します。

GetChildrenToIndexプロセッサのインデックスの一覧にカスタム インデックスを追加します

新しいインデックスをSitecore GetChildrenToIndexプロセッサに追加する必要があります。Sitecore XCは、独自のクローラーを使用してCommerceアイテムのインデックスを作成します。 Sitecore.Commerce.Engine.Connect.Pipelines.GetChildrenToIndexプロセッサは、デフォルトのSitecoreインデックス クローラーがCommerceアイテムのインデックス作成を試みるのを停止します。

カスタム インデックスをSitecoreの子インデックスのリストに追加するには、次の手順に従います。

  1. C:\inetpub\wwwroot\cqa-dem-01-dk1\App_Config\Include\Y.Commerce.Engineフォルダーで、Sitecore.Commerce.Engine.Connectors.Index.Common.configファイルを開きます。

  2. 次の例に示すように、カスタムインデックスをインデックスのリストに追加します。

    <pipelines>
      <indexing.getChildrenToIndex>
         <!-- 
              Insert our processor first so that we can intercept Commmerce items that we do    not want indexed into the below referenced indexes.
              As Commerce uses a separate crawler to index Commerce items, we insert this processor to stop the default crawlers from attempting to index
              Commerce items.
              By default the processor below will skip indexing of children of the following locations or templates:
                Commerce Catalog Folder   ID {334E2B54-F913-411D-B159-A7B16D65242C}
         -->
         <processor type="Sitecore.Commerce.Engine.Connect.Pipelines.GetChildrenToIndex, Sitecore.Commerce.Engine.Connect" patch:source="Sitecore.Commerce.Engine.Connectors.Index.Common.config">
            <!-- The list of indexes that we do not want commerce items to be indexed to -->
            <Indexes hint="list:AddString" help="Add index names below to stop crawling of Commerce items by the default crawler">
              <IndexName>sitecore_master_index</IndexName>
              <IndexName>sitecore_web_index</IndexName>
              <IndexName>sitecore_testing_index</IndexName>
              <IndexName>sitecore_suggested_test_index</IndexName>
             <IndexName>mysite_master_products/IndexName>
            </Indexes
この記事を改善するための提案がある場合は、 お知らせください!