In SharePoint 2013 OnPremise, we had one requirement recently to show the comments and likes count with each blog post in the content search web part. We have two different Sharepoint Web Applications (different domains with different AD), and we were required to show this web part on both these applications' front pages. Also one important thing to note is that we have only one “Mysite” for both the applications.
Based on the customer requirement, first we implemented this only for the first web application.
During this implementation, we found that likes count implementation was pretty straightforward (using “LikesCount” managed property, in display template, mapped to “ows_LikesCount” crawled property). The continuous or incremental crawl updates this property correctly (for continuous crawl it takes around a three minute interval to update).
But we found that this wasn’t the case with the comments crawled property “ows_NumComments.” Though we created a managed property for it, say NumComments, it still wasn’t updating the comments counter after continuous or incremental crawls. It requires a full crawl all the time to update the counter. We also found this issue mentioned here.
Comments counter (# Comments) column is not created as Site Column. It is local in posts library.
To set it in full crawl, we can set “My Site” in new content source and set it to run every three or “x” mins.
But setting a full crawl for updating only one field wasn’t our choice that time (considering performance overhead for whole application) so we decided to fetch the comments count with the help of REST calls from the display template. For this to work with cross site (“My Site” was in a different domain), we had to add few entries in web.config of “My Site” to allow cross domain requests from single calling domain:
- <configuration>
- <system.webServer>
- <httpProtocol>
- <customHeaders>
- <add name="Access-Control-Allow-Origin" value="<http://calling-domain>" />
- <add name="Access-Control-Request-Method" value="GET,POST,HEAD,OPTIONS" />
- <add name="Access-Control-Request-Headers" value="Content-Type,Authorization" />
- <add name="Access-Control-Allow-Credentials" value="true" />
- <add name="Access-Control-Allow-Origin" value="*" />
So we decided to again give it a thought on our first approach of using Managed Property for Comments count for only this second application. As in this second application, blog posts are only coming from “My Site” so there was no need to do a full crawl for the whole second application and it was needed for only “My Site.” So it was a considerable case for full crawl as we have to do it only for “MySite” and not for those main sites with huge contents and libraries.
We created a new managed property “NumComments” for “ows_NumComments” crawled property and then created a new Content Source which had full crawl scheduled to run for every ‘x’ minutes interval or so. We have assigned only “MySite” reference in new content source and scheduled to run it for every 30 minutes. Earlier we thought it would be a performance overhead, but since we have to do full crawl for only “MySite,” it shouldn’t be a problem.
We kept the approach of using the REST call for the first application, as it is as there were posts from both the first application and “My Site” as well. So it was not convenient to allow a full crawl fo the first application because of the huge contents.
Conclusion
So we had to use this mixed approach for fulfilling our requirement (especially for showing the comments count) for both applications.
For the first application, we used the REST call approach for fetching comments count from the comments list (by adding above Access-Control-Allow-Origin entries in web.config in “MySite,” which works well for a single domain).
For the second application, we used the full crawl technique (for only “MySite” set to full crawl) where 30 mins crawling schedule is set for updating NumComments managed property and then showsthe correct number in webpart.
I hope this will help someone struggling to overcome a similar situation.
Happy Learning!

Rupali ShindePosted Feb 23, 2016, 5:21 AM
thanks for sharing
Sibeesh VenuPosted Feb 18, 2016, 12:11 AM
Nice Share
Humayun Kabir MamunPosted Feb 16, 2016, 10:55 PM
Nice...
Sr KarthigaPosted Feb 16, 2016, 10:19 PM
Nice explanation
Santhakumar MunuswamyPosted Feb 16, 2016, 2:51 PM
Thanks for nice work
Vignesh ManiPosted Feb 16, 2016, 11:53 AM
Nice one
Abhay ShankerPosted Feb 16, 2016, 2:54 AM
Nice Share
Prasham SabadraPosted Feb 15, 2016, 11:27 AM
Thanks Shriram for sharing this :)