Wednesday, October 12, 2016

Search Query by ContentType name issue

I ran into very weird issue in SharePoint Search while querying the items using ContentType name.

Query: ContentType={content type NAME}

This was giving me the result of content type, however some extra data/results where coming along in the result. There was no clue what is failing there.

Spent few hours and got very useful tip from Search Guru, MIKAEL SVENSON  that not to use ContentType but to replace that with SPContentType.

Modified Query: SPContentType={content type NAME}

Learning: We should use SPContentType instead of ContentType. As Contenttype also includes the mime type and not just the name and may cause issues. SPContentType only stores the name.

I hope this small piece of information will save your time!