---
title: "インデックスクローラー"
slug: "the-indexcrawler"
abstract: "既存のインデックスを取り、その上で関数を実行します。"
---
# インデックスクローラー

IndexCrawlerは既存のインデックスを取り、その上に複数の関数を実行させるクローラーです。

IndexCrawlerはFlatDataCrawler<T>から継承します。つまり、IIndexablesのリストを渡してそれらを反復し、各IIndexableで関数を実行してインデックスに戻すことを意味します。

これが使える例です:インデックス内のすべてのドキュメントを確認し、すべてのドキュメント名に「!!」を付け加えます。コードは次のようになります:

var crawler = new IndexCrawler(this.sourceIndexName);
crawler.CrawlFunctions += this.CallMe;
this.DestinationIndex.AddCrawler(crawler);
this.DestinationIndex.Rebuild();
public IEnumerable<IIndexable> CallMe(IProviderSearchContext context)
{
 var list = new List<IIndexable>();
 foreach (var item in context.GetQueryable<InsertDocument>())
 {
 item.Name = item.Name + "!!";
 list.Add(new ObjectIndexable(item, null));
 }
 return list.AsEnumerable();
}