We have several Person or Group fields with users in them. We need to write a query that will find all content where that field contains a specific user. The following queries are returning 0 ResultRows:

Submit-PnPSearchQuery -Query "PersonField:me@myaddress.com"

Submit-PnPSearchQuery -Query "PersonField:i:0#.f|membership|me@myaddress.com"

Submit-PnPSearchQuery -Query "PersonField:1114" where the number is my SharePoint ID

How do I submit this query correctly?


A Search Managed Property that is mapped to a user/group field will contain the user or group's Display Name (e.g. Joe Smith), full username (e.g. i:0#.f|membership|jsmith@tenantname.com), email address (e.g. jsmith@publictenanturl.com), and an alphanumeric unique identifier (not the integer userid), so you can query against any of these values. If you view the value in the mapped Search Property it would look something like jsmith@publictenanturl.com | Joe Smith | 693A30232E667C6D656D626572736869707C737A35736D6B40616C736E2E6636F6D i:0#.f|membership|jsmith@tenantname.com.

The real trick though, and likely where you problem is, is making sure that Managed Property exists, and determining what its name is. In order to execute a Search query on a field, it has to have a Managed Property set up in the Search Index and marked as queryable.

If your properties are created as Site Columns first, and then added to lists and libraries, SharePoint will auto-create managed properties for you. If SharPoint auto-creates an managed property for a user/group field, the property will have a suffix of "OWSUSER" (and yes, it is case sensitive and the suffix is in all caps). So, if your PersonField example is a site column with an automatic search managed property, your query would look like

Submit-PnPSearchQuery -Query "PersonFieldOWSUSER:me@myaddress.com"

If your columns are defined directly on your lists and libraries, you will need to manually create a Managed Property. Use type of "Text", then you can use whatever you name your property to query on.

Submit-PnPSearchQuery -Query "WhateverYouNameYourMappedSearchProperty:me@myaddress.com"


If the field is a custom list column, just like willman said, have a check on crawled properties and make sure the column is crawled, then add a managed property map to the crawled property corresponding to your column.

For site column, there will automatically created managed property with mapping to the crawled property after a full crawl.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.