1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Search results are wrong

Search results are wrong

12 posts, 0 answered
  1. Steven Lancaster
    Steven Lancaster avatar
    82 posts
    Registered:
    06 Nov 2009
    29 Jan 2010
    Link to this post
    I have a page called HitANerve.aspx that shows a list of all my blog posts. When I set the Indexes for search I want it to return to the page that actually holds the post which the code is:
                    <asp:HyperLink ID="hplTitle" NavigateUrl='<%#string.Format("~/Comments/{0}.aspx?searchid={1}",DataBinder.Eval(Container.DataItem, "URL"),DataBinder.Eval(Container.DataItem, "ID")) + "&nocomments=true"%>' runat="server">  
                        <asp:Literal ID="Title" runat="server"></asp:Literal>&nbsp;&nbsp;<asp:Image ID="Thumbnail" runat="server" imagealign="right" /></asp:HyperLink> 
     
    I want it to return those same results in my search engine. Do you have sample code where I can set that up for the searches.

    -Steve
  2. Steven Lancaster
    Steven Lancaster avatar
    82 posts
    Registered:
    06 Nov 2009
    29 Jan 2010
    Link to this post
    Can someone Please point me to an article about changing Search Functionality?
  3. Steven Lancaster
    Steven Lancaster avatar
    82 posts
    Registered:
    06 Nov 2009
    29 Jan 2010
    Link to this post
    Please Help!!
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    01 Feb 2010
    Link to this post
    Hi Steven Lancaster,

    1. You need to include the content item ID to the SearchResult item. You can append the content item ID to the snippet. Then you can add the Hyperlink inside your template and change its NavigateUrl.

    2. You can modify ~/Sitefinity/ControlTemplates/Search/SearchResult.ascx

    •  edit ~/App_Data/Search/YOUR SEARCH NAME HERE/fieldsInfoProvider.xml to add blog id in the results snipper
       
    <?xml version="1.0" encoding="utf-8"?>
    <fields>
      <field name="ID" weight="1" indexAttribute="" filterTag="GUID" filterAttributes="" />
    <field name="keywords" weight="1" indexAttribute="content" filterTag="meta" filterAttributes="name:keywords;" />
      <field name="keywords" weight="1" indexAttribute="content" filterTag="meta" filterAttributes="name:keywords;" />
      <field name="description" weight="1" indexAttribute="content" filterTag="meta" filterAttributes="name:description;" />
      <field name="script" weight="-1" indexAttribute="" filterTag="script" filterAttributes="" />
      <field name="style" weight="-1" indexAttribute="" filterTag="style" filterAttributes="" />
    </fields>
    • add hyperlink to the Repeater
    • get the snipper and extract the content item ID
    • set the navigate url.
    protected void Page_Load(object sender, EventArgs e)
    {
        this.rptResults.ItemDataBound += new RepeaterItemEventHandler(rptResults_ItemDataBound);
         
    }
     
    void rptResults_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
     
            HyperLink addLink = (HyperLink)e.Item.FindControl("Link1");
             
            Telerik.Search.Engine.ResultItem resultITem = e.Item.DataItem as Telerik.Search.Engine.ResultItem;
            string value = resultITem.Snippet;
            //this is the id of the item
            string ID = value.Substring(0, 36);
            // form the navigate url of the Hyperlink
            if (addLink != null)
            {
                addLink.NavigateUrl = "HERE FORM THE URL";
            }
     }

    <asp:Repeater ID="rptResults" runat="server">
        <HeaderTemplate>
            <dl class="searchResults">
        </HeaderTemplate>
        
        <ItemTemplate>
           
            <dt><strong><a href='<%#DataBinder.Eval(Container.DataItem, "Url")%>'><%#DataBinder.Eval(Container.DataItem, "Title")%></a></strong></dt
            <%--<dd><%#DataBinder.Eval(Container.DataItem, "Snippet")%></dd>--%>
            <dd><asp:Literal ID="Literal1" runat="server"></asp:Literal></dd>
            <dd><em><a href='<%#DataBinder.Eval(Container.DataItem, "Url")%>'><%#DataBinder.Eval(Container.DataItem, "Url")%></a>
                        </em></dd>
             <asp:HyperLink runat="server" ID="Link1" ></asp:HyperLink>          
        </ItemTemplate>
        <FooterTemplate>
            </dl>
        </FooterTemplate>
    </asp:Repeater>



    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Steven Lancaster
    Steven Lancaster avatar
    82 posts
    Registered:
    06 Nov 2009
    09 Feb 2010
    Link to this post
    protected void Page_Load(object sender, EventArgs e)
    {
        this.rptResults.ItemDataBound += new RepeaterItemEventHandler(rptResults_ItemDataBound);
           
    }
       
    void rptResults_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
       
            HyperLink addLink = (HyperLink)e.Item.FindControl("Link1");
               
            Telerik.Search.Engine.ResultItem resultITem = e.Item.DataItem as Telerik.Search.Engine.ResultItem;
            string value = resultITem.Snippet;
            //this is the id of the item
            string ID = value.Substring(0, 36);
            // form the navigate url of the Hyperlink
            if (addLink != null)
            {
                addLink.NavigateUrl = "~/Comments/{0}.aspx?searchid={1},DataBinder.Eval(Container.DataItem, 'URL'),DataBinder.Eval(Container.DataItem, 'ID') %>";
            }
     }
      
    }

    I have the above code and it is returning:

    http://dev.thenerve.org/Comments/%7B0%7D.aspx?searchid={1},DataBinder.Eval(Container.DataItem, 'URL'),DataBinder.Eval(Container.DataItem, 'ID') %>

    Is what it is returning. Why is it not evaluating my DataBinder?

     

     

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    09 Feb 2010
    Link to this post
    Hello Steven Lancaster,

    1. You have some symbols like " %>" in your code.

    2. You could try doing something like this

    sample code

    // sample code
    DataListItem container = ( DataListItem ) link.NamingContainer;
    link.NavigateUrl = Convert.ToString ( DataBinder.Eval ( ( ( DataListItem ) container ).DataItem,
    "Url" ), CultureInfo.CurrentCulture );
    link.Target = "_blank"

    3. You can get the content id and its url using the ContentManager instead DataBinder which you use on the server.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  7. Steven Lancaster
    Steven Lancaster avatar
    82 posts
    Registered:
    06 Nov 2009
    09 Feb 2010
    Link to this post
    I have tried this multiple times and still can not get the results I want. So let me show the results I want are:

    /Comments/10-02-09/The_State_s_Secret_7_Billion_Budget.aspx?searchid=6169c9f8-3202-405b-9686-d9e99a956d30

    The Results I am getting are:

    /HitANerve/10-01-13/The_Okatie-Boeing_Connection.aspx

    Can you try and see if you can make the search feature give these results?

    This is ver frustrating and I really appreciate all your help. Your awesome Ivan!!

    -Steven

  8. Steven Lancaster
    Steven Lancaster avatar
    82 posts
    Registered:
    06 Nov 2009
    10 Feb 2010
    Link to this post
    Ivan can you help this is really killing me!!


    Thank you!

    -Steven
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    10 Feb 2010
    Link to this post
    Hello Steven Lancaster,

    Below is the code that you should use

    Telerik.Search.Engine.ResultItem resultITem = e.Item.DataItem as Telerik.Search.Engine.ResultItem;
               string value = resultITem.Snippet;
               string ID = value.Substring(0, 36);
     
               HyperLink navLink = new HyperLink();
               navLink.Text = resultITem.Title;
               navLink.Target = "_blank";
               navLink.NavigateUrl = resultITem.Url + "?searchID=" + ID;
               Controls.Add(navLink);

    The hyperlink NavigateUrl will look as shown below

    http://domain.com/SomePage/10-02-03/SomeArticleSinglePage.aspx?searchID=c2ed11d7-28e2-40e2-875c-e054dda9316e


    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  10. Steven Lancaster
    Steven Lancaster avatar
    82 posts
    Registered:
    06 Nov 2009
    11 Feb 2010
    Link to this post
    I have the following code  (see Below):

    I am getting the following results:
    /HitANerve/10-01-13/The_Okatie-Boeing_Connection.aspx?searchID= onion, a connection exists between

    I need to get the Following:

    /Comments/10-01-13/The_Okatie-Boeing_Connection.aspx?searchid=9a010f39-4e47-41c0-9522-dcf4086a3914


    What is wrong with my code and how come I can't get the results I am looking for?


    <br /><asp:HyperLink ID="Link1" runat="server">test</asp:HyperLink> <br />




    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using Telerik.News.WebControls;
    using Telerik.Cms.Web;
    using Telerik.Cms.Engine;
    using Telerik.Cms.Engine.ContentViewFiltering;
    using System.Collections;
    using Telerik.Blogs;
      
    public partial class Sitefinity_ControlTemplates_Search_SearchResult : System.Web.UI.UserControl
    {
    protected void Page_Load(object sender, EventArgs e)
    {
        this.rptResults.ItemDataBound += new RepeaterItemEventHandler(rptResults_ItemDataBound);
           
    }
       
    void rptResults_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
       
            HyperLink addLink = (HyperLink)e.Item.FindControl("Link1");
               
            Telerik.Search.Engine.ResultItem resultITem = e.Item.DataItem as Telerik.Search.Engine.ResultItem;
            string value = resultITem.Snippet;
            string ID = value.Substring(0, 36);
      
            HyperLink navLink = new HyperLink();
            navLink.Text = resultITem.Title;
            navLink.Target = "_blank";
            navLink.NavigateUrl = resultITem.Url + "?searchID=" + ID;
            Controls.Add(navLink);
      
            if (addLink != null)
            {
                addLink.NavigateUrl = resultITem.Url + "?searchID=" + ID;
            
     }
      
    }
    }




  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    11 Feb 2010
    Link to this post
    Hello Steven Lancaster,

    Check wheat is returned in this line string ID = value.Substring(0, 36);
    Most probably you have problem with your snippet and the content ID is not there.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  12. Steven Lancaster
    Steven Lancaster avatar
    82 posts
    Registered:
    06 Nov 2009
    11 Feb 2010
    Link to this post
    I added the following to my  FileProvider.XML file:

    <field name="ID" weight="1" indexAttribute="" filterTag="GUID" filterAttributes="" />



    Should that not add it to the snippet? If  not how do I add it on the Search feature to pull it?

    Also how do I have the string take out the: HitANerve and change it to Comments

    I am getting the following results:
    /HitANerve/10-01-13/The_Okatie-Boeing_Connection.aspx?searchID= onion, a connection exists between

    I need to get the Following:

    /Comments/10-01-13/The_Okatie-Boeing_Connection.aspx?searchid=9a010f39-4e47-41c0-9522-dcf4086a3914
Register for webinar
12 posts, 0 answered