How to provide predefined search pages to the user? RRS feed

  • Question

  • Hi,

    I want to use FAST Search for SP 2010 together with SP 2010. Among other things I would like to provide the user a set of pages with predefined search queries inside.


    • Show search results based on "Customer B"
    • Show search results based on "Customer B" in the last x days

    Thanks for input.


    Sunday, February 19, 2012 9:09 AM


  • There's a number of ways to accomplish this depending how dynamic your search query needs to be.

    1. The easiest using an out-of-the-box Core Results Web Part and a static site page for each predefined query. I would only recommend this approach if you have a small number of pages showing predefined search query results. Basically, all you need to do is to create a new site page, drop a Search Core Results web part and set the Fixed Keyword Query web part property to your predefined query. You can also customize the UI by providing your own xslt.
    2. To make things a bit more dynamic and avoid creating a separate page for each predefined query, you can create your own web part that inherits from the CoreResultsWebPart class and override the OnLoad method to dynamically set the FixedQuery property based on a certain parameter value such as a query string argument. You can also accomplish this by overriding the GetXPathNavigator method, get a reference to the QueryManager for the page and set the UserQuery property to the desired search query. Same as with the approach above, you can customize the UI by using your own xslt.
    3. The most advanced but also most flexible approach would be to create a custom web part and use the search object model (KeywordQuery class) to execute the search query and retrieve the results. In this case you have full control over the query parameters as well as the web part UI rendering.

    In every case, you have an option to specify if the results should be coming from the SP2010 or FS4SP search index.

    • Marked as answer by Sven W Monday, February 20, 2012 12:17 AM
    Sunday, February 19, 2012 5:28 PM