Setting up filtered Smart Search results on .aspx template

Tim G. asked on May 29, 2018 18:20

I'd like to set up a smart search results page which can restrict results via a custom field on some pages of my site based on logic I already have in place in my master page. I currently have the following code in my .aspx template:

<uc1:SearchResults runat="server" ID="TheSearchResults" Indexes="MySite-Pages" /> <uc1:SearchFilter runat="server" ID="SearchFilter" FilterClause="+SectionID;(int)1;Only for this section" SearchWebpartID="TheSearchResults" />

I've set up smart search and inlcuded the relevant custom fields in the search indexing but the filter doesn't seem to be applying to my results (I get the same results with or without the filter). Am I missing something obvious or misunderstanding how this functionality works?

Correct Answer

Tim G. answered on May 30, 2018 12:06

I sussed this out in the end and it's actually very simple - you simply need to set the SearchCondition property of the SearchResults user control:

<uc1:SearchResults runat="server" ID="ucSearchResults" Indexes="MySite-Pages" SearchCondition="+MyCustomFieldColumnID:(int)1" />

In addition, make sure that those values are indexed in the search.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Rui Wang answered on May 29, 2018 20:03

Here is a sample of some properties you need to set in the portal web part version of the search filter. You may want to add some of these. Also, try move your filter clause to filter value.

<webpart controlid="GrinderTypeFilter" guid="9b855d67-2143-4bc1-a259-67b58585c13b" type="SearchFilter" v="1">
  <property name="filterautopostback">True</property>
  <property name="filterclause">+</property>
  <property name="filterisconditional">True</property>
  <property name="filterlayout">vertical</property>
  <property name="filtermode">checkbox</property>
  <property name="filtervalues">classname;DancingGoat.ElectricGrinder;Electric grinderclassname;DancingGoat.ManualGrinder;Manual grinder</property>
</webpart>
0 votesVote for this answer Mark as a Correct answer

Tim G. answered on May 30, 2018 10:34

Thanks - but can anyone else offer an example for this in an aspx template where the filter value is set in the code behind?

0 votesVote for this answer Mark as a Correct answer

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