Dot Net Mafia

Group site for developer blogs dealing with (usually) Ionic, .NET, SharePoint, Office 365, Mobile Development, and other Microsoft products, as well as some discussion of general programming related concepts.

This Blog



Corey Roth [MVP]

A SharePoint MVP bringing you the latest time saving tips for Ionic, SharePoint, and Office 365.

Wildcard Search Web Part for SharePoint 2010

SharePoint 2010 Enterprise Search has great wildcard search support built in now.  However, it requires the use to add an asterisk to their query every time they want a wildcard search.  This is a great step compared to what we had in MOSS 2007, but now it results in a training issue.  In 2007, many people wrote custom code or relied on the Wildcard Search Web Part that I built.  So I thought why not use the QueryManager object to override the query and add an asterisk to the query for the user. 

Since they’ve given us some methods to override now on the CoreResultsWebPart, these kind of changes can be done easily without using reflection.  We start by adding assembly references to Microsoft.Office.Server.Search.  Then we create a new web part inheriting from CoreResultsWebPart and add the following using statements.

using Microsoft.Office.Server.Search.Query;

using Microsoft.Office.Server.Search.WebControls;

We then override the GetXPathNavigator method and get a reference to the QueryManager and override the UserQuery property.  In reality, there are only two lines of code involved.

QueryManager queryManager = SharedQueryManager.GetInstance(this.Page).QueryManager;

queryManager.UserQuery = string.Format("{0}*", queryManager.UserQuery);

You can look at the code in the CodePlex project for specifics.  Instructions to add the solution package are included in the readme.txt file.  You can use PowerShell to add the solution package or use stsadm still if you like.  Once the solution is installed, activate the Wildcard Search Core Results ( site collection feature.


Now, go edit any search center results.aspx page you have and use the add web part button on the bottom zone.


Click on the Search group, and choose the Wildcard Search Core Results ( web part.


Remove the existing CoreResultsWebPart from the zone and drag it into place.  You can then stop editing (or publish) the page.  Try a wildcard query and you should get results like the one below.


Notice how i search for accoun and yet I get matches for Accounting and Account.  Very cool.  I’ll warn you that this is a very preliminary release.  It definitely needs more testing so if you run into issues, please let me know.  This was compiled against the release version of SharePoint 2010.  Give it a try and let me know what you think.

Wildcard Search Web Part for SharePoint 2010

Follow me on twitter.



Twitter Trackbacks for Wildcard Search Web Part for SharePoint 2010 - Corey Roth - - Tip of the Day [] on said:

Pingback from  Twitter Trackbacks for                 Wildcard Search Web Part for SharePoint 2010 - Corey Roth - - Tip of the Day         []        on

May 13, 2010 4:46 PM

sathish said:

Hi Corey Roth,

This a great post and it help me a lot.

I have a requirement to override the Search Action Link Webpart in People Search. I want to add two more managed property to the DropDown so that I can sort on that.

I want to add LastName and FirstName to the dropdown with the existing Relevance,social distance and name

Can you help on that

May 24, 2010 11:45 AM

Rob S said:

Thanks, Corey.  This is a help!

After setting this up, however, I'm not receiving any message when no results are found.  Any way I can rectify this?

Thanks in advance

July 28, 2010 10:36 AM

Mario said:

Hello Corey,


When you do not use the asterix wildcard the refinement panel is not filtered. So this makes this solution limited in use.


We want to modify the WildcardSearchCoreResultsWebPart to change the look of the results web part. But whatever we do in Designer is not displayed in the browser.

Do you know why?

Kind regards,


October 22, 2010 6:15 AM

Mikael Svenson said:

Do you have any idea why this webpart won't work against the FAST SSA? Against the built-in search it works just fine, but if you point it to use FAST results it shows nothing at all.

November 3, 2010 8:13 AM

CoreyRoth said:

@Mikael I'm surprised it doesn't work.  The syntax should be the same.  I'll try this out when I get a chance.

November 5, 2010 11:03 AM

Yaelc said:


This is a great solution.

It does work for fast for SharePoint 2010.

But when I use it does not returns the "Did you mean ?" or as mentioned before it does not return any message when no results are found.

Do you know why, or how to solve it?



November 8, 2010 4:10 PM

Cecilie Widsteen said:


if all  you need to do is to add the asterisk to the query, then it's possible to add it in the confuguration of the federated location you are using. Since even local searches are routed through the federation layer, as documented here: - “The search result Web Parts in SharePoint Enterprise Search are built on top of the federated search object model.” - then you can add the asterisk to the query template of the "Local Search Results" location, like so: {searchTerms}* . It seems to me you'll achieve pretty much the same, no programming needed.

May 5, 2011 5:41 AM

Pepe said:

Hi Corey,

I have the same requirement that Sathish who wrote "How to override the Search Action Link Webpart,  I want to add two more managed property to the DropDown so that I can sort on that."

Could You help me?

Kind regards,


May 6, 2011 10:56 AM

Manisha said:

I changed the QueryManager.UserQuery in GetXPathNavigator() method. But it seems that though user query is getting updated. Results fetched are not getting changed as per the new query. ApprovedCountries is the custom managed property.

Here is the code:


   public class CMSCoreResultsWebPart : CoreResultsWebPart


       private QueryManager queryManager;

       private KeywordQuery keyQuery;

       protected override void OnInit(EventArgs e)


           queryManager = SharedQueryManager.GetInstance(this.Page).QueryManager;



       protected override System.Xml.XPath.XPathNavigator GetXPathNavigator(string viewPath)




               Page.ClientScript.RegisterStartupScript(this.GetType(), "AlertPartNumbe1r", "<script type='text/javascript'>alert(' " + queryManager.UserQuery + "');</script>");

               queryManager.UserQuery = queryManager.UserQuery + " ApprovedCountries:India";

               Page.ClientScript.RegisterStartupScript(this.GetType(), "AlertPartNum33be1r", "<script type='text/javascript'>alert(' " + queryManager.UserQuery + "');</script>");


           catch (Exception ex)


               Page.ClientScript.RegisterStartupScript(this.GetType(), "AlertPartNumber",

             "<script type='text/javascript'>alert('" + ex.GetBaseException().ToString() + "');</script>");


           return base.GetXPathNavigator(viewPath);


May 19, 2011 7:44 AM

CoreyRoth said:

@Manisha your code looks like it should work.  You can download the source code to the web part I did from codeplex if you need something to compare against but it is pretty simple.

May 19, 2011 9:02 AM

Steve Reid said:

I added the astriks like Cecilie Widsteen said and it seems to work without needing this webpart...

Thanks Cecilie Widsteen!

May 19, 2011 9:28 AM

CoreyRoth said:

That technique does work but you may run into issues if you start creating custom queries using managed properties as it will render the syntax invalid.

May 19, 2011 9:43 AM

AJ said:

Hi Corey - I'm struggling to activate the feature - what's the syntax? I've been trying:

Enable-SPFeature –Identity WildCardSearchCoreResultsWebPart –url http://sharepoint/

And I'm getting the error:

The feature is not a farm level feature and is not found in a site level defined by the url http://sharepoint/

What have I done wrong?

May 23, 2011 5:50 AM

CoreyRoth said:

@AJ Your syntax looks correct.  Are you sure the solution package installed correctly.  Verify that it's there and deployed in Central Administration.  You can also activate the feature through the UI in Site Collection features.

May 23, 2011 9:51 AM

Cecilie Widsteen said:

I absolutely agree with Corey - this could have side effects that you haven't thought of and you need to be aware of what you're doing :) like, I presume what you mean by custom queries using managed properties is when you do a fielded search? Like this: keyword1 fieldname:keyword2 - you'll acheive nothing here, because the asterisk will be added towards the end of the expression... and a fielded search is by default a wildcard search. Thing is, if you don't have users that are likely to be aware of the possibility to do fielded searches, then you'll risk little. And you could always create another location without the asterisk added under the hood and let experienced users perform their search towards this other location. But if you for instance use append to query on your web part, you'll actually get the asterisk appended after the appended text AND a space. So you should also be aware of this and check if this is something that renders this solution useless to you.  

May 30, 2011 6:48 AM

Walt Fles said:


I activated the feature and am having trouble with making it the default search engine.

What exactly do you mean by: "The Wildcard Search Core Results Web Part can then be added to your Search Center's results.aspx page.

Simply add this web part to the bottom zone and remove your existing Core Results Web Part."

I guess that starts with:

"Now, go edit any search center results.aspx page you have and use the add web part button on the bottom zone." but I'm confused how to get there.

Thanks in advance!

June 24, 2011 10:23 AM

Wildcard Search Sharepoint 2010 | Code ??ffle Blog said:

Pingback from  Wildcard Search Sharepoint 2010 | Code ??ffle Blog

October 29, 2011 3:04 PM

CoreyRoth said:

@Walt.  Just edit the results.aspx page of your search center, remove the existing CoreResultsWebPart, and ad this new one in its place.

January 6, 2012 1:03 PM

samo said:


i'm facing this problem that the web part is not displaying, though i activated the feature in the "Site collection features"...

what should i do

January 31, 2012 11:28 PM

CoreyRoth said:

@Samo It doesn't appear in the web part list?  Does it appear in the web part gallery of the site collection?

February 6, 2012 11:52 PM

Ajay Sharma said:

Thank you for your great work. I have created a custom webpart inheriting from Coreresultwebpart that do the sorting on LastName. I am using Ranking model logic to sort the results on LastName as this was not available as default. But when i added your code to override the XPathNavigator method then sorting stopped working. Please help as this is urgent for my client. Client want both cutom sorting with wildcard search.

June 2, 2012 6:57 AM

CoreyRoth said:

@Ajay do you have a code snippet you can share?

June 6, 2012 1:32 PM

Randy Schader said:

I just installed this webpart and noticed:

1)  The refinement panel only displays ‘No refinements available’.  Is this expected behavior?  If not then I will continue investigating.

2)  I see that someone else tested with a known condition of no items returned, and did not get any message stating such.

I will back out the new web part and try the approach mentioned by Cecilie Widsteen (May 5, 2011).

June 29, 2012 4:33 PM

James said:

We are having a problem with refinements.  When the search term is a wildcard, "stew" rather than "stewart" it returns a set of results but the refinements are not found.  If we search on "stewart" the results are the same and we get refinements.  Another odd thing is in the first scenario, using a wildcard search term, we get the results, click on a sort column and we get refinements with a refresh sorted result set.  Any suggestions on this?  

July 26, 2012 4:11 PM

Doreen said:

Thank you - Thank you for this !!

Just having an alignment issue where it right justifies (leaving a very, very large left margin on the screen which looks silly) the results when we de-select the 4 items below.....

Display "Search from Windows" Link

Display "Alert Me" Link

Display "RSS" Link

Allow users to display language picker

Tried moving to middle lower left zone and that's too "skinny" but it is left

Any easy idea for this?

November 15, 2012 4:26 PM

Avian said:

I download the tool, seems to be working fine, thanks for sharing.

I have five type of following documents in my document libraries






Now when I search keyword as 123AVK, it returns following two result



I want it should result all 5 records as mentiond above because all five documents are containing 123AVK.

so please share your thoughts and let me know how can I do this?


July 17, 2013 5:02 AM

Palvayi said:

How to do wildcard search in Infopath form 2013

October 21, 2015 9:22 AM

Leave a Comment


About CoreyRoth

Corey Roth is an independent SharePoint consultant specializing in ECM, Apps, and Search.
2018 dotnetmafia.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems