Wednesday, March 20, 2013

SharePoint 2013: Adding People to Everything Search Results

Once again, the main search results, which is now called Everything, does not include People search results. So it's not really everything. The reason is because there is a special People Search Results web part that is catered towards the User Profiles and their respective properties. If I searched for my last name, my personal profile result does not appear:

 
It's all good. With the the SharePoint Search capabilities, you can add some people results into my main search (Everything). First go to the site settings of your Search Center and under Site Collection Administration click on Search Query Rules:
 
 Select Local SharePoint Results (System) in the Context drop-down:
 
 
Once that is selected, click on New Query Rule:

 
On the Add Query Rule page, add a rule name, remove the condition, and then click on the Add Result Block link:
 

 
 
On the Add Result Block page change the Title to state "People Results". In the Select this Source, select Local People Results (System) and select the amount of items. The default is 2 and that's probably not enough (just like beer or martinis). 3 or 5 seem like good numbers.


Under the Settings section, as shown above, select the "More" link option and enter "peopleresults.aspx?k={subjectTerms}". Select People Item from the Item Display Template. Click OK.


Back on the Add Query Rule page, click Save.

Run your search again (it may take a moment for the changes to appear):

The People Results were modified in the above screen shot to protect real people information.


Now I have people results appearing in the search results under Everything!!!


 

76 comments:

  1. Replies
    1. Good. You could also just modify the query and remove the portion that excludes people but I needed a promoted result block anyway.

      Delete
  2. I dont know what i've done wrong, but mine isn't working :/ Ill give it another go !

    ReplyDelete
    Replies
    1. You have user profiles in your SharePoint environment, correct?

      Delete
  3. I was looking for exactly those settings. Thanks a lot! I could get it to work within minutes!

    ReplyDelete
  4. Hi Steve,

    Is there away to edit the preview information?I don't want others to see my Authored documents.. is there away to change it to something else.. like information about me..

    Thanks in advance

    ReplyDelete
    Replies
    1. Yes you would need to create a new Person Display Template along with a new Person hover panel. You can copy the out-of-the-box versions and then modify accordingly. In the hover pabel template, simply remove the divs that show the authored documents. Then you would configure People results to use the new template. That's the best practice method. The easier method is just to edit the current people hover panel template and rip out the authored documents section. I have many posts that describe how to edit the display templates. Here is one that modifies the PDF templates: http://stevemannspath.blogspot.com/2012/10/sharepoint-2013-pdf-preview-in-search.html

      You would follow similar steps but just modify the person hover template instead.

      Delete
    2. could you please help me locate divs that show the authored documents? which template am I looking into?

      Delete
    3. I am still on holiday but the template is Item_Person_HoverPanel.html. I am sure you'll find the divs towards the bottom.

      Delete
    4. I checked the Item_Person_HoverPanel.html, I could not find the DIV you are referring to? Care to elaborate? Thanks

      Delete
    5. Actually I think it is this:

      AddPostRenderCallback(ctx, function(){
      var docCtrlElem = document.getElementById(dynTagId);
      Srch.PSU.documentsByQuery(ctx.ClientControl, uname, docCtrlElem, infoAvailable, isExpResult);
      });

      Delete
    6. Hi Steve, the code you mentioned above is already commented out. Any other ideas how to get rid of the Authored documents section?
      Thank you.

      Delete
    7. It may look commented out but that's the way the code looks in the HTML version of the template. I would make a copy and actually remove the code in question. The use the copy of the template.

      Delete
  5. Hi Steve,

    I'm a beginner and try to learn Sharepoint Search 2013. I've done the same, but mine isn't working...How can I look up if my user profiles are correct?

    Thanks in advance.

    ReplyDelete
    Replies
    1. You would need to go into the User Profile Service Application and verify the profiles have been synchronized. This is done via Central Admin -> Manage Service Applications.

      Delete
    2. Amazing! Thank you for the great response.

      Delete
  6. I did the same thing in my solution, but when I wanted to display some additional managed properties it turned out I can't... That is - the property mapping is set perfectly fine, it works and displays under people tab, but the result block simply don't get the additional properties... Any ideas?

    ReplyDelete
    Replies
    1. You may need to update the Result Type:
      http://stevemannspath.blogspot.com/2013/03/sharepoint-2013-search-managed-property.html

      Delete
  7. How you found a way to deploy a result block programatically? I can only find internal classes and methods?

    ReplyDelete
    Replies
    1. I haven't done it programatically. I haven't looked into it either.

      Delete
  8. Hello Steve

    thanks for the great post. I have a question regarding to query rules. If my user is looking for "cancelation" I don't want to show him any results. If I could show him an error message it would be perfect. Maybe with the "Change the rank by changing the query"?

    ReplyDelete
    Replies
    1. Yes! I had to do something similiar but change the search term. In your case, clear out the search query term box. I just tested this and no results appear.

      Delete
    2. Awesome! It works. But now I have the next problem :):

      Can I do the same, if one of my user is looking for a managed property? For example "autor:F123456" . I don't want that the users are able to search for autor. Do you have an idea?

      Delete
    3. In your Search Schema, edit the autor managed property and make sure Queryable is not selected. If you don't want them to get results trying "F123456" either, then make sure Searchable is unselected as well. Run a full crawl after these modifications.

      Delete
  9. Hi Steve,
    I encountered a little issue with my search result. I tried to follow your post without any good results.
    It could be great if you could help a sharepoint newbie like me.
    In people search, when I put the first 3 letters of a user name (example DES), I would like to see a list of users where LastName begin with DES letters.
    But in fact, the search give me a list of users where it find DES letters in others fields of the profils (like Function, Direction, Services ...)
    How can I priorize the result of this query to show me in the top, every LastName users which are beginning with 3 letters I wrote in the search?

    Don't know if my question was really clear.
    Anyway, thanks for your post (and maybe help)

    ReplyDelete
    Replies
    1. I understand what you are saying. We have our own source for people data so we don't use the user profiles. What I did was dump out the last names and the full names of all of our employees and clients. From this I created a suggestion file and uploaded that to SharePoint. I am not sure how to resolve your issue directly. There are two sets of suggestions - content and people. Your problem is in the People. Anything I can think of right now would be a hack.

      Delete
  10. Hi,

    does this only work in an enterprise search center site? i have tried in a normal team site but it doesn't work

    thanks

    ReplyDelete
    Replies
    1. I have implemented search results in other sites. Compare which Site Collection and Site features are activated.

      Delete
  11. hi, great post, i have this working, however i want to display the users telephone number as well, i have followed: http://antclegg.blogspot.co.uk/2013/09/people-search-with-work-number-in.html to create a new template with the phone number, this works fine on the People search but on the Everything search it doesn't display the phone number, i have also specified the correct template to use under the search query rules for the collection.

    ReplyDelete
    Replies
    1. Did you update the Result Type? http://stevemannspath.blogspot.com/2013/03/sharepoint-2013-search-managed-property.html?m=1

      Delete
    2. hi,

      didnt see the option to update result types, i did a full reboot of my farm just to clear any cobwebs, but this didnt resolve it either,

      however, i did then create a copy of the person result type and told it use my new template which displays the telephone number, so now my people search under everyone shows the correct details!

      so thanks for the pointer about the result types! i'm a complete newbie to sharepoint but picking things up quickly - next challenge is to get office location in there!

      thanks again

      Delete
  12. Really appreciate it! Just teaches me there are so many aspects of SharePoint OOB that need to be explored. Thanks you!

    ReplyDelete
  13. Good stuff! This has saved my team days to weeks of time!

    ReplyDelete
  14. That worked just great! Exactly what I needed!

    ReplyDelete
  15. Hi. Excellent post. Worked perfectly for adding people to everything. However, now normal people search returns no results. Should this be an after effect? Normal people search has no results for the person but "everything" does? Thank you

    ReplyDelete
    Replies
    1. Should not be an after effect. Check the Search Results web part configuration - specifically within the Change Query dialog.

      Delete
  16. Worked for me! Thanks for the great post!
    do you know why the sorting of the people results on the 'everything' page is different to the sorting on the people result page?
    thank you

    ReplyDelete
  17. Hi, how to return fuzzy search in everything?

    ReplyDelete
  18. Haven't officially investigated fuzzy searches, however, I would look at the various ranking models that are available. Also, creating and uploading a thesaurus may help as well.

    ReplyDelete
  19. Hi, It seems that fuzzy people search works fine the people search but not in everything

    ReplyDelete
  20. SharePoint 2013 also provide nickname search. On People's tab I am able to see the results. but on Everything tab the same nickname search do not bring through results. So by applying your suggested query rule will that solve the problem or some other extra work I will have to do?

    ReplyDelete
    Replies
    1. The results should be the same with the promoted result. I also have name variations in my thesaurus. For example: Rob, Robert, Bob...

      Delete
    2. Hi Steve, are you saying thesaurus is working on people search (people scope) as well?

      Delete
  21. This is good solution. It worked for me. The only problem I have is that it shows the result block for people even if I did not search for a person. For example, it shows the top one person for finance before showing the result set for finance. How can prevent it from showing the result block for people when the search term is not a person?

    ReplyDelete
    Replies
    1. It is not an AI system. If I search for "Washington" am I looking for D.C. content or last name??

      Delete
    2. It is not an AI system. If I search for "Washington" am I looking for D.C. content or last name??

      Delete
  22. I have done this with success. The one part I am trying to do differently is use a custom Display template that shows more user data. I have this setup and working properly on people search. When using the same display template in the block settings, only a few of the attributes show up versus all like on people search. Any idea?

    ReplyDelete
    Replies
    1. Check the Result Source and make sure it is going against People. You can also use the browser developer tools to inspect the ctx.CurrentItem to see what is coming back.

      Delete
  23. I have double checked and the block result source is going against "Local People REsults (System)". I am not sure how to inspect the ctx.CurrentItem with the dev tools, can you provide a little insight on that?

    ReplyDelete
  24. Can I show the active directory ID results in people set?currently it is showing under everything.

    ReplyDelete
    Replies
    1. Need more clarification of what you mean.

      Delete
    2. Need more clarification of what you mean.

      Delete
  25. Thanks for this article, but I found the promoted people result in "everything scope" is different from the "people scope" search result.
    1. if you search "Bill" on "everything", "William" won't come up, but it will come up on "people scope" search result page.
    2. if you search "William", "Williams" won't come out on "everything", but it will come up on "people scope" search result page.
    3. the result sort order is different.
    Do you have any ideas about how to make them consistent?

    ReplyDelete
  26. Steve, Great Article, One question maybe you can help me, I copied "Local People Results" Result Source to customize it to hide certain domain users and when I use it results come back but it seems the display template is blank like this: https://social.technet.microsoft.com/Forums/getfile/867139 what can be wrong? MANY THANKS FOR YOUR TIME.

    ReplyDelete
    Replies
    1. Go into the result types and see if they need to be updated. There will be a bar at the top of the page alerting you to this.

      Delete
    2. Go into the result types and see if they need to be updated. There will be a bar at the top of the page alerting you to this.

      Delete
  27. Awesome post. worked like charm. Much thanks dude.

    ReplyDelete
  28. Hi Steve,

    Great post!
    I have to change 'People' label to People Directory' in the search result page
    Can you please help me to do the changes.

    ReplyDelete
  29. Hi Steve,
    Can I customize document library search "Find a file", so that when performing search, the results are displayed based only on file name and not the content. I am aware of using Filename:Keyword but that doesnot work all the time.

    ReplyDelete
  30. Fantastic post! Weird fact, it didn't show up in a Bing search! Thank you for this!!

    ReplyDelete
  31. I have a duplicated user in my search, how can I remove it?

    ReplyDelete
    Replies
    1. If you have People as a separate Content Source, then I would delete the Content Source, wait until there are no results left in search, and then run a full crawl. Otherwise, I would reset all crawled content and then do a full crawl.

      Delete
  32. Hi Steve, very useful post (and many others too), I really appreciated it as I was trying to get my head around SP2013 search just now. A related question, if you have a moment: It seems that to take advantage of the built-in people-search specific functions like phonetic name matching "people search results" are required and this seems to imply that there needs to be a user profile. Is this correct? Our requirement is to search across user profiles + 100K or so external contacts that ideally won't have user profiles (the external contacts are in a SQL server table accessed via BDC, just coming up as web page results for now). Many thanks again!

    ReplyDelete
    Replies
    1. I'm thinking that if you map the BDC crawled properties to the People managed properties you will be fine.

      Delete
  33. Hi Steve, i have customers documents in my main library. How can i enable 'People Name'/ fuzzy search on these documents?

    ReplyDelete
    Replies
    1. add a column to the library to store the customer name

      Delete