Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Smart search filtering View modes: 
User avatar
Member
Member
stephen.turley-terradon - 8/15/2012 9:32:45 AM
   
Smart search filtering
I need to filter search results between two dates specified by the user. This filter should have two date selectors. I don't think this is possible with the default search filter. Is there a guide for developing search filters, or should I take another route?

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 8/15/2012 12:10:33 PM
   
RE:Smart search filtering
I haven't tried it, but this page has an example of the syntax for searching items with a date between two dates
http://devnet.kentico.com/docs/7_0RC/devguide/index.html?smart_search_search_syntax.htm

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 8/15/2012 12:15:26 PM
   
RE:Smart search filtering
I'm not sure how you get the dates in there, but I would try using a control with two date fields that modified the querystring in the url to filter by date (I know sometimes you don't want to use querystring parameters because you don't get ajax, but just do it anyway. It also gives a copy paste url that users can share the same search results with someone else)

Then you could probably add this to the filter:
DocumentCreatedWhen:[{%startdate%}TO {%enddate%}]

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 8/15/2012 12:16:11 PM
   
RE:Smart search filtering
Just a tip for modifying the url querystring parameters easily. Use the URLHelper class.

User avatar
Member
Member
stephen.turley-terradon - 8/15/2012 12:56:42 PM
   
RE:Smart search filtering
So I'm passing the following query string:

/Search.aspx?searchtext=test&searchmode=anyword&DocumentCreatedWhen:[200902020101%20TO%20200906020101]

Also I've set the query options to the smart search dialog to "FULL"

This is not limiting my search results in any way. Am I missing an option somewhere?

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 8/15/2012 1:05:06 PM
   
RE:Smart search filtering
can you copy and paste your smart search filter settings?

User avatar
Member
Member
stephen.turley-terradon - 8/15/2012 1:08:05 PM
   
RE:Smart search filtering
Here they are but I should note that I'm just passing the query string manually at this point. This filter is used for categories only at the moment. The way I interpreted the filter system working is that the search results webpart looks at the query string and filters the results based on the parameters passed.


Webpart properties (Smart search filter)

Alias path: /Departments/DevSite/Search
Zone ID: SearchControl


Default


Web part control ID: SearchFilter

Web part title:

Disable view state: False

Disable macros: False


Visibility


Visible: True

Hide on subpages: False

Show for document types:

Display to roles:


Filter properties


Search webpart ID: SearchDialog

Filter mode: checkbox

Filter layout: vertical

Filter auto postback: False

Values:

Query name: CMS.Root.CategorySearchFilter

Query WHERE condition:

Query ORDER BY clause: CategoryDisplayName

Filter clause: +

Default selected index:

Filter is conditional: True


Partial caching (hidden)



Web part container


Web part container:

Container title:

Container CSS class:

Container custom content:

Hide container on subpages: False


HTML Envelope


Content before: <div id="searchFilter">

Content after: </div>


AJAX


Use update panel: False


Time zones


Time zone: inherit

Custom time zone:


Partial caching


User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 8/15/2012 1:09:35 PM
   
RE:Smart search filtering
Hang on, this looks all wrong
/Search.aspx?searchtext=test&searchmode=anyword&DocumentCreatedWhen:[200902020101%20TO%20200906020101]

You don't have a query parameter name and value, maybe try this

/Search.aspx?searchtext=test&searchmode=anyword&DateFilter=DocumentCreatedWhen:[200902020101%20TO%20200906020101]

and use +{%DateFilter%} in your Smart Search Filter

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 8/15/2012 1:17:13 PM
   
RE:Smart search filtering
Try putting this in your search results web part for Search Condition:

{%IfEmpty(QueryString["datefilter"],"","+DocumentCreatedWhen:" + QueryString["DateFilter"])%}

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 8/15/2012 1:18:20 PM
   
RE:Smart search filtering
I really wish Kentico would add a feature to let me edit my forum posts.

based on the way you're querystring is, do this instead

{%IfEmpty(QueryString["datefilter"],"","+" + QueryString["DateFilter"])%}

User avatar
Member
Member
stephen.turley-terradon - 8/15/2012 1:20:12 PM
   
RE:Smart search filtering
Cool, it looks like this is working. I'll build a control for it now.

User avatar
Member
Member
stephen.turley-terradon - 8/15/2012 1:24:09 PM
   
RE:Smart search filtering
Just a note: I have to take the "DocumentCreatedWhen:" out of the query string to get this to work since the search results will add it.

User avatar
Member
Member
stephen.turley-terradon - 8/15/2012 12:27:24 PM
   
RE:Smart search filtering
Thanks I'll give it a shot.