in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Marks MOSSels

Advanced Search Box & Search Core Results web part on one page: Watch Out!

Hi everyone,

My first blog post on sharepointblogs.com is about an issue I came by this week.

Typically, if you create a new SharePoint Site based on the Search Center template (under Enterprise), you get a teamsite with a few prefab pages: default.aspx, advanced.aspx and results.aspx. By default, the advanced page houses the Advanced Search Box web part, which is configured to show its results on the results page. The results page houses, among some other web parts, the Search Core Results web part which is responsible for rendering the search results.

A customer asked us if it was possible to put these two web parts on the same page, so the search results would render below the advanced search form. If a user then wants to refine his search query he wouldn't have to go back to the previous page. "That's easy", you might think, and at first it did seem quite trivial:

Just put the Core Search Results web part to the advanced page, together with one or two Search Paging web parts. Then configure the Advanced Search Box web part to show results on the advanced page instead of the results page (Results URL property) and you're done.

Though the above described steps might make you think you've done it, and it might even show the correct search results in your first test run, be aware that if you're starting to use the Result Type selection, all of a sudden it's not "all good". Somehow, putting the Advanced Search Box web part on a page together with the Core Search Results web part makes it hard for SharePoint to remember what the user selected as Result Type. Check out this example:

  1. A user types "Microsoft" in free search text box "All of these words:"
  2. The user selects "Word Documents" as a "Result type", because he/she only wants to see Word documents with the term "Microsoft" in it
  3. The user clicks the Search button
  4. The system at first shows correct results (of course items should be available in the system for results to come up)
  5. But by clicking the Search button again, or by navigating to the next Page in case of a big search result set, the Result Type selection all of a sudden is ignored. Now all items that contain the term "Microsoft" in it.

Is it a bug? Is it a feature? What causes this wicked behavior?

To be honest, I don't really know, but I think it has something to do with the javascript blocks and hidden form fields that are rendered by the web parts. I haven't done any thorough research so I'm not sure. This post is just a warning in case you think of customizing your search center in the same way I did. If anyone out there has something to add to this, maybe even has a solution, please let me know!

Comments

 

Tom Clarkson said:

The controls at the bottom of the advanced search box are quite complicated - It's been a while since I have looked at that, but I think they are getting created in javascript based on the selected document type. A side effect of this is that the standard asp.net saved state won't work on these controls.

There's some more detail on the controls involved on my blog - www.tqcblog.com/.../creating-a-custom-advanced-search-box-in-moss-2007.aspx

If you implement something similar in a custom web part using asp.net controls rather than html controls, the form should remain filled out after you go to the results page.

March 6, 2008 4:33 PM
 

Lori said:

Has anyone found a way to have multiple core results web parts, each pointing to a different scope?  We would like users to perform an All Sites scoped search from the home page and then present people results in one web part and all other results in a separate web part all on the same results page.  

March 7, 2008 9:10 AM
 

Clyde said:

What she said.  

Lori, that's a question that I have as well. Have you found an answer?

May 27, 2008 12:44 PM
 

Tom Clarkson said:

I don't think that's possible, because the core results web part gets its parameters from the search result hidden object, which will read one set of parameters from the submitted form.

However, you may be able to get a similar result using custom XSL to display the results.

June 3, 2008 2:44 AM
 

laen said:

sir gud evening..

i just want to know if the webpart "Refine Search"

is a default web part in Sharepoint or you really have to customize to have that certain kind of webpart??

thanks,

laen

July 30, 2008 5:44 AM
 

Patrick said:

Lori, Microsoft recommends a company called KnowledgeLake for SharePoint.  They have a Search webpart that allows you to easily create and save metadata searches.  In those saved searches, you can enable different scopes.

August 21, 2008 1:03 PM
 

prasad said:

I have created one team site and a list in it.I have created the scopes for the list and  used a seach box webpart to fetch the results using the scope but it is not fetching any results.

Is it not possible to use the search box webpart without using Search Center temple ? how to achive the above functionality?

August 27, 2008 6:15 AM

Leave a Comment

(required )  
(optional )
(required )  
Add

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts