Thursday, December 11, 2014

How to trigger re-indexing of updated user profiles in SharePoint Online

Get re-indexing as an App - http://searchtoolbox.azurewebsites.net/

You asked for it, and I deliver an early Xmas present for your pleasure and enjoyment!https://github.com/wobba/SPO-Trigger-Reindex

This script was made possible by the September 3rd release of the CSOM SDK which implements user profile write support. And DO NOT run it from a SharePoint Online Management Powershell, use a regular Powershell with no special cmdlets loaded. If not you get CSOM DLL hell.

Problem: You map an existing (or new) crawled property corresponding to a user profile property to a new managed property you want to use in search (phew). After the mapping, you wait and you wait and you wait (as you cannot start a full crawl yourself in SPO)… and you never get a value in your managed property. You curse some, you Google some, you post some questions in forums or Yammer. Then you go and edit your user profile in the SPO UI, wait some more.. and voila the value is there. You’re seriously baffled at the randomness and think to yourself

How the can I ask my 5,000 users to go edit their user profile to get that new property working in search??

(don’t worry - my script will help you out!)
Ok.. these are my findings as per December 10th 2014 (subject to change)
  • There are no full crawls executed on user profiles
  • User profiles are incrementally crawled at a 4 hour interval – Seen as low as 2 hours during the night and as high as 8h during the day
  • Working with search and user profiles in SPO will require patience – no way around it unless you hit the crawl schedule right on
So in order to trigger a re-index of a user profile you need to save it. What the script does is read out the SPS-Birthday field. Write a new random value to the field, and then re-write back the original value, that being a real date or blank. This has the effect of not messing with the data in the profile and triggering it to be re-index on the next user profile incremental crawl. If you have removed the SPS-Birthday field edit the script and use something else.

You still have to wait 2-8 hours for data to appear in the index, but it will appear - eventually.
Want the script….. head over to https://github.com/wobba/SPO-Trigger-Reindex where you also will find my script to trigger content indexing in SPO.

You can find my post about re-indexing content  at http://techmikael.blogspot.no/2014/02/how-to-trigger-full-re-index-in.html

13 comments:

  1. This changes everything. Again. I've been waiting a long time for someone (you) to come up with a solution that triggers a re-indexing of user profiles in SPO. I'll give you an infinite amount of hugs the next time I see you around at HQ. Thanks!

    ReplyDelete
  2. Replies
    1. Hope it makes life a little bit easier :)

      Delete
  3. Thanks Mikael! Could this technique be modified in order to populate the User Profile Pictures?

    ReplyDelete
    Replies
    1. Not sure of the API to set the picture, so not sure.

      Delete
  4. Mike, if you were a girl I would kiss you ;)

    ReplyDelete
  5. Dear Mike,

    I have an issue with Groups in SPO, so can you extend your script also to SPO groups (as you did for Users ;-)

    ReplyDelete
  6. We would like to use the user profile property 'Office' as a refiner in our People Search. We used your script but it worked only partly. When I make people search only some peoples Office property values are shown in the refiner... No errors while running the script.

    ReplyDelete
    Replies
    1. Did you use birthday or department as the change field? Could be something there...or change the script and use some other field you know all profiles have.

      Delete
  7. Hi,

    If I do not run the script. Will the modified search schema allow the last name sortable automatically?

    ReplyDelete
    Replies
    1. No, as there are no full crawls for user profiles, only incremental. And incremental needs a changed date in order to pick it up.

      Delete
  8. This comment has been removed by a blog administrator.

    ReplyDelete