Wildcard People Search on MOSS 2007
Written by Ramon Scott on July 8, 2008 – 6:34 pm -Unfortunately out-of-the-box Microsoft Office SharePoint Server 2007 does not play nice with wildcard searches. This is particularly troublesome when searching for people with hard to spell names.
Here’s a quick solution for a adding a web part to the home page that allows for searching for people using first, last or a combination of names. Wildcards are supported on either.
So, entering a first name of Rob would return results for Rob, Robert, Roberta, Robbie, etc. Likewise, a last name search for Smit would return results for Smith, Smits, Smitkerson, etc.
To use this, just add a content editor web part to the moss home page and paste the code below into the source view. The form will submit to the default people search results page.
Tags: MOSS, SharePoint, WSS
Posted in SharePoint | 21 Comments »


July 18th, 2008 at 8:34 am
How would you add an additional field for Department to perform wildcard searches?
July 22nd, 2008 at 12:13 am
Hi, thanks for the excellend post, its very good solution for wildcard search. But I have a slightly different scenario. The client doesn’t want separate text boxes for first name or last name or any other property. There is a single textbox similar to the standard search webpart, and in that want to incorporate the wildcard search. Any ideas for that, or how I can modify script as given by you. Any help would be more than welcome. Thanks
July 30th, 2008 at 7:27 am
Excellent post…very simple…the only problem I have is that with the results, the formatting of all of the employees information is non-existent…it is one long string of information. Do you know where I might make the changes, or what changes TO make on the peopleresults.aspx page so that the formatting is correct?
September 18th, 2008 at 2:43 am
hii .i tried this people search but it is working for only my detail is displaying not others.Is there any other settings to be done in peoplesearch result page?pls reply me in detail.
September 18th, 2008 at 2:49 am
where i should add the details of the people.
September 22nd, 2008 at 6:38 am
Is there a way to search for phrase endings? All wildcard solutions offer only begining phrase search.
If I had a telephone number string like: 984395857883 and tried to search for extension *883 in MOSS can I do it at all?
September 23rd, 2008 at 2:38 am
Hi Ramon,
I modified your code to enable wild card search on PreferredName (e.g. Kelvin Chris) instead.
I entered “Kelvin” but there isn’t any result.
Any idea?
Thank you in advance!
September 26th, 2008 at 7:06 am
I like your example of a division dropdown, but does wildcard searching work on something like Skills and Responsibilities? I tried passing skills:”C” to the peopleresults page and it only returns exact matches. Is there some configuration that needs to be changed?
October 23rd, 2008 at 12:50 pm
Thanks for this post,thats what i was exactly looking for.
October 24th, 2008 at 12:02 pm
I followed your other post where you show how to search by other fields but having a problem in there.
I have added Department field and made it as a text box instead of dropdownlist but it only return results if we provide the full department name.Its not doing the wild card search the same way its doing for first and last name. could you please show us how to do wild card search on other fields also like department.
October 27th, 2008 at 2:07 pm
This is fantastic. Thank you.
I have one question.
If I use this code on the actual “peopleresults.aspx” page (by adding a content editor webpart there), is there a way to have those fields filed out with what they searched on. by default, the get cleared each time. Can this be pulled from teh url using javascript and populated back into the form? Thanks.
November 5th, 2008 at 10:30 am
Raj –
You need to remove the quotes from the search term – to get the wildcard to work
skills:C
make sure there is no space between the catgory and the term
November 10th, 2008 at 6:01 am
Hi Ramon – Do you by any change have a similar code for ordinary (not people search) wildcard-search in MOSS 2007?
December 8th, 2008 at 11:07 am
This is great code! However, has anyone encountered a problem where the apostrophe in a person’s last name, like O’Brien, causes an error, or no person found?
I’m researching ways to fix this. The double single quotes and the %22 doesn’t work in our farm. The same issues occurs on the Site Contact link. It breaks for a name with an apostrophe.
Any suggestions?
March 4th, 2009 at 10:04 pm
Great quick and easy soltuion
March 31st, 2009 at 8:29 pm
Just had to configure it to point to the correct site since mine’s not set up as the default, and it works like a charm! Thanks for the code.
July 8th, 2009 at 3:55 pm
[...] in the people search functionality. This snippet gets around that using code inserted into a CEWP: http://www.ramonscott.com/wordpress/?p=8 Filed under: Coding | Leave a [...]
July 23rd, 2009 at 2:51 am
Nice Code. I’ve tried and its work. but how can i search with keyword last character. i.e : “eo” and the result is “Leo”
October 23rd, 2009 at 7:14 am
The other alternative is to make use of the Sharepount XML thesaurus files (loads of web pages about this) that way you get “Jim” returning “James” and loads of other misspellings that a wildcard may not get – “Cath” and “Kath” for example.
It takes a while to generate you XML file but is another alternative.
December 16th, 2009 at 4:02 am
[...] Wildcard People Search on MOSS 2007 [...]
January 21st, 2010 at 7:47 am
We’ve expanded on this a slight bit – rather than having different text boxes for the different parts of the name we have created a new “Metadata Property Mappings ” in Share Services Search Admin that is called “searchname” and this has the “Include values from all crawled properties mapped” option checked and then mapped to many fields from the people listing, including a user editable one “Other names” so users can add common misspellings and alternative names they may have – including pre-marriage names – then we simplified the code to remove the if statements, simply to search on “searchname”.
We also have, although not told anyone, Car License plate so we can quickly find “naughty” cars that are blocking others in, or in rare cases, slipping down the car park.