Kentico CMS 6.0 Developer's Guide

Using the Smart search filter

Using the Smart search filter

Previous topic Next topic Mail us feedback on this topic!  

Using the Smart search filter

Previous topic Next topic JavaScript is required for the print function 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 behavior 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.

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 must 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

 

Please note that in order for the filter to work correctly, the data fields used in the option definitions must be set as Searchable in the field configuration of the given object type. Information about the search field configuration of objects can be found in the Settings for particular object types topic.

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 range of objects that are searched (where condition). If false, the filter determines the order in which search results are displayed (order by condition).