1

I have a few site collections and I would like to retrieve the content types of each site collection and display them as a list and I was wondering if it can be achieved using search api?

2
  • Why do you want using exactly Search API? Please provide some details of your ask. May be it would be better to use CSOM or smth. else.
    – AlexZh
    Jul 5, 2018 at 12:41
  • Because I am working with search and I would like to know if it can be done. Instead of going through other apis. Jul 5, 2018 at 12:43

2 Answers 2

2

only in a very convulted way... Search is not indexing contenttypes as objects.

You would need to pull all items from the Sitecollection and iterate over them, extracting all contenttypes. Which would not help you at all, since there is no info about them in the result (besides names and ID's)

The proper solution would be to pull them from the REST Service under the URL

/teams/yourSite/_api/Web/ContentTypes

3

No, it cannot be done. If a content type does not have any data associated with it, the search index will never know it exists.

There are other ways to do it, but Search is not the right tool for this job.

2
  • 1
    +1 - I didn't think about the non data case ;) Jul 5, 2018 at 13:55
  • thanks Derek for your answer. I was aware of the non-data thing. I like your answer , but I want to give this to Heiko as he answered first. Sorry ;) Jul 5, 2018 at 14:18

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.