Using CSOM Search API is there a way to filter for only files? Something similar to the following ListItem filter would be ideal:


Ex use case:

if (item.FileSystemObjectType.Equals(FileSystemObjectType.File))
    // do stuff

The only thing similar I have found in documentation would be using the filetype Keyword Query Language (KQL) filter:


I'd like to avoid using that, however, as setting all the possible valid file types feels like a sloppy solution IMO. Thanks for any feedback!

1 Answer 1


You can use IsDocument managed property to filter out the list items. The search Get API should look like this


apart from IsDocument managed property you can also use

  1. contentclass:STS_ListItem_DocumentLibrary - if you want to search within document libraries only
  2. contenttype:CONTENT_TYPE_NAME - if you want to search documents for particular content type.
  • 1
    Thanks, IsDocument should work perfectly for my use case and a clean solution. Just to note for other users I am using CSOM so would be 'IsDocument:1' in this case.
    – seanrco
    Commented Jul 7, 2021 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.