Getting PDF's to Show in SmartSearch Results with Media Link

Yoyo Bubble asked on July 11, 2018 21:07

Hello Devnet,

I’ve been researching how to get PDF’s to show in the search result and have been making good progress.

I’ve run into a bit of a snag however, the link that shows up to the PDF in the results page is linking either to the root domain (if I select content only pages pagetype) or the page itself (If I select pages pagetype). But I want it to be a direct link to the PDF.

I took a look at the root pagetype and the smartsearchresults transformation.

Is there a way to have it detect whether or not the item is a content only pagetype or pdf and then allow that to be what links?

<div style="margin-bottom: 30px;">
        <%-- Search result title --%>
            <a style="font-weight: bold" href='<%# SearchResultUrl() %>'> <!-- THIS HERE! CAN THIS CONTAIN A CONDITIONAL THAT EITHER SHOWS THE URL OR THE MEDIA LIBRARY “PDF” URL? -->
                <%#SearchHighlight(HTMLHelper.HTMLEncode(CMS.Base.Web.UI.ControlsHelper.RemoveDynamicControls(DataHelper.GetNotEmpty(Eval("Title"), "/"))), "<span style='font-weight:bold;'>", "</span>")%>
        <%-- Search result content --%>
        <div style="margin-top: 5px; width: 590px;">
            <%#SearchHighlight(HTMLHelper.HTMLEncode(TextHelper.LimitLength(HttpUtility.HtmlDecode(HTMLHelper.StripTags(CMS.Base.Web.UI.ControlsHelper.RemoveDynamicControls(GetSearchedContent(DataHelper.GetNotEmpty(Eval("Content"), ""))), false, true, " ", "@", "")), 280, "...")), "<span style='background-color: #FEFF8F'>", "</span>")%><br />
        <%-- Relevance, URL, Creattion --%>
        <div style="margin-top: 5px;">
            <%-- Relevance --%>
            <div title="Relevance: <%# Convert.ToInt32(ValidationHelper.GetDouble(Eval("Score"), 0) * 100) %>%"
                style="width: 50px; border: solid 1px #aaaaaa; margin-top: 7px; margin-right: 6px; float: left; color: #0000ff; font-size: 2pt; line-height: 4px; height: 4px;">
                <div style='<%# "background-color:#a7d3a7;width:" + Convert.ToString(Convert.ToInt32(ValidationHelper.GetDouble(Eval("Score"), 0) * 50)) + "px;height:4px;line-height: 4px;" %>'>
            <%-- URL --%>
            <span style="color: #008000">
                <%# SearchHighlight(SearchResultUrl(),"<strong>","</strong>")%>
            <%-- Creation --%>
            <span style="color: #888888; font-size: 9pt">
                <%# GetDateTimeString(ValidationHelper.GetDateTime(Eval("Created"), DateTimeHelper.ZERO_TIME), true) %>

Any help would be much appreciated.


Recent Answers

Peter Mogilnitski answered on July 11, 2018 21:36

Suggest you to have links for your pdf in a smart search index, otherwise it might be a query for every row when you displaying the results. pdf is an attachment to indexed document? There is a topic on this

0 votesVote for this answer Mark as a Correct answer

Christopher Jones answered on July 12, 2018 11:06

Verify each PDF file's "Description" in Document Properties before posting. Make sure that all PDF files have meaningful Titles, if nothing else. Add structure and proper tags to PDF files to improve the quality and appearance of search results. File-size limits may apply. Try to ensure that PDF files posted online are as small as possible, to minimize the chance that search engines will give up and fail to index the document. If you're posting scanned documents, OCR them prior to posting.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.