Unable to search results using tags on local index kentico 13 smart search.

Siddharth Verma asked on November 3, 2022 15:19

Hello Everyone, I'm trying to get search result using tags, in kentico 13 .NET Core. Please suggest me what I'm missing in below code logic, or is there any alternative way to achieve this functionality

 string searchText = HttpContext.Request.Query["searchtext"].ToString();
                string extraConditions = "|| documenttags:(" + searchText + ")";
                var condition = new SearchCondition(extraConditions, SearchModeEnum.AnyWord, SearchOptionsEnum.FullSearch);
                string searchCondition = SearchSyntaxHelper.CombineSearchCondition(searchText, condition);
                SearchParameters parameters = new SearchParameters
                    SearchFor = searchCondition,
                    SearchIndexes = properties.SmartSearch,
                    StartingPosition = 0,
                    DisplayResults = 100,
                    NumberOfProcessedResults = 100,
                    NumberOfResults = 0,

                return await Task.FromResult((IViewComponentResult)View("~/Components/Widgets/SmartSearch/_SmartSearch.cshtml", new SmartSearchViewModel()
                    SearchResultItems = _smartSearchRepository.GetSearchResults(parameters),
                    PageSize = string.IsNullOrEmpty(properties.PageSize) ? "9" : properties.PageSize


Any help or suggestion appreciated in advance.

Recent Answers

Juraj Ondrus answered on November 3, 2022 15:31

The issue is probably that the smart search syntax is different from the C# syntax. Especially the boolean operators.

So, I think you should replace || with OR.

1 votesVote for this answer Mark as a Correct answer

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