The search component expects a set of fields to be posted to it, including "search_query", "search_categories", "search_authoringtemplate", etc. The component then constructs a single query to send to the search engine - basically it puts the appropriate field names into the query and passes it along.
This constructed search does not explicitly perform a filter - i.e. it does not mark any of the criteria as required - and so the search performed will be a "best fit" search where the results can match any of the criteria mentioned, but will be 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 template or templates, or that they must NOT use a specified template or templates.
You can then send the constructed query to the search component using the "search_query" field, which will be passed on modified onto the search engine.
To only include content that is using a specific template, you would append this to the end of the user's query:
+AuthoringTemplate:"Template Title"
To extend this to multiple templates, you can simply append more:
+AuthoringTemplate:"Template Title 1" +AuthoringTemplate:"Template Title 2"
Similarly to only include content that does NOT use a specific template, you would append this to the user's query:
-AuthoringTemplate:"Template Title"
And for multiple:
-AuthoringTemplate:"Template Title 1" -AuthoringTemplate:"Template Title 2"
Typically the second case is more suitable to the problem - i.e. you are trying to exclude certain content.
But there are some cases where you want to do the first type of filtering - for example you may be providing a type specific search like a "News search".
Constructing your query can easily be done using some Javascript that executes on the form submit.
Put the filtering code into a function that you can call from your form submit:
<script language="Javascript">
function addFilter(queryIn)
{
return queryIn + ' -AuthoringTemplate:"Template Title";
}
</script>
In your search form, hide the "search_query" query field and compute it during the submit using what the user typed in plus the template filter:
<form onSubmit="this.search_query.value=addFilter(this.query.value)">
Query: <input name="query"/>
<input type=hidden name="search_query"/>
</form>
Using this technique you can not only hide content, you can provide specialised searching forms for specific types of content. It can also be used to provide a type selection to the user, allowing them to pick what content type (or types) to search which you then use to construct a query appropriately.
Related Content
Integrating IBM WebSphere Portal Search with IBM Workplace Web Content Management for version 6
Info Center: Portal Search
Info Center: Searching Sites
New search features in 6.1