Hi Shweta,
First we need to ensure that the DocumentName field is not already mapped to the Title field of the index. The easiest way to do that is to map a different field to the search title field in the page type's "Search fields" tab, like this:
Then in the search transformation, you can check the page type. If using an ASCX transformation, it would look something like below, in which Title is used for "dancinggoat.article" page types and DocumentName is used for everything else.
<%# IfCompare(GetSearchValue("ClassName"), "dancinggoat.article", GetSearchValue("DocumentName"), Eval("Title"))%>
If you have more complex logic, it might be easier to use a Text/XML transformation, so you can use macro syntax.
Mike