---
title: "インデックス作成"
slug: "indexing"
abstract: ""
---
# インデックス作成

Connectをインストールすると、デフォルトのインデックスがすべての製品データを除外するようにパッチが適用され、拡張された製品データを含む別の製品インデックスが作成されます。

すべての製品または製品リストを同期している間はインデックス作成が停止されます。同期が終わるとインデックスは再構築されます。これはパフォーマンス向上のためです。以下の構成スニペットは、インデックスに関連するプロセッサを含むSynchronizeProductListパイプラインのデフォルト構成を示しています。

<commerce.synchronizeProducts.synchronizeProductList>
<processor type="Sitecore.Commerce.Pipelines.Products.SynchronizeProductList.PauseSearchIndexing, Sitecore.Commerce" />
<processor type="Sitecore.Commerce.Pipelines.Products.SynchronizeProductList.SynchronizeProductList, Sitecore.Commerce" />
<processor type="Sitecore.Commerce.Pipelines.Products.SynchronizeProductList.ResumeSearchIndexing, Sitecore.Commerce" />
<processor type="Sitecore.Commerce.Pipelines.Products.SynchronizeProductList.RebuildSearchIndexes, Sitecore.Commerce" />
</commerce.synchronizeProducts.synchronizeProductList>

Sitecore.Commerce.Products.Configファイル内の設定ProductSynchronization.ProductIndexes、商品同期中に停止・再起動されるインデックス名のカンマ区切りリストが含まれています。

<!-- PRODUCT INDEXES.
The indexes are used to store synchronized products.
Can be stopped, resumed and rebuilt automatically during product synchronization.
-->
<setting name="ProductSynchronization.ProductIndexes" value="sitecore\_master\_index, commerce\_products\_master\_index" />

> !注新しいまたはカスタム製品テンプレートが導入された場合、DefaultIndexConfigurationとProductインデックスの構成の両方を更新する必要があります。

> !警告追加のインデックスが作成された場合は、設定をインデックス名を含めて更新する必要があります。そうでなければ同期中にインデックス作成が続き、パフォーマンスが低下します。

## デフォルトインデックス

設計上、デフォルトのマスターインデックスとウェブインデックスは、製品リポジトリに保存されているアイテムを含まないように設定されています。デフォルトのインデックス構成は、各製品テンプレートのエントリを含むExcludeセクションでパッチが当てられています。

<exclude hint="list:ExcludeTemplate">
<ProductRepositoryTemplateId>{F599BF48-D6FE-40DC-9F78-CF2D56BFB657}</ProductRepositoryTemplateId>
 <ProductTemplateId>{47D1A39E-3B4B-4428-A9F8-B446256C9581}</ProductTemplateId>
…
</exclude>
## 製品指数

Connectはマスターデータベースとウェブデータベースの両方に独自の製品インデックスを備えています。このインデックスはいくつかの目的を果たしています:

-   コンテンツを2つの別々のインデックスでデータから分離すること。
    
    製品インデックスは、コンテンツエディター内で製品リポジトリのバケットを検索する際に使用されます。これはgetContextIndexパイプラインのパッチを当てることで実現されます。
    
    <contentSearch.getContextIndex>
    <processor type="Sitecore.Commerce.Pipelines.ContentIndex.CustomIndex.FetchCustomIndex,
    Sitecore.Commerce"                patch:before="processor@type='Sitecore.ContentSearch.Pipelines.GetContextIndex.FetchIndex,
    Sitecore.ContentSearch'"/>
    </contentSearch.getContextIndex>
    
-   拡張製品データを含めること。
    
    commerce.inventory.stockStatusForIndexingパイプラインは外部商取引システムから製品ごとの在庫データを読み取り、インデックスを埋め込みます。計算されたフィールドが在庫データを含めるために使われます。構成はSitecore.Commerce.Products.Lucene.Index.Common.configファイルで確認できます。以下の表は、4つのフィールドで拡張された製品インデックスの例を示しています:
    
    -   在庫あり—商品が在庫されている場所のリストを含みます。
    -   在庫切れ—商品が在庫切れの場所一覧を含みます。
    -   ロケーション—商品が注文可能な場所のリストを含みます。
    -   Pre-Orderable—商品が事前注文可能かどうかを示すブール値を含む。

製品ID(バリアントではない)

サイズ

カラー

在庫あり

在庫切れ

所在地

予約注文可能

AW123-04

S、M、L、XL

R、B、G、O

セントラルストア、ストア1、ストア2

ストア3

セントラルストア1、ストア2、ストア3

製品インデックスはSitecore.Commerce.Products.Lucene.Index.Master.configファイルで定義されています。Webインデックスには同様の構成ファイルが定義されています。

<configuration
xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<contentSearch>
<configuration type="Sitecore.ContentSearch.ContentSearchConfiguration,
Sitecore.ContentSearch">

<indexes hint="list:AddIndex">

<index id="commerce\_products\_master\_index" type="Sitecore.ContentSearch.LuceneProvider.LuceneIndex,
Sitecore.ContentSearch.LuceneProvider">
<param
desc="name">$(id)</param>
            <param desc="folder">$(id)</param>
            <!-- This initializes the index property store. Id has to be set to
the index id -->
            <param
desc="propertyStore" ref="contentSearch/databasePropertyStore" param1="$(id)"
/>
            <configuration
ref="contentSearch/indexConfigurations/defaultLuceneIndexConfiguration"/>
            <strategies
hint="list:AddStrategy">
              <!--
NOTE: Order controls the execution order -->
              <strategy
ref="contentSearch/indexUpdateStrategies/syncMaster" />
            </strategies>
            <commitPolicyExecutor
type="Sitecore.ContentSearch.CommitPolicyExecutor,
Sitecore.ContentSearch">
              <policies
hint="list:AddCommitPolicy">
                <policy
type="Sitecore.ContentSearch.TimeIntervalCommitPolicy,
Sitecore.ContentSearch" />
              </policies>
            </commitPolicyExecutor>
            <locations
hint="list:AddCrawler">
              <crawler
type="Sitecore.Commerce.Search.ProductItemCrawler,
Sitecore.Commerce">
                <Database>master</Database>
                <Root>/sitecore/content/Product Repository</Root>
              </crawler>
            </locations>  
</index>
</indexes>
</configuration>
</contentSearch>
</sitecore>
</configuration>

> !注製品リポジトリは以下のパス /sitecore/content/Product Repositoryの下にあると仮定されます。もしそうでない場合は、クローラーの <Root> 要素を実際の位置を反映するように更新する必要があります。

カスタムクローラーは、Sitecore.Commerce.Products.config設定ファイルの<includeTemplates>セクションで定義された製品テンプレートに基づくアイテムを含むために製品インデックスに使用されます。このセクションで定義された製品テンプレートのリストは、DefaultIndexConfigurationの除外テンプレートセクションと完全に一致しています。カスタム製品テンプレートが導入された場合、インデックス構成は更新されなければなりません。

<includeTemplates>
 <ProductRepositoryTemplateId>{F599BF48-D6FE-40DC-9F78-CF2D56BFB657}</ProductRepositoryTemplateId>
 <ProductTemplateId>{47D1A39E-3B4B-4428-A9F8-B446256C9581}</ProductTemplateId>
…
</includeTemplates>