I am building a custom .NET Page and I need to query the total count of items in each Sitecore index (backend is Solr). I have not been able to find any "hooks" or documentation of the Sitecore API to support my needs.

In older versions (I am building on 8.1), I was able to use the Sitecore.Search.SearchManager but it appears this is now obsolete. I am leaning towards hitting the Solr API directly.

  • 1
    Have you looked into using ContentSearchManager? Would the following work for you? gist.github.com/grg17/cc8a6400d5205555e68c300842b411c0 You should always use Sitecore API instead of directly going to Solr API.
    – grg
    Nov 7, 2018 at 22:20
  • That may be a better fit. Is that becoming obsolete like the Search.SearchManager?
    – Kode
    Nov 7, 2018 at 22:31
  • Also, do you know where in the Sitecore docs they list the info/options for ContentSearchManager?
    – Kode
    Nov 7, 2018 at 22:41

2 Answers 2


Below link will help you get all the details about how to access indexes using LINQ



You can also create your custom indexes so you can get count of total items for each index while building the indexes. Essentially when you access indexes all the calculations are done and you just fetch the total count.

Here's the example of creating custom indexes.



The Sitecore ContentSearchManager is what you want for this kind of thing. It's definitely not obsolete.

First add a reference to the ContentSearch API by adding Sitecore.ContentSearch and Sitecore.ContentSearch.Linq libraries either as a direct reference or via the nuget feed.

You can query index state like this:

foreach (var index in ContentSearchManager.Indexes)
    var summary = index.Summary;
    var documents = summary.NumberOfDocuments;

Documentation for querying indexes is available here.

  • Very helpful, but where did you get the values of .Indexes like Summary and NumberofDocuments? Are the allowed variables listed somewhere for what ContentSearchManager.Indexes allows us to Query?
    – Kode
    Nov 8, 2018 at 18:55
  • I can open the dll in reflector if necessary, but it would be nice to have some docs
    – Kode
    Nov 8, 2018 at 19:26
  • 1
    I think that part of the api won't be documented so you're best off reflecting the dlls Nov 8, 2018 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.