Using the Smart search filter

  Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic! Mail us feedback on this topic!  

The Smart search filter web part can be used to allow users to limit the range of objects that will be searched (conditional filter), or define how the search results will be sorted. It is designed to be connected to the Smart search dialog or Search dialog with results. You can connect more than one filter to these web parts.

 

You can see an example of how this works on the sample Corporate Site, on the Examples -> Web parts -> Full-text search -> Smart search filter page. You can see three Smart search filters connected to a Smart search dialog, which is connected to Smart search results.

 

The behaviour of the smart search filter is mainly defined by the properties explained in the table below. You can find descriptions of all the web part's properties in the Kentico CMS Web Parts reference or after clicking the Documentation link at the top right corner of the web part properties window.

 

Property Name

Description

Search webpart ID

ID of the Smart search dialog or Smart search dialog with results web part to which the filter should be connected.

Values

Using this property, you can specify the possible filtering options that can be selected.

You enter one option per line in format: <index field name>;<value of the field>;<displayed text>

 

When creating a conditional filter, the logical value of each filtering option can be specified. If the + symbol is added before the option, then only objects whose value in the given field matches the specified value will be included in the search. If the - symbol is added, only results that do not match the value will be returned.

 

Please note, when entering integer or double type fields as filter options, the type of the value needs to be specified in the following way: +DocumentCreatedByUserID;(int)53;Administrator

 

Examples:

;;All
+classname;cms.cellphone;Cell phones
+_created;[{%CurrentTime|(add)-10080|(tosearchdatetime)%} TO {%CurrentTime|(tosearchdatetime)%}];Past week
##SCORE##;;Score
documentcreatedwhen;;Creation date

 

Query name

Name of the query which can be used instead of the Values property to dynamically create the filter options. The query must return three columns, which will be used in the following order: <index field name>,<value of the field>,<displayed text>

 

Sample query to load all document types as the filter options:

 

SELECT TOP 1000 '+classname', ClassName, ClassDisplayName

FROM CMS_Class

WHERE ClassIsDocumentType = 1

 

Filter clause

Sets a clause that overrides the logical values specified for filtering options. Possible choices are:

 

None - no clause is added and the original logical values set for individual filtering options are used.
Must - indicates that the conditions in all filtering options must be fulfilled (adds the + symbol).
Must not - indicates that the conditions in all filtering options must not be fulfilled (adds the - symbol). Conditions are inverted compared to the Must option.

Filter is conditional

If true, the filter limits the searched documents (where condition). If false, the filter determines the sorting of search results (order by condition).

 

Page url: http://devnet.kentico.com/docs/5_5r2/devguide/index.html?smart_search_filter.htm