I was troubleshooting one of our products in O365 and ran into an issue where search results were not coming back. So I popped open the SharePoint 2013 Search Query Tool and started to look into the problem, and about two minutes into the process I remembered that SharePoint search is infuriating. My query worked just fine in an on-premise situation, but in O365 it was returning no results. Specifically, I was querying for a user. Specifically me. So I was querying with something like this:
Now, I knew which document was supposed to be coming back so I searched for the title of that document using a keyword search. And it returned back from the search engine. I had high hopes that maybe the userField was not mapped or that the value was something unexpected. The results:
title – “The Document I was Looking For”
userField – “Damon Armstrong”
So the exact term for which I was searching was being returned in exact form from the exact field in the search index. Thanks SharePoint. If you are familiar with search you are probably thinking that the mapped property was not setup as queryable or that some other setting was off. I figured the same, but the property was setup as correctly as I knew how at the time. So I went into the mapped property settings for userField and turned on just about everything I can think of to make it work. And it worked on the first try! I had turned on so many settings that I started to remove ones that I figured were unnecessary to trim down the instructions for how to get this to work. Everything I changed broke it again. So apparently I found just the right combo the first time around.
So, to get a user property configured so you can search for a user by name you need to do the following. All of the following. At least in my limited experience on the matter:
- Searchable is unchecked [did not test modifying this setting]
- Queryable is checked.
- Retrievable is set to No.
- Refinable is set to No.
- Sortable is not checked.
- Safe for Anonymous is unchecked [did not test modifying this setting]
- Alias is blank [did not test modifying this setting]
- Token Normalization is checked.
- Complete Matching is not checked.
- Company Extraction is not checked [did not test modifying this setting]
- Custom Entity Extraction is unchecked [did not test modifying this setting]
- Include content from all crawled properties is selected.
- Create a single mapping to the ows_q_USER_<fieldName> crawled property
- There is also an ows_<fieldName> crawled property that should NOT be selected
This allowed me to search by user name and logon. Any of the settings that I did not test might be able to be changed, but if anything goes wrong you can revert back to this set of settings and use trial and error to determine which setting is throwing things off.