Selecting a Particular Smart Search Index

Deann Graham asked on April 5, 2018 21:56

We have Three indexes one that indexes Assets, one that indexes pages, one that indexes events. I want to allow the user to use a checkbox list to show either Just one of the indexes or Two of the indexes or All three by default. It looks as though the Indexes are handled by the CMS Control and not the webpart. I just want to pass a value to the section as to what indexes to use. Anyone tackle this before? Any suggestions? I feel I will need to create a separate control and webpart.

Recent Answers


Peter Mogilnitski answered on April 6, 2018 06:01 (last edited on December 10, 2019 02:31)

Essentially what you need is to make your page reload with query string parameter telling what index(s) to use in smart search results. You basically need 2 things:

  1. Smart Search Results Web part where you tell to get what indexes to search from query string, i.e.{%QueryString["searchIndexName"]|(identity)GlobalAdministrator%}

  2. Would be any web part that can list check boxes with name searchIndexName and do post back on click, for example: you can clone and modify smart search dialog web part and replace "search mode" drop down with list of check boxes. At the end you just need reload your page with a new URL something like this:www.yoursite.com/yoururl?searchIndexName=index1Name,index2Name

I might miss some technicalities but this is just a general approach you can use :)

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 9, 2018 02:26

If you have 3 separate indexes setup, I'd make them all one but unique in the fashion that they ONLY get those 3 page types. For instance, create a new index and the Indexed Content should be:

  • Page type: custom.assets, Path: /assets/%, Allowed
  • Page type: cms.menuitem, Path: /%, Allowed
  • Page type: cms.events, Path: /events/%, Allowed

This will ONLY index assets, events and pages in those 3 paths.

Now when you go to setup your page:

Search results

  • add a smart search results webpart to the page
  • Set the indexes to the single index you just created
  • leave the Path empty
  • set the Search options to "Full"
  • set your transformation

Search filter

  • add a smart search filter to the page
  • set the Search dialog webpart to the Search results webpart ID you just added (typically something like SmartSearchResults)
  • Filter mode: Checkbox
  • Filter auto postback: checked (true)
  • Values = (on individual lines, second value is the classname you want to filter by)
    classname;custom.assets;Assets
    classname;cms.event;Events
    classname;cms.menuitem;Pages
  • Filter clause: Must
  • Filter is conditional: checked (true)

Save it and test your filter. Should bring back all the results initially or when you search for a term, then select a checkbox and it will display the proper "classname" of a page you're looking for.

0 votesVote for this answer Mark as a Correct answer

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