Customizing Search Results

Posted by Community Admin on 04-Aug-2018 20:29

Customizing Search Results

All Replies

Posted by Community Admin on 12-Mar-2012 00:00

I have the problem that my search results show stuff they should not

a) options from a dropdown
b) breadcrumb text of the backend informing you that it can not show the breadcrumb

Of course the most appropriate thing to show like any search engine would be the description of the page. Can this be done? the Design Widget does not show any fields.

If it's not possible out of the box shouldn't it be? Well Google uses the decription in the serach results why should SF not?

Markus

Markus

Posted by Community Admin on 14-Mar-2012 00:00

anyone?

Markus

Posted by Community Admin on 15-Mar-2012 00:00

Hello Markus,

When indexing the page's static HTML we render the page in the memory, so what we operate with is the pure HTML that will be passed to the browser. However there might be certain controls on your page hat you'd like to exclude from being indexed. For such cases we've recently released a blog post demonstrating how you can develop a layout control which, when placed on a page, any widget you put in it will be properly displayed however will not be picked up by the search index.

Kind regards,
Boyan Barnev
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 15-Mar-2012 00:00

Dear Boyan
I see the text of the SF Navigation Breadcrumb widget like when its in edit mode. I hope I don't have to customize the result of a SF nativ widget.

How about the question on displaying the description in the widget as text for the search result. How can I do this, and should this not be default?

Because then you would not have to worry about having to look at blogpost to get decent search results displayed. Indexing I don't mind. Just diplaying it :-)

Markus

Posted by Community Admin on 20-Mar-2012 00:00

Hello Markus,

Please note that not all Content items might have their Description field filled in, and the search functionality is the same for all Sitefinity content. In addition, the search index keeps Lucene documents which serve as pointers to the actual Sitefinity content item, so the document itself does not know about the Description field of the content item until you get the actual content item with the corresponding manager, that's why you'll need to customize the template a little bit.

Regards,
Boyan Barnev
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 20-Mar-2012 00:00

Dear Boyan

I might not understand you correct. I don't realy mind whats beeing index if the description is indexed as well or not.
What I would like to know is how to display the page description in the search results.

Markus

Posted by Community Admin on 23-Mar-2012 00:00

@anyone
How do I display the Description entered under Titles & Properties in the the search results template?
Markus

Posted by Community Admin on 29-Mar-2012 00:00

@all

Still open for any sugestions :-)
Markus

Posted by Community Admin on 03-Apr-2012 00:00

Hi Markus,

I apologize for getting back to this thread with a delay. As discussed previously, getting the Page "Description"
field on the search results template is not that trivial. In other words it's not about writing and Eval() statement for "Description" in the markup and the results dispalying the page description. Why is that so? - because our search functionality needs to
1. Provide fast indexing
2. return the results quickly
3. be compatible with all content types, so you don't have 10+ Search results for "this content type" widgets to select from.

Because of the above, the documents returned when you perform a search are nto the actual content items the URLs in the search results point to, they are just a "stripped-down pointer" to the real item, and it points using the original item ID and URL. That being said, it is not impossible to modify the search results to return whatever you want it to return, and implementing it is quite easy actually. Since you already have the original item ID you can just say PageManager.GetPage(ID) and then get the Description and display it on the template. For example, if you copy the default SearchResults template:

<%@ Control Language="C#" %>
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sitefinity" %>
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Services.Search.Web.UI.Public" TagPrefix="sfSearch" %>
 
<sfSearch:SearchBox ID="topSearchBox" runat="server" />
 
<sitefinity:SitefinityLabel id="resultsStats" runat="server" WrapperTagName="p" CssClass="sfsearchResultStatistics" Text="<%$Resources:SearchResources, SearchResultsStatusMessage %>" />
 
<asp:Repeater ID="resultsList" runat="server">
    <HeaderTemplate>
        <dl class="sfsearchResultsWrp sfsearchReultTitleSnippetUrl">
    </HeaderTemplate>
    <ItemTemplate>
        <dt class="sfsearchResultTitle"><a runat="server" href='<%# Eval("Link")%>'><%# Eval("Title") %></a></dt
        <dd class="sfsearchResultSnippet"><%# Eval("Summary")%></dd>
        <dd class="sfsearchResultUrl"><a runat="server"  href='<%# Eval("Link")%>'><%# Eval("Link")%></a></dd>
        <dd class="sfsearchResultHighLighter"><%# Eval("HighLighterResult")%></dd>
    </ItemTemplate>
    <FooterTemplate>
        </dl>
    </FooterTemplate>
</asp:Repeater>
<sitefinity:Pager ID="pager" runat="server" />
<sfSearch:SearchBox ID="bottomSearchBox" runat="server" />
 in a new UserControl, and in the code behind subscribe to the ItemDataBound event of the Repeater we're using for displaying the returned results you could say:
protected void Page_Load(object sender, EventArgs e)
        
            this.resultsList.ItemDataBound += new RepeaterItemEventHandler(resultsList_ItemDataBound);
        
 
        void resultsList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        
            var myitem = e.Item.DataItem as Document;
             var type = myitem.GetValue("ContentType");
            //You need to check for the type of the item you have gotten in your search results
            //here we're checking if the item is a Page:
            if (TypeResolutionService.ResolveType(type) == typeof(PageNode))
            
                var ID = new Guid(myitem.GetValue("OriginalItemId"));
                //you can now get the item with its manager and access its properties,
                //since you'll be working with an object of the correct type
                //for example:
                var manager = PageManager.GetManager();
                var page = manager.GetPageNode(ID);
                var description = page.Description;
            
        
The you can simply place a new Literal on the template and set its value to be the page description

Regards,
Boyan Barnev
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 03-Apr-2012 00:00

Dear Boyan

Thank's for comming back so detailed (more then I expect). I did not think about it that other types then pages might be indexed which do not have a page description.

I will give your solutino a try. Well you chew it our for me so I am sure it works :-)

Thank's again

Markus

PS: Still think pages should return the decription by default ;-)

Posted by Community Admin on 05-Sep-2012 00:00

Along these lines, I want to exclude content items that reside within my template (ie. header and footer content). If I search for a term that is in my header or footer (defined at the template level), I get every single page returned as a result, rather than the one page that is actually applicable.

Any ideas?

This thread is closed