Kentico CMS 6.0 Developer's Guide

Managing search index cultures

Managing search index cultures

Previous topic Next topic Mail us feedback on this topic!  

Managing search index cultures

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

Arrow


API examples for newer versions


Please visit the latest API Examples documentation to view API examples for newer versions of Kentico.



The following example assigns a culture to a smart search index.

 

private bool AddCultureToSearchIndex()
{
    // Get the search index and culture

  SearchIndexInfo index = SearchIndexInfoProvider.GetSearchIndexInfo("MyNewIndex");

    CultureInfo culture = CultureInfoProvider.GetCultureInfo("en-us");
 
    if ((index != null) && (culture != null))
    {

      // Save the binding
      SearchIndexCultureInfoProvider.AddSearchIndexCulture(index.IndexID, culture.CultureID);

 
        return true;
    }
 
    return false;
}

 

The following example removes a culture from a search index.

 

private bool RemoveCultureFromSearchIndex()
{
    // Get the search index

  SearchIndexInfo removeIndex = SearchIndexInfoProvider.GetSearchIndexInfo("MyNewIndex");

  CultureInfo culture = CultureInfoProvider.GetCultureInfo("en-us");

 
    if ((removeIndex != null) && (culture != null))
    {

      // Get the binding
      SearchIndexCultureInfo indexCulture = SearchIndexCultureInfoProvider.GetSearchIndexCultureInfo(removeIndex.IndexID, culture.CultureID);

 
        // Delete the binding
        SearchIndexCultureInfoProvider.DeleteSearchIndexCultureInfo(indexCulture);
 
        return true;
    }
 
    return false;
}