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

Forums / Developing with Sitefinity / SearchResult.ascx and snippet

SearchResult.ascx and snippet

18 posts, 0 answered
  1. Jan
    Jan avatar
    39 posts
    Registered:
    22 Jan 2010
    07 Dec 2010
    Link to this post
    I'm trying to change the snippet of my custom search.
    I'm guessing I'm indexing something wrong in my fieldsInfoProvider.xml but I can see this problem will be relative later also.

    I have the standard SearchResult.ascx and this is returning a <%# DataBinder.Eval(Container.DataItem, "Snippet")%>
    The problem is that the snippet code returns something like

    avstängningsventil och on/off <strong>ventil</strong>" /><meta name="Keywords" content="<strong>Ventil</strong>, ventiler <strong>...</strong>  pneumatiskt ställdon och Fieldvue DVC6200 <strong>ventil</strong> lägesställare frÃ¥n Askalon AB" src="/Libraries <strong>...</strong> ;" alt="Vanessa metalltätande on off <strong>ventil</strong> avstängningsventil handventil med växel eller ställdon frÃ¥n Tyco för Askalon AB" src="/Libraries/Content_images/Vanessa_metallt%c3%a4tande_on_off_<strong>ventil</strong> <strong>...</strong> ¶vertryck säkerhets <strong>ventil</strong> frÃ¥n Tyco för Askalon AB" src="/Libraries/Content_images/Crosby_JOS_s%c3 <strong>...</strong>

    As you can see, there is parts of html tags returned, and that is destroying the layout of the page.
    I'm figuring with the fieldsInfoProvider I can remove the meta fields
    Another possibility would be that it returned a </div> and closes a div on the page layout.

    What is the best way to handle this?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    07 Dec 2010
    Link to this post
    Hello Jan ,

    1. You can modify fields fieldsInfoProvider.xml

    2. You can modify the SearchResults control and the snippet.


    All the best,
    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
  3. Jan
    Jan avatar
    39 posts
    Registered:
    22 Jan 2010
    07 Dec 2010
    Link to this post
    Thanks, that was what I had found.
    Tried to open the lucene index in Luke and found that is did not make use of my fileds in fieldsInfoProvider.xml
    It just added content and path.

    I have a cusutom search index provider that returns a couple of urls, so the parser/indexer should be the same.
    Have I missed something vital?


    About using the event option; this is not possible.
    Say for instance we get a result that is "the end of the indexed text goes here</div><h2>Some..." from our snippet. The "</div>" will close the last <div> on the page and the <h2> will make all text after this in <h2> format...
    Not what I want to do. I want to strip all the tags and just get the text in plain format.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    07 Dec 2010
    Link to this post
    Hi Jan,

    You can use regular expresion to remove all tags from the snippet and/or parse the text.

    All the best,
    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
  5. Jan
    Jan avatar
    39 posts
    Registered:
    22 Jan 2010
    07 Dec 2010
    Link to this post
    Any idea why the fields dont show up in the index?
    they are all in the fieldsInfoProvider.xml file, but the recomended luke program (lucane index toolbox) only have a content and a path field.

    The fieldsInfoProvider.xml is autogenerated and not changed. Tried to change it but no effect.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    07 Dec 2010
    Link to this post
    Hi Jan,

    1. If you have a custom index provider - you are not adding your content to the index.
    2. You have some control/custom logic inside a control on a page that stops the crawler. You can perform a simple test with a new master template and put GenericContent control with some text  on a page that uses this template. Index the website and  search for some text you entered.

    Kind regards,
    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
  7. Jan
    Jan avatar
    39 posts
    Registered:
    22 Jan 2010
    08 Dec 2010
    Link to this post
    Hi and thanks for the answer.

    1. The content does show up in the search index. The custom index provider only returns the urls to be indexed. Sitefinity/lucane does the indexing. The fields I get is content and path
    2. This may be the case. But I tested to change fieldsInfoProvider.xml for the standard searchindexprovider, and did an index on a div with specific class. That did get indexed. Tried to move the same line to my own index, just changing the class name, without any success.

    At a point I was guessing that the controller didn't find the localization for the index crawler, but as I wrote before, the snippet returns a swedish text (the control is multilanguage)

    I have a generic control on one type of the pages, and that does not get the fields from the settings file either.

    As I said, the content gets indexed (whole page in field content) but the specific columns specified in fieldsInfoProvider.xml does not show up in index (when opened in Luke)
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    08 Dec 2010
    Link to this post
    Hi Jan,

    For content based index you can add

    • metafields
    • Content
    • item ID
    For page index - we get the HTML of the page by using
    Regards,
    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
  9. Jan
    Jan avatar
    39 posts
    Registered:
    22 Jan 2010
    09 Dec 2010
    Link to this post
    Seems like the answer been cut

    What I have done is to follow this webinar
    http://www.sitefinity.com/devnet/webinars/working-with-sitefinity-search.aspx

    What they do there is to set up a fieldsInfoProvider.xml to retrieve diffrent part of the page.
    When I modify the fieldsInfoProvider.xml for the standard sitefinity search to search for a specific div, it will be found and indexed. But for my custom search provider (provides a list of urls) the index files only result in a content and a path columns. So how do I get the searchindex to read the settings in the fieldsInfoProvider.xml and index the other fields as well?

    the index gets all the 96 pages and the content field holds the WHOLE page (including the tags)
    The search page finds the info, but I want to index only part of the page (skipping menus etc), and the simplest way to do this seems to be to filter the index by fieldsInfoProvider.xml and only index a specific part of the page.
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    09 Dec 2010
    Link to this post
    Hi Jan,

    You can try suggestions in this KB - How to customize the indexing of html documents

    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
  11. Jan
    Jan avatar
    39 posts
    Registered:
    22 Jan 2010
    09 Dec 2010
    Link to this post
    I seem to have a hard time communicating my problem.

    I have changed the fieldsInfoProvider.xml file, but the Index does not seems to load it/read it.
    The autogenerated fieldsInfoProvider.xml does not work neither!

    When I take the autogenerated fieldsInfoProvider.xml it still just get the two column in search result!
    When I modify the default search index fieldsInfoProvider.xml ,I get the expected result.
  12. Jan
    Jan avatar
    39 posts
    Registered:
    22 Jan 2010
    09 Dec 2010
    Link to this post
    I can send you my searchindex folder, and you can see for yourself? Please give me a mail to post it to

    Did a simple test and the code for the class is the following

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Framework.Search;
    using System.Collections;
    using SYSteam.Sitefinity.SitefinityPoint;
    using SYSteam.Sitefinity.SitefinityPoint.Interfaces;
     
        public class CustomTestIndexProvider : IIndexingServiceClient
        {
            #region IIndexingServiceClient Members
      
            public string Name
            {
                get { return "Test SharePoint Index"; }
            }
      
            public string Description
            {
                get { return "Test Search Sharepoint posts"; }
            }
     
            public new string[] GetUrlsToIndex()
            {
              List<string> list = new List<string>();
     
              list.Add("http://askalonweb.se/businessarea/Engineering");
               
              return list.ToArray() ;
            }
             
            public IIndexerInfo[] GetContentToIndex()
            {
                return new List<IIndexerInfo>().ToArray();
            }
             
            public void Initialize(IDictionary<string, string> indexSettings)
            {
            }
      
            public event EventHandler<IndexEventArgs> Index;
      
            #endregion
     
            IDictionary<string, string> settings;
             
        }

    I have 2 "empty" classes for handling the index in admin gui

    Once again, the content of the page get loaded into a content column, and path into a path. Title and meta ar not stored. And also, not the div with the class (but found in the content column data)
  13. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Dec 2010
    Link to this post
    Hi Jan,

    The code you use only adds three strings - urls to the index. This code cannot add any other data than these strings into the index. The <strong> tag is added by the SearchManager, because this is the search results separator. You cannot escape the separator in your code because the search results are retrieved by the manager which add it when you perform a search. You can remove the tags by replacing the content using RegularExpression that matches the tags you do not want to see.

    Regards,
    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
  14. Jan
    Jan avatar
    39 posts
    Registered:
    22 Jan 2010
    13 Dec 2010
    Link to this post
    Forget about the <strong> for now and how to recieve the correct snippet.

    Do I understand you correct when you say that if I returns Url to be indexed, the title cannot end up in the search index (lucene)?
    When I watched the webinar about search, I thought that if I returned urls these Url would be indexed by lucene and the fields/columned specified in fieldsInfoProvider.xml would end up in the search index. This is NOT the case for me. The lucene index only holds filed/column path and content.

    First question: Is this what I should expect? Can't i get for example a Title column (there is one specified in fieldsInfoProvider.xml but it does not end up in lucene index)


    The content in the lucene index does hold the whole page. I thought was that I could create other columns/fields in the index and these would handle the indexed content. But if this is not the case, then I thought I could set the index to just index the words, not the syntax. So if i search for <div> all the pages would not be found.
    Again, this is not possible you say, and what I should do is to filter the snippet by doing a regular expression to remove the tags. But wouldn't a search for <div> still hit all the pages???

    Second question: There is no way to remove the tags from the search index, and therefore a search for <div> will result in a hit on all the pages. I can filter the result displayed to the user, but not the content indexed?
  15. Jan
    Jan avatar
    39 posts
    Registered:
    22 Jan 2010
    22 Dec 2010
    Link to this post
    Do I have to create the index by myself and ignore to return the urls and instead use GetContentToIndex()
    The problem with this is that the page to be indexed as some advanced settings. The page has dynamic content (urlrewrite sends all the url I use today to same page with diffrent querystrings) and also has a query setting file (gets data from sharepoint) and template file. This will make the index hard to find since there can be data from diffrent Lists in sharepoint and the calm can be diffrent for the diffrent pages. Therefore I would like to get the standard index to work by just suppling the urls to index.
    It seems to do the job (all content gets to the index) but it does not use the fieldsInfoProvider.xml setting file to crate new columns in the lucene index.
  16. Bachar Zeidan
    Bachar Zeidan avatar
    67 posts
    Registered:
    01 Jul 2010
    22 Mar 2011
    Link to this post
    Hi,
    I've a custom controls that embeds the Youtube player at runtime, so it's possible visualize video only passing the video-ID in querystring.
    So, the content of my page Video.aspx has: the video title, the player, and some text coming from the video description.

    Now, the problem: if I search the text (taken from title or description) the index doesn't find the video page. The only result I can obtain is the empty Video.aspx page if I use the "video" word in the searchbox.

    The index always takes the html page, but seems not consider the html that my control fills in the page at runtime.

    Second: I tried to force the indicization of the video description text modifying the fieldsInfoProvider.xml adding this line:

    <field name="video" weight="1" indexAttribute="" filtertag="div" filterattributes="id:videodata" />

    where videodata is the id of the div that wraps my control.
    Occurs this problem:

    E' stata generata un eccezione. Messaggio Eccezione generata dalla destinazione di una chiamata.. Metodo o funzione :System.Object _InvokeConstructor(System.Object[], System.SignatureStruct ByRef, IntPtr). Dettaglio Errore:   in System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct& signature, IntPtr declaringType)
       in System.RuntimeMethodHandle.InvokeConstructor(Object[] args, SignatureStruct signature, RuntimeTypeHandle declaringType)
       in System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       in System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
       in System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
       in Telerik.Search.Engine.Crawler.GetIndexer(String key, Dictionary`2 indexers, String provider, Boolean appendToIndex)
       in Telerik.Search.Engine.Crawler.IndexContent(String provider, LinkedList`1 data, Boolean appendToIndex, Dictionary`2 indexers)
       in Telerik.Search.Engine.Crawler.Index(String provider, String[] urls, LinkedList`1 data, Boolean appendToIndex)
       in Telerik.Search.Engine.IndexingManager.StartIndexing(IIndexingService service, Boolean appendToIndex)
       in Telerik.Search.Engine.IndexingService.Index(Boolean appendToIndex)
       in Telerik.Search.WebControls.Admin.ControlPanel.Service_Command(Object sender, CommandEventArgs e)
       in System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
       in System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
       in System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       in System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       in System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       in System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    System.Reflection.TargetInvocationException: Eccezione generata dalla destinazione di una chiamata. ---> System.NullReferenceException: Riferimento a un oggetto non impostato su un'istanza di oggetto.
       in Telerik.Search.IndexFieldsProvider.Load(String infoPath)
       in Telerik.Search.IndexFieldsProvider.Load()
       in Telerik.Search.Engine.HtmlIndexer..ctor(String directory, String provider, Boolean appendToIndex)
       --- Fine dell'analisi dello stack dell'eccezione interna ---
       in System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct& signature, IntPtr declaringType)
       in System.RuntimeMethodHandle.InvokeConstructor(Object[] args, SignatureStruct signature, RuntimeTypeHandle declaringType)
       in System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       in System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
       in System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
       in Telerik.Search.Engine.Crawler.GetIndexer(String key, Dictionary`2 indexers, String provider, Boolean appendToIndex)
       in Telerik.Search.Engine.Crawler.IndexContent(String provider, LinkedList`1 data, Boolean appendToIndex, Dictionary`2 indexers)
       in Telerik.Search.Engine.Crawler.Index(String provider, String[] urls, LinkedList`1 data, Boolean appendToIndex)
       in Telerik.Search.Engine.IndexingManager.StartIndexing(IIndexingService service, Boolean appendToIndex)
       in Telerik.Search.Engine.IndexingService.Index(Boolean appendToIndex)
       in Telerik.Search.WebControls.Admin.ControlPanel.Service_Command(Object sender, CommandEventArgs e)
       in System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
       in System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
       in System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       in System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       in System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       in System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    What's the problem.
    Best regards,
    Bachar
  17. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    24 Mar 2011
    Link to this post
    Hi ,

    The field attributes are case sensitive

    filterTag="title" filterAttributes=""

    Please modify them properly. Also I cannot translate the error from the stack trace.

    Regards,
    Ivan Dimitrov
    the Telerik team
  18. Jan
    Jan avatar
    39 posts
    Registered:
    22 Jan 2010
    11 Jan 2012
    Link to this post
    Long time and now back to this problem (Sitefinity 3.7 SP3)
    I try to explain what I got and what the problem is and see if you can help me

    1.
    I have a custom search index, that is indexing some dynamic generated pages. This is working fine and I have created a IIndexerInfo class that on the public byte[] GetData() function does a HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create(Url); and does a regular expression to remove html tags etc.

    2. 
    I have the default searchindex combined with my custom on the search-section in admin

    3.
    When I run the index I get all the pages Indexed to my lucene index. Opened in Luke (http://www.getopt.org/luke/) i can see what's indexed.
    But ALL pages from (2) have empty content fields. The description, guid, keywords all works fine. Path I don't know. I get a path like this {sv}~/about/business
    For all the pages in (1) i set the path by myself and later call it so I can't say if this culture tag in path is correct or not.

    image1 = an indexed page from sitefinity (2)
    image2 = an indexed page from dynamic page

    Since I don't get any data in content the snippet on searchresult is showned as ... and the only match I can get is on keywords/descriptions.

    Another this (as seen in attachments) is that the sitefinity pages has 2 empty content tags and the other page has only one.


    An additional question: When I return the whole page from GetData() function in my IIndexerInfo class, will that data be handled by the lucene engine and (if I don't strip all the html tags and header tags) will be parsed by the settings in fieldsInfoProvider.xml file
Register for webinar
18 posts, 0 answered