Hey there, im trying to use the smart search APIs to do a search however it never really returns anything through the API, however when i do the smart search preview in the Site Manager, it returns items..
Anyone got any ideas on what im doing wrong?
// Get the search index
string culture = Functions.GetPreferredCulture();
CMSSiteProvider.SearchIndexInfo sii = CMSSiteProvider.SearchIndexInfoProvider.GetSearchIndexInfo(String.Format("hub.searchitems_{0}", culture));
int numberOfResults = 0;
List<dynamic> list = new List<dynamic>();
if (!string.IsNullOrEmpty(searchTerm))
{
// Get current search mode from query string
string searchMode = QueryHelper.GetString("searchmode", "");
CMS.ISearchEngine.SearchModeEnum searchModeEnum = CMS.ISearchEngine.SearchHelper.GetSearchModeEnum(searchMode);
// Get current index info object
// Check whether index info exists
if (sii != null)
{
// Keep search text in search textbox
//txtSearchFor.Text = searchText;
searchTerm = CMSSiteProvider.SearchHelper.CombineSearchCondition(searchTerm, null, searchModeEnum, CMSSiteProvider.SearchOptionsEnum.FullSearch, null, null, null, false);
// Get positions and ranges for search method
int startPosition = 0;
int numberOfProceeded = 110;
int displayResults = 10;
// Search
//DataSet results = CMSSiteProvider.SearchHelper.Search(searchTerm, null, null, null,CMSContext.CurrentUser.PreferredCultureCode, null, false, false, false, sii.IndexName, displayResults, startPosition, numberOfProceeded, (CMSSiteProvider.UserInfo)CMSContext.CurrentUser, out numberOfResults, null, null);
DataSet results = CMSSiteProvider.SearchHelper.Search(searchTerm, null, null, null, "##ALL##", null, false, false, false, sii.IndexName, displayResults, startPosition, numberOfProceeded, null, out numberOfResults, null, null);
// If found at least one item
if (numberOfResults > 0)
{
foreach (DataRow item in results.Tables[0].Rows)
{
dynamic p = new
{
url = CMS.Controls.TransformationHelper.HelperObject.SearchResultUrl(ValidationHelper.GetString(item["id"], string.Empty), ValidationHelper.GetString(item["type"], string.Empty), true),
imageUrl = GeneralHelper.GetAttachmentURL(ValidationHelper.GetGuid(item["Image"], new Guid()), CMSContext.CurrentSiteID),
name = ValidationHelper.GetString(item["Title"], string.Empty)
};
list.Add(p);
}
}
}
}