Microsoft Graph API Search KQL contentclass not filtering

Viewed 187

I want to use the search endpoint of the Microsoft Graph API to search for documents that reside in all SharePoint sites. I am using the query:

{
"requests": [
    {
        "entityTypes": [
            "listItem"
        ],
        "query": {
            "queryString": "a contentclass:STS_ListItem_DocumentLibrary"
        },
        "fields": [
            "id",
            "name",
            "contentclass",
            "title"
        ]
    }
]
}

My understanding is that this query will get me all list items that contain the keyword "issue" and have the content class as STS_ListItem_DocumentLibrary. But in my results I am getting results from STS_ListItem_MySiteDocumentLibrary and STS_ListItem_GenericList.

My search endpoint is:

https://graph.microsoft.com/v1.0/search/query 

version is: 1.0

1 Answers

According this contentclass:STS_ListItem_DocumentLibrary queries Documents, Shared Documents, Form Templates, Site Assets, Site Collection and Documents Libraries creating using “Document Library” template.

If you want to list documents only you can specify isDocument:true in queryString.

{
 "requests": [
   {
     "entityTypes": [
        "listItem"
     ],
     "query": {
        "queryString": "issue contentclass:STS_ListItem_DocumentLibrary and isDocument:true" 
     },
     "fields": [
        "id",
        "name",
        "contentclass",
        "title"
     ]
   }
 ]
}
Related