Deb, i would just look at making a Custom Search Index, there you can use Kentico's API to pull in all the categories and add them to an index.
https://docs.kentico.com/k10/custom-development/miscellaneous-custom-development-tasks/smart-search-api-and-customization/creating-custom-smart-search-indexes
Here is the code that would index all hte categories, you can modify and adjust as you wish!
using System;
using CMS.Search;
using CMS.DataEngine;
using CMS.IO;
using CMS.Helpers;
using CMS.EventLog;
using CMS.Base;
using CMS;
using CMS.Taxonomy;
[assembly: RegisterCustomClass("CategoryIndex", typeof(CategoryIndex))]
public class CategoryIndex : ICustomSearchIndex
{
/// <summary>
/// Fills the index with content.
/// </summary>
/// <param name="srchInfo">Info object representing the search index</param>
public void Rebuild(SearchIndexInfo srchInfo)
{
// Checks whether the index info object is defined
if (srchInfo != null)
{
// Gets an index writer object for the current index
IIndexWriter iw = srchInfo.Provider.GetWriter(true);
// Checks the whether writer is defined
if (iw != null)
{
try
{
// Gets an info object of the index settings
SearchIndexSettingsInfo sisi = srchInfo.IndexSettings.Items[SearchHelper.CUSTOM_INDEX_DATA];
foreach (CategoryInfo catInfo in CategoryInfoProvider.GetCategories().Where("1=1"))
{
// Creates a new Lucene.Net search document for the current text file
SearchDocumentParameters documentParameters = new SearchDocumentParameters()
{
Index = srchInfo,
Type = SearchHelper.CUSTOM_SEARCH_INDEX,
Id = catInfo.CategoryGUID.ToString(),
Created = catInfo.CategoryLastModified
};
ISearchDocument doc = SearchHelper.CreateDocument(documentParameters);
// Adds a content field. This field is processed when the search looks for matching results.
doc.AddGeneralField(SearchFieldsConstants.CONTENT, catInfo.CategoryDescription, SearchHelper.StoreContentField, true);
// Adds a title field. The value of this field is used for the search result title.
doc.AddGeneralField(SearchFieldsConstants.CUSTOM_TITLE, catInfo.CategoryDisplayName, true, false);
// Adds a content field. The value of this field is used for the search result excerpt.
doc.AddGeneralField(SearchFieldsConstants.CUSTOM_CONTENT, TextHelper.LimitLength(catInfo.CategoryDescription, 200), true, false);
// Adds a date field. The value of this field is used for the date in the search results.
doc.AddGeneralField(SearchFieldsConstants.CUSTOM_DATE, catInfo.CategoryLastModified, true, false);
// Adds a url field. The value of this field is used for link urls in the search results.
doc.AddGeneralField(SearchFieldsConstants.CUSTOM_URL, "TheLink", true, false);
// Adds an image field. The value of this field is used for the images in the search results.
// Commented out, since the image file does not exist by default
// doc.AddGeneralField(SearchFieldsConstants.CUSTOM_IMAGEURL, "textfile.jpg", true, false);
// Adds the document to the index
iw.AddDocument(doc);
}
// Flushes the index buffer
iw.Flush();
// Optimizes the index
iw.Optimize();
}
// Logs any potential exceptions
catch (Exception ex)
{
EventLogProvider.LogException("CustomCategoryIndex", "Rebuild", ex);
}
// Always close the index writer
finally
{
iw.Close();
}
}
}
}
}
Just tested this out myself and works, i was able to search for my categories and pull them up.