Hi guys,
What is the easiest way to set up one copy of the search module on a page hosting a Wiki, showing only the Wiki results, and another copy of the module on a page hosting a Forum, showing only the Forum results, please? Is it just the results filter?
Also, is there an easy way to allow the user to switch between the Light and Advanced filter settings?
Best regards
Dave.
Hello David,
As promised yesterday, here is how you can use LuceneSearch to filter the search results according to your wishes. The first and cleanest option is to use the query filtering parameter which is available in the commercial version of LuceneSearch.
On every instance of the LuceneSearch module, you can define a additional Lucene filter that lets you customize the scope of your query. For example, to limit the search results you will display to documents from the wiki module, you can edit the filter like in the following screenshot.
This setting allows you to filter the results you display depending on the page you're on; you can then show the wiki results on the wiki page, the announcements results on the announcements page, etc.
The second option is to display only the entries you're interested in by editing the display template and adding a conditional setting around the result template. Since this happens after the query has been executed, it won't work correctly with the paging options you've chosen, but on the other hand it can allow you to see what the results will look like if filtered. If you don't use paging, this option can work correctly.
This solution is based on an advanced version of the token replacement system of DotNetNuke; the syntax is important, please note the closing tag, as well as the trailing semicolumn in the tag. This is only a simple example of what the token replacement can do, you could decide to use it for much more advanced filters (for example filtering for the current user, or the day on which the query is made, etc)
You must also keep in mind though that in this case, the search query isn't filtered so it won't be as efficient as the first option since it will get more results back from the index in order to display only a subset of these results.
Regarding your second question, LuceneSearch comes with some filters interface predefined, but you can easily create your own. To do this, you can select the Custom Filter entry for the filter control and then point to your ascx control in the website.
There are many options which you may be interested in when writing a custom control. A good way to see what's available to you is to look at sample filters in order to get an idea of how they are created. Here is a small list of filter controls that are included with LuceneSearch (in the Controls directory under the installation for the module) to get you started:
Once you've studied the samples, you can start defining your own custom filter with the behavior you desire.