Forum Discussion
SharePoint Search Query exclude specific pages based on custom field value
In our [site pages] library, we added a [Status] column with values [Current, Archive, Draft]. Essentially, in the search results, I only want site pages that have 'current' status. Is it possible to do this in Query Builder or other means (i.e. Microsoft Search Verticals)?
Tamras1972 my first suggestion would be to double check what the internal name of the field is. You can find that in the library settings. Below is an article on how to find the internal name of your custom status field:
https://elliskarim.com/2021/12/20/finding-the-internal-name-of-a-sharepoint-column/
This way you can find which one you would need to add to a mapped property. My suggestion would be to use one of the RefineableString ones from Microsoft for the mapping.
- ExpiscornovusIron Contributor
Tamras1972 you can use for example the ContentType, ContentTypeId or contentclass properties.
Try something like:
contentclass:STS_ListItem_WebPageLibrary
Did you mapped the crawled property of your custom Status field to a mapped property in the search schema? If that is the case you should also be able to use it in your query builder.
- Tamras1972Iron Contributor
Expiscornovus Honestly, I have no idea how to map the crawled properties. I am following the steps here but a bit lost.
Manage the search schema in SharePoint - SharePoint in Microsoft 365 | Microsoft LearnMap a crawled property to a managed property ยป Go to the Search Schema page for a site collection. I got to step #4 and searched "Status" but no idea which one to select. Will continue reading. Thanks for the tip.
- ExpiscornovusIron Contributor
Tamras1972 my first suggestion would be to double check what the internal name of the field is. You can find that in the library settings. Below is an article on how to find the internal name of your custom status field:
https://elliskarim.com/2021/12/20/finding-the-internal-name-of-a-sharepoint-column/
This way you can find which one you would need to add to a mapped property. My suggestion would be to use one of the RefineableString ones from Microsoft for the mapping.