Share via

SharePoint Online - Edit Result source Query to Exclude some List item based on Column (Yes/No) type

Anonymous
2021-07-22T16:35:14+00:00

I have one list named as a "Blogs" with column name "Exclude" with Yes/No type. Check snap below.

When List item has value "No" or "False", It should not appear in search result. In short, It should appear only if Exclude Column contains Value "Yes" or "True".

I tried following ways to get the result. Check the highlighted text in image.

I already have some filters in query for documents and want to add one more for list item value.
I created managed property with "Exclude" name and mapped it to crawled property 'ows_Exclude' and I did run "Reindex list" from "Blogs" list.

This is my first time hands on experience with SharePoint result source. Please suggest some ways to get proper result in search result.

Thank you in advance.

Microsoft 365 and Office | SharePoint | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

6 answers

Sort by: Most helpful
  1. Anonymous
    2021-07-28T04:13:05+00:00

    Dear ChandJpgani,

    Sorry for the late reply.

    I'm afraid that the Yes/No column may not better work with SharePoint Modern Search and the better practice may be to use the Choice column with the Yes/No or True/NotTrue value instead of the Yes/No column when performing SharePoint Modern Search in your situation in SharePoint Online.

    I have created a modern team site Search Modern List and a blog list naming BlogNewsList001 and just create 4 items for test. For your requirement, you don't want to search items having Exlude2=NotTrue. You can map the crawed property Exclude2 with the managed property RefinableString100 and use the query AND (Path: https://contoso.sharepoint.com/sites/SearchModernList RefinableString100<>NotTrue). If you want to search by the Title column and the text BlogTitleDetail column, you can just type the column value in the search box. If you want to search the item by ID, you can type ListItemID:ID Value such as ListItemID:1 to find the list item. As the ID number is a default column applied to many lists and libraries in the whole site, you may get some other results when using ListItemID:ID. If you want to only get the specific list item result, I suggest you use the Title column and the text BlogTitleDetail column value or RefinableString100:True.

    For test, for example, if you don't want to get the search result for News000test.docx, PowerPointFile1Old.ppt and EventDetail01.aspx, you can use the query -Path: https://contoso.sharepoint.com/sites/SearchModernList/SitePages/EventDetail01.aspx -Path: https://contoso.sharepoint.com/sites/SearchModernList/Shared%20Documents/News000test.docx -Path: https://contoso.sharepoint.com/sites/SearchModernList/Shared%20Documents/PowerPointFile1Old.ppt

    As the default search box on the top of the site can search results across the whole site and other sites, you may need to hide them on the site by scripts with SharePoint Online Management Shell and then use SharePoint PnP Modern Search Web Part to restrict the search results.

    For how to hide the default search box, you can refer to the article.

    For how to deploy the web part package in your SharePoint Online environment, you can refer to the steps in the article.

    You can create a search page for users to only search on this page>add the Search Box and the Search Results web part. In the Search Results web part, select SharePoint Search>combine all queries in one to restrict the search result scope as follows>In the Search Box web part, configure the corresponding settings as well. {SearchBoxQuery} (Path: https://contoso.sharepoint.com/sites/SearchModernList) -Path: https://contoso.sharepoint.com/sites/SearchModernList/SitePages/EventDetail01.aspx -Path: https://contoso.sharepoint.com/sites/SearchModernList/Shared%20Documents/News000test.docx -Path: https://contoso.sharepoint.com/sites/SearchModernList/Shared%20Documents/PowerPointFile1Old.ppt AND (Path: https://contoso.sharepoint.com/sites/SearchModernList RefinableString100<>NotTrue)

    After doing this, when you type RefinableString100:NotTrue in the search box, there should be no results. When you type RefinableString100:True, you can get results.

    For updating the list column value for the Choice column in your environment, you may refer to the steps in the article.

    Disclaimer: Microsoft provides no assurances and/or warranties, implied or otherwise, and is not responsible for the information you receive from the third-party linked sites or any support related to technology.

    When you search RefinableString100:True.

    When you search RefinableString100:NotTrue.

    Moreover, about that the Yes/No column may not work well in SharePoint Modern Search, I kindly suggest you submit your feedback on the SharePoint UserVoice platform to our related team directly for product improvements. If our product developers have some updates on the feedback you have submitted, they may post the updated information there as well.

    Thanks for your understanding and have a nice day!

    Cliff

    Was this answer helpful?

    0 comments No comments