---
title: "SXAインデックスの設定"
slug: "configure-sxa-indexing"
abstract: "サイトや言語ごとにインデックスを定義してください。"
---
# SXAインデックスの設定

SXAは特定の言語やサイトごとにインデックスを定義できます。これは、インデックスを小さく保ちパフォーマンスを向上させたいときにデータを分離したいときに便利です。

## インデックスを追加

インデックスを追加すると:

1.  */sitecore/content/Tenant/Site/Settings/Site Grouping/Site*へナビゲート。
    
2.  インデックス **セクション** で、サイトのインデックス仕様を入力します。必ずデータベースの後にスラッシュで始めてください。その後、言語を指定するか、すべての言語を含めるために\*を使うことができます。
    
    例えば、サイト固有の索引を作成したり、英語とスペイン語を分けたりすることができます:
    
    ![Index specification on language.](https://doc.sitecore.com/api/markdown-image/xp/ja/developers/sxa/104/sitecore-experience-accelerator/images/SXA-indexing.png)
    
    > !注SXA検索インデックスを特定の言語の項目を含めたい場合、クローラー用の言語パラメータを追加する必要があります:
    > 
    > マスター /サイトコア EN
    
3.  検索プロバイダーの設定ファイルにアクセスして、作成したインデックスを追加してください。例えば、Solrを使っている場合は、C:\\inetpub\\wwwroot\\Site\\Website\\App\_Config\\Include\\Z.Foundation.Overrides\\Sitecore.XA.Foundation.Search.Solrに行きインデックスを追加します。
    

デフォルトのクローラーパスは <Root>/sitecore</Root>です。カスタムインデックスでアイテムクローラーパスをデフォルトパスとは異なるパス(例: <Root>/sitecore/content/TenantA/SiteA/Home/NewFolder</Root>)を使うように設定すると、以下のような影響があります。

-   そのパスのアイテムのみがインデックスされます。
-   カスタムインデックスにはテンプレートは含まれません。

インデックスにテンプレートが欠けていると、フィールド型の解決ロジックに影響を与える可能性があります。場合によってはフィールド型が見つからず、検索やフィルタリング時に問題が発生することがあります。これを解決するには、設定ファイル内のすべてのカスタムフィールドを手動で定義し、Sitecoreが使用するタイプ(文字列、整数、テキストなど)を把握できるようにします。

![SXA-Indexing-custom-fields.png](https://doc.sitecore.com/api/markdown-image/xp/ja/developers/sxa/104/sitecore-experience-accelerator/images/SXA-Indexing-custom-fields.png)

> !注Sitecoreのインデックス作成に関する一般的な情報については、[プラットフォームのドキュメント](https://doc.sitecore.com/xp/en/developers/103/platform-administration-and-architecture/configure-indexing.html)をご参照ください。

## カスタムインデックスの設定

SXA固有のフィールドはすべてのインデックスに自動的に含まれるわけではありません。カスタムインデックスを使用しつつSXAの検索機能も使いたい場合は、SXA固有のフィールドを含めるようにカスタムインデックスを設定する必要があります。

SXA固有のフィールドをインデックスに追加するには:

1.  インデックス設定で、カスタムインデックスを定義するindexノードを見つけてください。
    
2.  documentOptionsノード内で、次のコードを追加します:
    
    <fields hint="raw:AddComputedIndexField">
     <field fieldName="site">
     <patch:delete /></field>
     <field fieldName="site" returnType="stringCollection">Sitecore.XA.Foundation.Search.ComputedFields.Site, Sitecore.XA.Foundation.Search</field>
     <field fieldName="sxacontent" returnType="textCollection" type="Sitecore.XA.Foundation.Search.ComputedFields.AggregatedContent, Sitecore.XA.Foundation.Search">
     <mediaIndexing ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration/mediaIndexing"/>
     </field>
     <field fieldName="haslayout" returnType="bool">Sitecore.XA.Foundation.Search.ComputedFields.HasLayout, Sitecore.XA.Foundation.Search</field>
     <field fieldName="searchable">Sitecore.XA.Foundation.Search.ComputedFields.Searchable, Sitecore.XA.Foundation.Search</field>
     <field fieldName="parentname" returnType="string">Sitecore.XA.Foundation.Search.ComputedFields.ParentName, Sitecore.XA.Foundation.Search</field>
     <field fieldName="level" returnType="int">Sitecore.XA.Foundation.Search.ComputedFields.Level, Sitecore.XA.Foundation.Search</field>
     <field fieldName="parenttemplate" returnType="string">Sitecore.XA.Foundation.Search.ComputedFields.ParentTemplate, Sitecore.XA.Foundation.Search</field>
     <field fieldName="inheritance" returnType="stringCollection" type="Sitecore.XA.Foundation.Search.ComputedFields.Inheritance, Sitecore.XA.Foundation.Search"/>
    </fields>
    
3.  変更を保存してインデックスを再構築します。