locked
Refinement panel not working with search core results webpart and fixed keyword query RRS feed

  • Question

  • I am attempting to create a user list using the people search core results web part and allow refinement of the search results with the refinement panel.

    I have a people search core results web part on my page, and under Results Query Options, I have the cross-webpart query ID set to Query 2 and I have contentclass:SPSPeople in the Fixed Keyword Query box.

    I then added a people refinement panel web part to the page and set the Cross-Web Part query ID to Query 2 as well.

    I get a complete list of all my users, but no options to refine the results in the refinement panel.

    I know that I have enough results for the refiner to work because if I do the same search in my enterprise search centre, I get a number of refinement options (and my refinement panel is set up the same as the one on the OOTB people search results page)

    As part of my troubleshooting I set both the PCRWP and refinement panel Cross-Web Part query IDs to User Query to see what would happen. The result is that I still get the same search result set, and I also get a number of options showing up in the refinement panel, but none of them work - i.e. if I click on one of the refiners, my search result set does not change at all.

    I have tried doing the same thing with a standard search core results web part and refinement panel, and a different fixed keyword query (one that returned a massive result set) and get the same outcome.

    I can add other search web parts (e.g. search paging, search statistics) to the page, and set the Cross-Web Part query ID to Query 2 and they link up with the core results web part just fine. It just seems that the refiner doesn't want to read from my search results.

    Am I missing something here?

     

    Wednesday, December 8, 2010 3:09 AM

Answers

  • John,

    I agree -> It seems to be a limitation of the Refinement Panel.  I did figure out a way to make it work though...

    Basic steps:

    1. Extend the CoreResultsWebPart (see the code below)
    2. Use the CoreResults webpart in place of the People one
    3. Change the XSL to match the default People one
    4. Change the columns list (Fetched Properties) to match the default People one
    5. Set the extended CoreResultsWebPart to use "Local People Search Results" for the webpart Location property
    6. Keep the default setting of "User Query" but set the Fixed Keyword Query property to your query.   (I'm using contentclass:SPSPeople to return all people as a test)

    Here is the code I used to extend the CoreResultsWebpart (very simple extension)
    ***NOTE****

    This will work with the first refinement -> If you want multiple refinements, you'll have to split the "r" query string at the "&" sign and add the additional refinements to the FixedQuery parameter.  (I believe you can just place a space between the refinements and it will automatically "AND" them.

      public class CustomCoreResultsWebPart : CoreResultsWebPart
      {
        protected override void OnInit(EventArgs e)
        {
          var webpartManager = WebPartManager.GetCurrentWebPartManager(Page);
    
          if (webpartManager.DisplayMode == WebPartManager.BrowseDisplayMode)
          {
            SetFixedQuery();
          }
    
          base.OnInit(e);
        }
    
        private void SetFixedQuery()
        {      
          if (HttpContext.Current.Request.QueryString["r"] == null)
          {
            return;
          }
    
          this.FixedQuery = this.FixedQuery + " " + HttpContext.Current.Request.QueryString["r"];
        }
      } 

    • Edited by Jason Rastovski Monday, February 7, 2011 3:13 PM Added note about the code
    • Proposed as answer by cbundy Monday, February 13, 2012 1:08 AM
    • Marked as answer by Margriet Bruggeman Tuesday, April 17, 2012 12:49 PM
    Monday, February 7, 2011 3:02 PM

All replies

  • Hi

    Not an answer but I'd like to get answer to this as I'm having the same issue.

    I also have just the core search results web part and the refinement panel. I have defined the query in the core search results web part and set to use query 2 (same set for the refinement panel).

    I get my predefined search results but the refinement panel doesn't see anything.

    In the default search site the refinement panel works ok and I can have my custom properties in the refinement, so I know the custom refinement category works also.

    So it must be something about the predefined query and not using the searchbox and letting user type in the search phrase.

    Thursday, December 9, 2010 6:58 AM
  • Hi guys,

    I was seeing the same problem with refinements and also the paging when using a fixed query (or Query 2-5 as it were).  Still trying to determine whether it's a corruption on the page layout with the alluserswebpart but it doesn't appear to be at this stage.  In order to get it to work for me, I placed a standard Search box on the page and set the target results page to be my current page.  I then under Query Text Box, set the additional query terms (IsDocument:1 in my case) and then set all other web parts to User Query (Query 1).  Once it was all working, I hid the Search box on the page and all seems fine.  A bit of a funny way to go about it, but it's working for now

    I had to remove all existing web-parts from my page and then re-add them again in order for the refinement panel to start working

    Cheers

    • Edited by Tonysi Monday, December 13, 2010 8:51 PM
    Monday, December 13, 2010 8:33 PM
  • I have just tried this and the refinement panel shows up but it doesn't work - when clicking on one of the options to refine by, it reloads the page and appends the refiner to the query string, but doesn't actually refine my search results...
    Monday, December 13, 2010 8:44 PM
  • Anyone ever find a resolution for this?  I ran into the same issue today and am stumped.  I've tried everything I can think of but something seems to permanently break the refinement panel on the page when you switch to a fixed query.  The only thing I can do to get it back is switch the page layout and start over -- but that doesn't solve the issue of being able to do a fixed query with the refinement panel.
    John Ross
    SharePoint Server MVP | Sr. Consultant SharePoint911: SharePoint Consulting
    Blog: http://www.sharepoint911.com/blogs/john
    Twitter: @JohnRossJr

    Professional SharePoint 2010 Branding and User Interface Design (Wrox Programmer to Programmer)
    Tuesday, January 11, 2011 4:53 PM
  • No unfortunately still stuck on this one!
    Wednesday, January 12, 2011 7:51 PM
  • I'm having the same issue. I want the search results page to show all items in a particular document library and custom list and users need the ability to filter these using the refinement panel (managed metadata). I can get the Search Core Results web part showing the documents but the Refinement Panel web part just says "No refinements available".
    Thursday, January 20, 2011 3:09 AM
  • Hi,

    I also had this issue when I started trying to customise the Search Results Web Part and use a fixed query, along with a refinement panel. I found the way round it is to put your query, which in your case is: contentclass:SPSPeople, within the Append text to query (under Fixed keyword query in webpart properties).

    I believe that if you put a Fixed Query on it, then you can not query/refine it any further (as you are fixing the query). Whereas appending your specific search to the query enables you to refine it further.

    Hope that makes sense.

    Monday, January 24, 2011 4:47 PM
  • I'm continuing to look into this issue as it is currently a big hold up for me on a project.  No one has specifically told me "it is officially a bug" but I see no reason why this specific use case wouldn't be supported.  I've gotten some feedback and will pass along more information as I get it -- hopefully in the next couple of days.
    John Ross
    SharePoint Server MVP | Sr. Consultant SharePoint911: SharePoint Consulting
    Blog: http://www.sharepoint911.com/blogs/john
    Twitter: @JohnRossJr

    Professional SharePoint 2010 Branding and User Interface Design (Wrox Programmer to Programmer)
    Monday, January 24, 2011 4:54 PM
  • John -> Definitely keep us posted on your progress.  I'm having the same issue with the refinement panel & fixed query.
    Wednesday, January 26, 2011 2:42 PM
  • John - Have you made any progress with this?
    Thursday, February 3, 2011 2:58 PM
  • John - Have you made any progress with this?
    Thursday, February 3, 2011 2:59 PM
  • Yes, I'm not sure specifically what I'm allowed to share but have asked for permission and hope to be able to write a couple blog posts.  As a work around you can do the fixed keyword query off the User Query.  Would that work for your situation?
    John Ross
    SharePoint Server MVP | Sr. Consultant SharePoint911: SharePoint Consulting
    Blog: http://www.sharepoint911.com/blogs/john
    Twitter: @JohnRossJr

    Professional SharePoint 2010 Branding and User Interface Design (Wrox Programmer to Programmer)
    Thursday, February 3, 2011 3:20 PM
  • For now, it will have to work via the User Query....it would just be a lot cleaner (in the URL) if we could use Query 2 for the connection.
    Thursday, February 3, 2011 9:23 PM
  • Wish I had a better answer.  It does limit the flexibility of the Refinement Panel.
    John Ross
    SharePoint Server MVP | Sr. Consultant SharePoint911: SharePoint Consulting
    Blog: http://www.sharepoint911.com/blogs/john
    Twitter: @JohnRossJr

    Professional SharePoint 2010 Branding and User Interface Design (Wrox Programmer to Programmer)
    Thursday, February 3, 2011 9:31 PM
  • John,

    I agree -> It seems to be a limitation of the Refinement Panel.  I did figure out a way to make it work though...

    Basic steps:

    1. Extend the CoreResultsWebPart (see the code below)
    2. Use the CoreResults webpart in place of the People one
    3. Change the XSL to match the default People one
    4. Change the columns list (Fetched Properties) to match the default People one
    5. Set the extended CoreResultsWebPart to use "Local People Search Results" for the webpart Location property
    6. Keep the default setting of "User Query" but set the Fixed Keyword Query property to your query.   (I'm using contentclass:SPSPeople to return all people as a test)

    Here is the code I used to extend the CoreResultsWebpart (very simple extension)
    ***NOTE****

    This will work with the first refinement -> If you want multiple refinements, you'll have to split the "r" query string at the "&" sign and add the additional refinements to the FixedQuery parameter.  (I believe you can just place a space between the refinements and it will automatically "AND" them.

      public class CustomCoreResultsWebPart : CoreResultsWebPart
      {
        protected override void OnInit(EventArgs e)
        {
          var webpartManager = WebPartManager.GetCurrentWebPartManager(Page);
    
          if (webpartManager.DisplayMode == WebPartManager.BrowseDisplayMode)
          {
            SetFixedQuery();
          }
    
          base.OnInit(e);
        }
    
        private void SetFixedQuery()
        {      
          if (HttpContext.Current.Request.QueryString["r"] == null)
          {
            return;
          }
    
          this.FixedQuery = this.FixedQuery + " " + HttpContext.Current.Request.QueryString["r"];
        }
      } 

    • Edited by Jason Rastovski Monday, February 7, 2011 3:13 PM Added note about the code
    • Proposed as answer by cbundy Monday, February 13, 2012 1:08 AM
    • Marked as answer by Margriet Bruggeman Tuesday, April 17, 2012 12:49 PM
    Monday, February 7, 2011 3:02 PM
  • Thanks Jason, this should help

     

    I'm not sure if you changed your code sample, but it seems to work fine with multiple refiners as it is? (I am doing a normal search not people search)

     

    Thanks again


    Monday, April 4, 2011 2:23 AM
  • Actually - you're probably correct...I'm using a fairly modified version of that code with a custom-built refinement panel, so I've had to make a lot of adjustments. 

    Jason

    Monday, April 4, 2011 1:23 PM
  • Any resolution for this? I'm trying to use the people search results page as a staff directory and want to be able to filter on Department.
    Thursday, June 9, 2011 9:55 PM
  • If you want to activate filters on the people search, you need to map:

    crawled properties -> Managed Properties

    1. Create your managed property in search called "DepartmentRefiner" (if it does not already exist)
    2. Map ows_department and People:Department crawled properties
    3. Perform a Full Crawl on People content source
    4. Modify the XML in the refinment panel to add the Department refiner
    <Category        Title="Department"        Description="Use this filter to restrict results to a specific Department"        Type="Microsoft.Office.Server.Search.WebControls.ManagedPropertyFilterGenerator"        MetadataThreshold="1"        NumberOfFiltersToDisplay="4"        MaxNumberOfFilters="50"        SortBy="Frequency"        SortDirection="Descending"    SortByForMoreFilters="Name"    SortDirectionForMoreFilters="Ascending"    ShowMoreLink="True"        MappedProperty="DepartmentRefiner"        MoreLinkText="show more"        LessLinkText="show fewer"/>

    Enjoy!

    thanks, Tony Cosentino Web Cloud Solutions

    Monday, February 13, 2012 12:32 AM
  • The solution is to create the Custom Core search results web part where you have control over the query and refinement behaviour. Tonycos's option wont work if you are using a fixed query (But will still need to be done in conjunction with the custom results web part, it just wont work on its own).
    Monday, February 13, 2012 1:08 AM