I was working on a custom search (Full Text Search) web part when at a point I came to know that managed property of a Publishing HTML field is returning just Text (simple) not actual HTML saved in that field. Whereas client requirement was to show formatted text with hyperlinks etc. in the web part. Initially I thought that there might be something wrong with either crawl or managed property for the field. However, I ran some tests and figured out that there is nothing wrong with crawl or managed property. So only other thing was, may be there was something wrong the way I setup/created Publishing HTML field.

For testing purpose, I created a new Publishing HTML field add some contents in that field, create crawl and managed properties then did a search against that new property and I was surprised new property was returning HTML instead of simple text… see screenshots below;

  1. Added contents in both fields (having some bold, underline text)
    image    
  2. Ran incremental crawl and see following results in the custom web part (I had already changed the web part query and XSLT to show both fields in the web part)

    image 
    In this screenshot you can see Test Additional Text (New Field) is showing formatted text but Additional Text (Actual Field) is showing simple text.
  3. Then I ran same query in SPQuery Tool and got following results that described the difference in both fields.
    image 
    In this screenshot you can see Additional Text is returning just Text whereas Test Additional Text field is returning html.
  4. Now this was confusing for me; apparently I wasn’t able to see any difference the way both fields, crawl and managed properties were being created. But then I got the difference and that was Face value of both field is different in the List view form.
    image
    May be some of you are thinking that AllItems.aspx looks ugly but in my case only Site Owners and Administrators can go to this page, all other users see results in the custom search web part on home page. 
  5. So yeah! I got the clue; actually problem was Crawler crawls face value/text not the hidden value/text that’s why I was facing that problem. But as I mentioned earlier there wasn’t any difference the way both fields were created.
  6. I wrote a utility to compare all of properties of both fields --- Hurray :), I found something; that is RichText property of Additional Text is set to true, which make sense to show a nice and pretty view on AllItems.aspx page but as mentioned I wasn’t worried about AllItems.aspx.
    image 
  7. I wrote following lines of code to set RichText property to False.

    Microsoft.SharePoint.Publishing.Fields.HtmlField field = (Microsoft.SharePoint.Publishing.Fields.HtmlField)list.Fields["Additional Text"];
    field.RichText = false;
    field.Update();

  8. Finally! my web part shows formatted text instead of simple text.
    image 

I hope this can save someone’s bunch of time who is facing same kind of problems with publishing fields :).