ASPX templates
Version 6.x > ASPX templates > How to show content in smartsearch result? View modes: 
User avatar
Member
Member
hungquang_itsyad-yahoo.com - 10/5/2012 4:28:48 AM
   
How to show content in smartsearch result?
Hi all,

I using code below to show smartsearch result.
<p><%#SearchHighlight(CMS.GlobalHelper.HTMLHelper.HTMLEncode
(TextHelper.LimitLength(HttpUtility.HtmlDecode
(CMS.GlobalHelper.HTMLHelper.StripTags
(CMS.ExtendedControls.ControlsHelper.RemoveDynamicControls
(GetSearchedContent
(DataHelper.GetNotEmpty(Eval("Content"), ""))),
false, " ")), 280, "...")), "
<span style='background-color: #FEFF8F'>",
"</span>")%><br /></p>

Document type: CMS.Root
Transformation name: SmartSearchResultsWithImages

But in my result, content don't display.
What's problem in my source?

Thank!

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 10/7/2012 10:16:46 AM
   
RE:How to show content in smartsearch result?
Hello,

Could you please post a picture of the Smart search fields configuration for the document type, which should be displayed in the transformation? Please also make sure, you've everything configured according to this documentation.

Best regards,
Boris Pocatko

User avatar
Member
Member
hungquang_itsyad-yahoo.com - 10/7/2012 8:55:18 PM
   
RE:How to show content in smartsearch result?
CMS.Root.SmartSearchResultsWithImages:
<div class="mini-content">
<div style="float: left">
<img src="<%# GetSearchImageUrl("~/App_Themes/Default/Images/CMSModules/CMS_SmartSearch/no_image.gif",90) %>" alt="" />
</div>
<div class="right-content">
<a style="font-weight: bold" href='<%# SearchResultUrl(true) %>'>
<%#SearchHighlight(CMS.GlobalHelper.HTMLHelper.HTMLEncode(CMS.ExtendedControls.ControlsHelper.RemoveDynamicControls(DataHelper.GetNotEmpty(Eval("Title"), "/"))), "<span style='font-weight:bold;'>", "</span>")%>
</a>
<%-- Relevance --%>
<div title="Relevance: <%#Convert.ToInt32(ValidationHelper.GetDouble(Eval("Score"),0.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.0)/2)*100)) + "px;height:4px;line-height: 4px;"%>">
</div>
</div>

<p><%#SearchHighlight(CMS.GlobalHelper.HTMLHelper.HTMLEncode(TextHelper.LimitLength(HttpUtility.HtmlDecode(CMS.GlobalHelper.HTMLHelper.StripTags(CMS.ExtendedControls.ControlsHelper.RemoveDynamicControls(GetSearchedContent(DataHelper.GetNotEmpty(Eval("Content"), ""))), false, " ")), 280, "...")), "<span style='background-color: #FEFF8F'>", "</span>")%><br /></p>
<div style="margin-top: 5px;">
<%-- URL --%>
<span style="color: #008000">
<%# TextHelper.BreakLine(SearchHighlight(SearchResultUrl(true),"<strong>","</strong>"),75,"<br />") %>
</span>
<br />
<%-- Creation --%>
<span style="padding-left:5px;color: #888888; font-size: 9pt">
<%# GetDateTimeString(ValidationHelper.GetDateTime(Eval("Created"), DateTimeHelper.ZERO_TIME), true) %>
</span>
</div>
</div>
</div>
<hr align="center" width="90%" size="1px" style="margin-bottom:10px;"></hr>

User image

User image


I thought everything was fine, but I do not know why not display the content.
Please help me!

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 10/20/2012 3:38:50 PM
   
RE:How to show content in smartsearch result?
Hi,

I think that the problem is the way you are working with Search results in transformations. Please, take a look at this article from the DevGuide, you will then realize that the key is GetSearchValue(string columnName).

So don’t use <%#Eval()%> – this won’t work in most cases as the items being returned aren’t the actual Documents but the Search Result items, which don’t have the correct things to bind for your Evals. You should use <%#GetSearchValue()%> which will provide you what you want.

Do you have enabled Smart search indexing?
You also need to create a Smart Search index.

I would recommend you to watch a video about: Smart Search in Kentico to understand in more details how the Smart Search works and how to configure it properly.

Best regards,
Martin Danko

User avatar
Member
Member
lokendra.jain-anktech.co - 5/10/2013 9:55:48 AM
   
How the most relevant sort works.
Suppose i am search for the 001 and i have 3 records which have 001
when i am sorting the records using ## Score## it is showing the % in result.
When two of the records have the same number of occurance for the 001, it is showing different results for both in %. for example it is showing 62% for one and 54% for second.

Can you please explain the logic how the most relevant sorting works.

Thanks
Lokendra jain

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 5/11/2013 1:30:02 AM
   
RE:How the most relevant sort works.
Hi,

Please see this FAQ to understand how the score and relevance is computed by Lucene.Net.

Best regards,
Juraj Ondrus