Thursday, 1 December 2011

SharePoint 2010 - Modifying the Core Search Results Web Part to Display Results Sorted by Site Name or Document Title (With Paging Limitations...)

I recently had a requirement from my client to have the following functionality in SharePoint 2010:
a) The Search Core Results web part displaying sorted in Alpha order
b) The Search Core results part should just show sites (not documents) that the current user has access to.

Requirement b) was simple - you can set the keywords on the Core Search Web Part to just display sites (using the "contentclass:STS_Site" keyword in the "Fixed Keyword Query" property - and the part would default to showing a list of sites the current user has access to (via the normal SharePoint 2010 security trimming functionality).


However, the first requirement was a little bit trickier. The default Core Search Web part only provides for 2 search sort options - by date and by relevance (which is the default).


To fix this, the XSLT which defines the search results needs to be changed. This XSLT is specific to the instance of the web part - modifying it won't affect the normal search functionality of your site.

To modify the XSLT for the search results web part, you need to first uncheck the "Use Location Visualization" checkbox. The XSLT that opens is around 700 lines long and has a lot of different XSL templates defined within it. To sort the search results by alpha order, you need to use an xsl-sort call within the main apply-templates call.

Some sites such as http://kwizcom.blogspot.com/2008/11/how-to-change-moss-search-retults-sort.html have a simple suggestion - but this would not work as the "select node is missing" on the "apply-templates directive. You need to provide a valid parent to allow for sorting. The fix was to change the empty apply-templates node in the default search XSL:
<xsl:apply-templates />

to the following:
<xsl:apply-templates select="All_Results/Result">
    <!-- The xsl-sort needs operate upon a single field - it doesn't work if the sort has to evaluate child nodes--> 
    <xsl:sort select="title" />
   </xsl:apply-templates>

Note that I didn't require the other elements in the Search XML (the TotalResults and the NumberOfResults nodes), so this solution may not work in your scenario. This list can then act as a facility for cross-site collection navigation (which is not available out of the box in SharePoint 2010)


Another limitation of this approach is that it will only work on a non-paged resultset - which is a pretty major limitation! In our scenario (for Phase 1 of our provisioning solution), it was acceptable for our customer to increase the page size to avoid any pagination from occurring. Your mileage may vary.

Other solution options are:
  1. Scripting - Using jQuery to do a search call and sorting and paging the results yourself
  2. Server side - with your own custom web part that also does the paging for you - using the SPGridView or inheriting from
    Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart
    
Phase 2 of our project will use a combination of Server Side customization (as described at http://msdn.microsoft.com/en-us/gg620579) by extending the CoreResultsWebPart
 and the jQuery approach above for easy inline searching of accessible site collections.
DDK

32 comments:

Jim's Blog said...

Thanks so much! I had the same general requirement (for an "in-page" alpha sort of sites that the user has access to), and this saved me a ton of hours, since I don't have much knowledge of XSLT. Much appreciated!!

Kimberly said...

How would I Display the search core results, grouped by site collection/site? I did find that if I placed the advanced search parameters in the fixed keyword search it would display the proper results. I added the contentclass:STS_Site to the append keyword field and it did make the sites display.

Unknown said...

http://camaragenbandarq.blogspot.com/2017/05/membahas-macam-macam-judi-di-indonesia.html
http://agenbandarqcamarqq.blogspot.com/2017/05/mengetahui-4-tempat-judi-termewah-di.html
http://agendomino99camarqq.blogspot.com/2017/06/trik-curang-main-bandarq.html
http://agendominocamar.blogspot.com/2017/06/mengetahui-warnet-di-jepang-yang.html
http://agendominocamarqq.blogspot.com/2017/06/cara-mendaftar-di-shioqq-situs-agen.html
http://www.jakartatercinta.com/2017/05/mengenal-situs-shioqq-agen-bandarq.html
http://www.jakartatercinta.com/2017/05/shioqqnet-agen-bandarq-yang-memberi.html

Yes done - Best Professional On Demand Home Service Provider in Jaipur said...

Thanks for sharing this information.
Yes Done is the best online site for on demand home services, professional service providers in Jaipur, Rajasthan. We are providing top services like carpenter, cleaning, TV, and many more services at your doorstep in Jaipur, Rajasthan. For more services visit our website.

Pheeta said...

Thanks for sharing this information.
Pheeta is the best online shopping sites for Salwar suits for women and woman Kurti online in Jaipur, Rajasthan. To shop more latest fancy and attractive dresses and Kurtas visit us at our website.

Apparrant Technologies - Best Web and Custom Mobile Application Development Agency in Noida said...

Thanks for sharing this information.
Apparrant is the best Mobile App Development Company in Noida and Web Application Development Company in Noida, Delhi NCR, Gurgaon, Faridabad, India, Toronto, and Canada. We are a leading Software Quality Assurance and App Testing company in Noida, India. We also provide IoT App Development Services in Noida as well as the best Project Management Services in Noida, Delhi NCR.

Lautrop and Uhre Aps Fine Jewellery said...

Tak for deling af disse oplysninger. Lautrop & Uhre er et bedste websted til shopping guldsmykker og forgyldte sølv smykker som guldringe, guldarmbånd, guld halskæder, guld øreringe, forgyldte sølv halskæder, forgyldte sølv armbånd, forgyldte sølv ringe og forgyldte sølv øreringe.

Apptians - Digital Marketing Agency in Delhi NCR, Noida, Gurgaon, Faridabad, India. Top SEO Company in New Delhi, India said...

Thanks for sharing this information.
Apptians is the best digital marketing agency and SEO company in Delhi NCR, Noida, Faridabad, Gurgaon, India. Top digital marketing company in India, website development, website designing and social media marketing agency in Delhi NCR, Noida, Gurgaon, Faridabad, India.

GIEC Global - Best Migration Agent Melbourne & Education Consultant in Melbourne, Australia said...

Nice Blog information.
GIEC Global is the best canada migration agent in Melbourne, Australia and education consultant in Melbourne, Sydney, Brisbane, Perth, Adelaide,Australia. If you want to migrate to Australia, or visit to Australia or work in Australia then GIEC Global is the right place for you to consult.

Hindustan Tradecom Pvt. Ltd. said...

This is really amazing blog and like to share Hindustan Tradecom.

Hindustan Tradecom is the best website where you can open your Demat Account in Jaipur, jodhpur, Bikaner, Kota, Rajasthan. We provide best services opening a Free Demat Account. We also help you opening Demat Account in Different Banks. For other services like Equity Trading, Commodity trading, Currency Derivatives, Easy-IPOs, Mutual Funds, and many more. Please visit our website.

Jewellery By Mitali Jain - Minimal & Contemporary Jewellery said...

Good Information Blog

Jewellery By Mitali Jain is the best website to buy artificial jewellery shop in Jaipur. They sell fancy and attractive statement jewellery designers products like Earrings, Rings, Necklaces, Headgears, Bracelets, Mask and Glass Chains, Bookmark Jewellery, Gift Cards and many more items like this. And also checkout our new collections Summer Luna Collection, Holy Mess Collection and Vintage Trésor Collection.

SilverMountain - Best Gold and Silver Jewellery Designers in Jaipur said...

Thanks for sharing this information

Shop jewellery from Best Silver Jewellery Designer and Manufacturer in Jaipur , Buy jaipuri bangles online, rajasthani silver jewellery, Latest maang tikka designs, 925 silver earring, Best designer silver pendant necklace, silver kundan jewellery, marhaba jewellery925 silver jewellery wholesale jewellery manufacturers in jaipur is SilverMountain Jaipur.

Yes done - Best Professional On Demand Home Service Provider in Jaipur said...

Thanks for sharing this information.
Yes Done is the best online site for on demand home services, professional service providers in Jaipur, Rajasthan. We are providing top services like carpenter, cleaning, TV, best pest control services in Jaipur, ro repair service in Jaipur, ac repair service in Jaipur online by Yes Done is there for services at your doorstep in Jaipur, Rajasthan. For more service visit our website. For more services visit our website.

Apparrant Technologies - Web and Mobile Application Development Company said...

Thank you for sharing this valuable information.

Apparrant is the leading UX UI Design agency having experienced designers and developers working throughout the year on important and life changing products. We have been awarded as top UI UX Design agency in India by multiple agencies. If you are looking for best UX Design Agency in Noida, UI UX Design Agency in Faridabad, and UX UI Design Company in Delhi then Apparrant is best for you.

Apparrant Technologies - Web and Mobile Application Development Company said...

Nice Information. I really liked it and admire you for posting it on the internet for the benefit of a larger Audience.

If you are looking for best App design and development company in Noida, Delhi NCR, Gurgaon, Faridabad and India then Apparrant is Awesome. We have been known as leading Mobile and web application development company in Noida, India. Work of Apparrant can be checked on our website along with the processes we follow in to the web or App design and technologies we use at Apparrant.

GIEC Global - Best Migration Agent Melbourne & Education Consultant in Melbourne, Australia said...

It's a great blog, shares a piece of good information.

GIEC Global is the leading education and migration consultants in Australia. We are top Education consultants in Melbourne, Sydney, Perth, Brisbane, Adelaide and Australia. We are best education consultants for Canada in Australia. We also helps people in studying in USA and have been awarded as education consultants for USA in Melbourne and education consultant for UK in Australia.

GIEC Global - Best Migration Agent Melbourne & Education Consultant in Melbourne, Australia said...

The awesome blog shares good information with everyone. I will bookmark it in the future.

France Education Consultants in Australia is GIEC Global. We are top Education consultants for Norway in Melbourne, Sydney, Perth, Brisbane, Adelaide and Australia. We are best education consultants for Netherlands in Australia. We also helps people in studying in Ireland and have been awarded as education consultants for Ireland in Melbourne and education consultant for Finland in Australia.

GIEC Global - Best Migration Agent Melbourne & Education Consultant in Melbourne, Australia said...

Nice Blog, worth reading it. I have also bookmarked it for the future.

If you are looking to Work in Australia , Work in Canada, Work in USA, Work in UK, or Work in Ireland then GIEC Global will be the best consultant for you in Australia.

GIEC Global - Best Migration Agent Melbourne & Education Consultant in Melbourne, Australia said...

It's a really good blog and I am in love while reading it.

If you are looking to migrate to Australia , Migrate to Canada, Migrate to USA, Migrate to UK, Migrate to France, or Migrate to Ireland then GIEC Global will be the best consultant for you in Australia.

GIEC Global - Best Migration Agent Melbourne & Education Consultant in Melbourne, Australia said...

Good One. Worth reading it once.

If you are looking to Visit to Australia , Visit to Canada, Visit to USA, or Visit to UK then GIEC Global will be the best consultant for you in Australia.

Ratnavali Arts : Best Jewellery Wholesaler in Jaipur, Jewellery shop in Jaipur said...

Wow its a great blog.
Best Jewellery Wholesaler in Jaipur is Ratnavali. It is a best place to buy silver jewellery Jaipur, Jaipuri gold jewellery, gemstone figures in Jaipur, Rajasthan. We have skilled craftsmanship who made best designer collection of jewellery for you.

Seva Home - Buy Candles Online and Fragrance Candles Online in India said...

Thanks for sharing this information. Your blog is good and I have bookmarked it as well.


SevaHome is the online site to buy scented candles and to buy premium candles in India. We have christmas collection, metal collection , Glass collection and marble collection. You can Seva Gift Sets from our website as well.

Next Digital Health said...

Thanks for sharing this information. Next Digital Health is the Best Healthcare Blog in the USA . Read about some of our blogs like Health sector releases threat brief from Log4J security vulnerabilities and Mobile Health lacks interventions for Mental Illness . IBM cracks a deal with Francisco Partners to share healthcare data and ONC will now exchange framework facilitating better interoperability on our website.

Apptians - Digital Marketing Agency in Delhi NCR, Noida, Gurgaon, Faridabad, India. Top SEO Company in New Delhi, India said...

Thanks for sharing this information.
Apptians is the best SEO company for ecommerce and SEO Agency for Pharmaceutical Industry in Delhi NCR, Noida, Faridabad, Gurgaon, India. Top Best Medical SEO Agency , Best SEO For Private School Website ,and Best SEO Agency for Real State .

Apparrant Technologies said...

Apparrant Technologies - Best UX UI Design Company in India.Great, it's really good blog

If you are looking for best UX Design Company in Gurgaon Haryana, India then Apparrant is Awesome. We have been known as leading UX Design Company in Pune , UX Design Studio in Hyderabad , UX Design Company in Mumbai , and UX Design Company in Bangalore .

Custom Healthcare Software Development Company in USA said...

Congratulations, your writing is really good.

Read about Wi4 which is Best Health Tech Companies and health IT company in USA . We are also best healthcare mobile app development company and medical app development agency having experience with CPOE systems in healthcare also.

Custom Healthcare Software Development Company in USA said...

Nice one, Good writing. Congratulations!

Read about Wi4 which is Provider of EMR Systems and Provider of EHR Systems . We are also best hipaa compliant web and hipaa compliant app development agency having experience with doctor App Development experience also.

Custom Healthcare Software Development Company in USA said...

Thank you, your writing is really good.

Read about Wi4 which is Best Telemedicine Software Solutions Provider and Best Laboratory Management Software Provider . We are also best Hospital Management Software Development company and Best Medical Device Software Development Company agency having experience with Veterinary Practice Management Software Solution Provider also.

Seva Home - Buy Candles Online and Fragrance Candles Online in India said...

Nice Blog!Thanks for sharing this information.
Check our website to buy gifts and candles WINTER WOODS, SET OF 3 RED VOTIVES, HEIRLOOM BOWL CANDLE - BLACK (NOIR), HEIRLOOM BOWL CANDLE - SILVER (AQUA), HEIRLOOM BOWL CANDLE - ROSE GOLD (RED BERRIES)

Custom Healthcare Software Development Company in USA said...

Wow, what great writing. I liked the way you have explained with that much detail.

Read about Wi4 Software Solutions including HL7 FHIR Development . We also deal with the data with program design and implementation . Know more about platforms and products offered by Wi4.

Custom Healthcare Software Development Company in USA said...

Congratulations, your writing is really good.

Read about Wi4 which is Healthcare Data Analysis Software Development and Medical Imaging Software Development Company . We are also best Remote Patient Monitoring Software Development and Patient Engagement Solutions Provider agency having experience with IoT Healthcare Software Developer in the USA also.

Seva Home - Buy Candles Online and Fragrance Candles Online in India said...

HEIRLOOM BOWL CANDLE -GOLD (BLOOM), TWO TIERED CANDLE - BLACK (NOIR), TWO TIERED CANDLE - SILVER (AQUA)
, TWO TIERED CANDLE - ROSE GOLD (RED BERRIES), MEDLEY CANDLE - BLACK (NOIR), MEDLEY CANDLE - SILVER (AQUA),