how to Implementing Smart search with three condition

benyamin jain asked on June 3, 2018 09:44


I need to implement a smart search like what you see below

smart search with search text,category,tags

as you see user enter desired text and select TYPE(ex:video,eBook,images,slides) then select specialties(defined as categories in system) then press search and see the results in the result page.(note SPECIALTIES AND TYPES ARE BOTH DROP-DOWN).

In kentico(v7.0 with last hotfix) we have smart search textbox,smart search results,and also smart search filter. these web-parts somewhat meet requirements but in another way that is not our option.

How it is possible to implement smart search as shown in image?

Correct Answer

Peter Mogilnitski answered on June 3, 2018 17:56

Here my 2 cents: your drop downs and smart search box have will form a query string: ?searchtext=sometext&indextype=indexname&categoryid=123. Then with help of macros you put all that in smart search result web part and you good to go. You need 4 components here:

  1. Smart search results with macro conditions based on query string.
  2. type drop down - IMO represents search indexes. You have video search index,eBook index,images index,slides and slides (you can created drop down with pure macro see below). If none selected you use all 4 indexes.
  3. specialties drop down - has to add categoryid=123 to querystring, which will go into search condition text box of smart search results web part, i.e. +documentcategoryids:(123) to get the value from query string: +documentcategoryids:({%QueryString["categoryid"]|(identity)GlobalAdministrator%}).
  4. text box - you can use smart search box web part.

You can achieve without any backend code, may be some custom macros. Smart search filter is limited in terms of layout and design. I prefer to render drop downs with macros and transformation, especially if consider layout for mobile and tablet.

P.S. You can probably do all that with standard kentico web parts as well here is an article on categories and smart search.

0 votesVote for this answer Unmark Correct answer

Recent Answers

Brenden Kehren answered on June 3, 2018 14:32

The textbox and search button are simply the smart search box. The dropdowns are smart search filters configured with the options you want to filter by and select dropdown as your control. Then define one option per line in format:

Index field name;Value of the field;Displayed text

For example:

TypeColumnFromDocType;1;Videos TypeColumnFromDocType;2;eBooks TypeColumnFromDocType;3;Images

You can also use a query to populate these assuming you're already doing that in the doc type field. Assume you have ResourceTypes table with ResourceID and ResourceName your query would be

SELECT 'TypeColumnFromDocType', ResourceID, ResourceName FROM Resource Types ORDER BY ResourceName

This will populate the dropdown with the needed items to filter. Repeat for the Specialties.

0 votesVote for this answer Mark as a Correct answer

benyamin jain answered on June 3, 2018 15:49 (last edited on June 3, 2018 15:54)

Thanks Brenden for reply

one issue with these search is that it must be redirected to result page and there we must display final results entirely.

1 - user enter it's search phrase

2 - select Type

3 - select specialty

4 - click search

system redirect user to result page and display the retrieved results.

i think i must see this system as a whole.this means (i think) that writing code is required. but how i can use smart search API to achieve this.

NOTE : types and Specialties defined as categories for site (ex, user create video document and asign it a category) then category also must be considered in search index on the other hand each document has tag(i don't know smart search include tags in search if search phrase provide by user match with them)

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on June 4, 2018 15:55

What I provided will work on the actual search results page. I assumed this is what you're looking for because you stated you placed a search results webpart on the page.

What Peter provided will be a better solution for a global search solution.

0 votesVote for this answer Mark as a Correct answer

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