How to create document crawler smart search index using the API?

Kentico Support Engineer asked on February 24, 2013 13:48

How to create document crawler smart search index using the API?

Correct Answer

Kentico Support Engineer answered on February 24, 2013 13:48

Our Developer’s guide describes how to create smart search indexes using the API.  With the exception of the Document crawler index type, you can set a value of the newIndex.IndexType property from PredefinedObjectType enumerator.

For example: newIndex.IndexType = PredefinedObjectType.DOCUMENT;

However, the document crawler index type specifically needs to be set like this:
newIndex.IndexType = SearchHelper.DOCUMENTS_CRAWLER_INDEX;

So, a complete API example would look like:

// Create new search index object
SearchIndexInfo newIndex = new SearchIndexInfo();

// Set the properties
newIndex.IndexDisplayName = "My new index";
newIndex.IndexName = "MyNewIndex";
newIndex.IndexIsCommunityGroup = false;
newIndex.IndexType = SearchHelper.DOCUMENTS_CRAWLER_INDEX;
newIndex.IndexAnalyzerType = AnalyzerTypeEnum.StandardAnalyzer;
newIndex.StopWordsFile = "";

// Save the search index
SearchIndexInfoProvider.SetSearchIndexInfo(newIndex);
0 votesVote for this answer Unmark Correct answer

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