Is there a way to get the index root.

I am able to find the current index using the following code


How can I get the current Root defined inside the index ?


  • You can have multiple roots for the same location tag, what do you want to achieve here? Jun 17, 2021 at 6:58

1 Answer 1


The simplest code would be like that:

var crawler = Sitecore.ContentSearch.ContentSearchManager.GetIndex(indexName).Crawlers.First() as SitecoreItemCrawler;
string rootString = crawler.Root;
Item rootItem = crawler.RootItem;

It assumes that there is one crawler defined only.

You should add some null checks, but I skipped them for clarity.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy