Share via

Filter list and items in Microsoft Search API

captain_atharv 511 Reputation points
2022-11-03T11:05:44.48+00:00

Hi,
I'm using Microsoft Search API (https://learn.microsoft.com/en-us/graph/api/search-query?view=graph-rest-1.0).
I'm trying to filter out folders from my search results. On using 'ContentType:Document' in queryString, I'm able to filter out folders but I'm not receiving list items.
Is there a way to filter out only folders? I want my search to return Documents and Lists only.

Microsoft 365 and Office | SharePoint | Development
Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,496 Reputation points Microsoft External Staff
    2022-11-07T06:23:25.74+00:00

    Hi @captain_atharv ,
    Per my test, I do agree with SrinivasaRaoDarna-MSFT's answer. You will need to use "entityTypes": ["listItem"] to return list items. But if you set ContentType:Document in queryString. It will filter out list items too. So we are unable to filter documents and list items in a query currently.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



  2. Srinivasa Rao Darna 6,846 Reputation points Microsoft External Staff
    2022-11-03T11:41:49.417+00:00

    Hello @captain_atharv ,

    As I understand your query, ContentType:Document refers to files "entityTypes": ["driveItem"], and ContentType:Item will be returning listItems "entityTypes": ["listItem"].

    Hope this helps.
    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.