Forum Discussion
SharePoint Search Query exclude specific pages based on custom field value
- Jul 20, 2024
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.
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.
Expiscornovus Honestly, I have no idea how to map the crawled properties. I am following the steps here but a bit lost.
https://learn.microsoft.com/en-us/sharepoint/manage-search-schema#map-a-crawled-property-to-a-managed-property
Map 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.
- ExpiscornovusJul 20, 2024Iron 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.
- Tamras1972Jul 29, 2024Iron Contributor
Expiscornovus Using Managed/Crawled properties worked, at least like 99% -- I still can't figure out why one of the site pages with status = draft is getting included in the search results.
My search vertical query has:
RefinableString00="Current"
I mapped the RefinableString00 to "ows_status" and re-indexed the library after changing the search schema. It worked most of the time, search results only include site pages with status = current, except for one page. Not a big deal I guess, since only people with 'edit' permission can see draft versions.