Get all items from searchindex

Kenny Deblaere asked on April 29, 2016 11:04


I'm looking to get all of the indexed items in the code. At this moment, I have this as code

string indexName = "indexname";
var index = SearchIndexInfoProvider.GetSearchIndexInfo(indexName);

// returning 0
var itemChildrenNumbers = index.Children.Count;

// returning an empty CombinedInfoObjectCollection
var itemChildren = index.Children.All;

// returning the right amount of indexed items
var numberOfIndexedItems = index.NumberOfIndexedItems;

How can i get all the indexed items in the code. I want to receive a list with the items.

Correct Answer

Chetan Sharma answered on April 29, 2016 12:30

Hi, I am providing you with a code snippet. You may modify it to suit your needs.

private  DataSet SearchText(string searchQuery)
// Get the search index
SearchIndexInfo index = SearchIndexInfoProvider.GetSearchIndexInfo(searchIndex);
DataSet results = new DataSet();

if (index != null)
    // Prepare parameters
    SearchParameters parameters = new SearchParameters()
        SearchFor = searchQuery,
        Path = "/%",
        ClassNames = "",
        CurrentCulture = "EN-US",
        DefaultCulture = CultureHelper.DefaultUICulture.IetfLanguageTag,
        CombineWithDefaultCulture = false,
        CheckPermissions = false,
        SearchInAttachments = false,
        User = (UserInfo) CMS.Membership.MembershipContext.AuthenticatedUser,
        SearchIndexes = index.IndexName,
        StartingPosition = 0,
        DisplayResults = 5000,
        NumberOfProcessedResults = 5000,
        NumberOfResults = 5000,
        AttachmentWhere = String.Empty,
        AttachmentOrderBy = String.Empty,

    // Search returns resultset.
    results = SearchHelper.Search(parameters);
return results;


This will give you DataSet. You can then use JSOn serializer to return results in json format.

CHeers, Chetan

2 votesVote for this answer Unmark Correct answer

Recent Answers

Kenny Deblaere answered on April 29, 2016 15:01

Thanks for your answer. My next step in the filtering is more than one element, for example, I search for id (1000 and 1001).

Can I filter these with the parameters?

0 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on May 2, 2016 17:37

Hi Kenny,

Sorry for three late reply. I didn't get any notification from Kentico.

Did you check this ?

Let me know if you need further help to figure out this?

Thanks Chetan

0 votesVote for this answer Mark as a Correct answer

Tom Troughton answered on May 17, 2016 14:33

Guys, I'm not clear from the answer how to return all documents. The OP stated that the requirement was to return all documents but Chetan's code expects a string query. I'm finding that using an empty string here returns nothing, so I'm still unclear how to return all documents from an index...?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.