Skip to main content
2 of 2
spelling!
Mike Smith - MCT
  • 6.8k
  • 2
  • 14
  • 21

You would need to iterate through all of the objects:

SPFarm
   SPWebApplication
    SPSite (Site collections)
      SPWeb  (sites)
        SPList  (and filter for just libraries)

You would only be able to search in the document's metadata (name, created by, library columns, etc.) and not by keyword within the document. (Unless you want to open and parse the content of all of the files / file types.)

At the Site Collection level you use a SPSite​Data​Query CAML Query to search the Site Collection. https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-server/ms409088(v=office.15)

This would be very slow compared to a SharePoint Search. Why do you not want to call the Search API?

Mike Smith - MCT
  • 6.8k
  • 2
  • 14
  • 21