Add search condition on Kentico smart search API

Below is an example of using the Smart Search API module in Kentico.
The API Example inside Kentico not telling this, but I was able to figure out the way. 

Kindly have a try on the snippet example 

Smart Search Module API - Search With Condition 

   public void SmartSearchWithCondition(string searchText,string ClassName,string extraCondition)  
DocumentSearchCondition docCondition = new DocumentSearchCondition();
docCondition.ClassNames = ClassName;
docCondition.Culture = "en-US";
//refer for the extra condition syntax
var condition = new SearchCondition(extraCondition, SearchModeEnum.AllWords, SearchOptionsEnum.FullSearch, docCondition, true);
searchText = SearchSyntaxHelper.CombineSearchCondition(searchText, condition);
// Get the search index
SearchIndexInfo index = SearchIndexInfoProvider.GetSearchIndexInfo("SearchIndex");
if (index != null)
// Prepare parameters
SearchParameters parameters = new SearchParameters()
SearchFor = searchText,
SearchSort = "##SCORE##",
CurrentCulture = "EN-US",
DefaultCulture = CultureHelper.EnglishCulture.IetfLanguageTag,
CombineWithDefaultCulture = false,
CheckPermissions = false,
SearchInAttachments = false,
User = (UserInfo)MembershipContext.AuthenticatedUser,
SearchIndexes = index.IndexName,
StartingPosition = 0,
AttachmentWhere = String.Empty,
AttachmentOrderBy = String.Empty,
// Search
DataSet results = SearchHelper.Search(parameters);
// If found at least one item
if (parameters.NumberOfResults > 0)
//do your works here

Have a try!

Popular posts from this blog

Example to disable save as certain file type in SSRS Report Viewer

Phone book application example - Java

Modal Popup Message Box ASP.NEt C# Example