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: , ,
Posted in SharePoint | 21 Comments »

21 Comments to “Wildcard People Search on MOSS 2007”

  1. Leigh Says:

    How would you add an additional field for Department to perform wildcard searches?

  2. Preet Says:

    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

  3. Jay Says:

    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?

  4. zulu Says:

    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.

  5. zulu Says:

    where i should add the details of the people.

  6. Elzbieta Says:

    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?

  7. Kelvin Says:

    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!

  8. Raj Says:

    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?

  9. Ricky Singh Says:

    Thanks for this post,thats what i was exactly looking for.

  10. Ricky Singh Says:

    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.

  11. Mike Says:

    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.

  12. paisleygo Says:

    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

  13. Aske Says:

    Hi Ramon – Do you by any change have a similar code for ordinary (not people search) wildcard-search in MOSS 2007?

  14. Tim Goodgion Says:

    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?

  15. Michael Campbell Says:

    Great quick and easy soltuion

  16. Ryan Says:

    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.

  17. Reasons to love the Content Editor Web Part (CEWP) « 5280 SharePoint Solutions Says:

    [...] 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 [...]

  18. Leo Says:

    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”

  19. Chris Says:

    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.

  20. La recherche “People” sous MOSS 2007 : une alternative au WildCard , The Mit's Blog Says:

    [...] Wildcard People Search on MOSS 2007 [...]

  21. Chris Says:

    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.

Leave a Comment

RSS