Filtering search results
Often you want certain types of content to not be shown in your search results. You can do this by filtering your search results to ensure that certain types of content is not displayed.
A search component uses a set of fields, such as "search_query", "search_categories" and "search_authoringtemplate", to construct a single query to send to the search engine. This constructed search does not explicitly perform a filter. It does not mark any of the criteria as required and therefore the search performed is a "best fit" search where the results can match any of the criteria mentioned, but is ordered so that the best fitting results are displayed first.
If you want to force the results to be filtered, you have to construct the query yourself. This allows you to force either that the results must use a specified parameter, or that they must not use a specified parameter. You can then send the constructed query to the search component using the "search_query" field, which is passed on to the search engine.
Filtering by authoring template
+authoringtemplate::"Template Title"
+authoringtemplate::"Template Title 1" +authoringtemplate::"Template Title 2"
-authoringtemplate::"Template Title"
-authoringtemplate::"Template Title 1" -authoringtemplate::"Template Title 2"
<script language="Javascript"> function addFilter(queryIn) { return queryIn + ' -authoringtemplate::"Template Title"; } </script>
<form onSubmit="this.search_query.value=addFilter(this.query.value)"> Query: <input name="query"/> <input type=hidden name="search_query"/> </form>
Filtering by content path
+contentpath::"/LibraryName/FolderName/SiteArea1Name/SiteArea1.1Name"
-contentpath::"/LibraryName/FolderName/SiteArea1Name/SiteArea1.1Name"
<script language="Javascript"> function addFilter(queryIn) { return queryIn + ' -contentpath::"/LibraryName/FolderName/SiteArea1Name/SiteArea1.1Name"; } </script>
<form onSubmit="this.search_query.value=addFilter(this.query.value)"> Query: <input name="query"/> <input type=hidden name="search_query"/> </form>