More in this section

Forums / Developing with Sitefinity / Search Index not finding pages with shared generic content

Search Index not finding pages with shared generic content

11 posts, 0 answered
  1. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    14 May 2010
    Link to this post
    Hi have searched the forums for this but have not found I think what I am looking for.

    I have created a search index of my site. It returned for example 701 indexed words and 101 pages for the index. I have added the search box to a page, set the index for the search, created a search results page, etc.

    All of my pages have their content stored in the shared content (generic content) modules. I am finding that the search results are not returning the pages that are using the shared content. 

    Should the results be returning these pages with shared content or do I need to so something to enable this?

    Thank you.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    14 May 2010
    Link to this post
    Hi Laura,

    There is something on the pages that uses this shared content - it could be a control on these pages or some control or code in the master page. This prevents the crawler to index your pages properly.

    1. Crate a new master page without any css, js and controls on it. Add just one ContentPlaceHolder.
    2. Create a new page and set the page to use the newly created template with a single ContentPlaceHolder
    3. Drop a GenericContent control on this page and type a simple text in it - say "Telerik".
    4. Save the page and make sure that it is with status "Published".
    5. Run the search index.
    6. Go to the page where you have already dropped SearchResults and SearchBox control and look up for "Telerik"

    Make sure that you have not set any negative value for the weight in fieldsInfoProvider.xml -  How to customize the indexing of html documents

    Greetings,
    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. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    16 May 2010
    Link to this post
    Thank you for your response. 

    I have tried that. I created a "blank" page from a "blank" template and out a few words on it. The search was able to find it.  So my question remains as this - can the search index pages where the content is pulled from the shared generic content items?  If not then I have to branch all generic content on the pages?

    Thank you.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    16 May 2010
    Link to this post
    Hello Laura,

    The problem is not whether the content is shared or not. Have you tried the same with shared content?
    There is something on the pages that uses this shared content - it could be a control on these pages or some control or code in the master page. This prevents the crawler to index your pages properly.

    Please take a look at the attached video.

    Sincerely yours,
    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. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    16 May 2010
    Link to this post
    Yes, sorry. I spoke to soon...  I did some more testing.

    On our pages we have a custom login view control (but very similar to the login view control that comes with Sitefinity) that is linked to a single sign on application. If I remove this control I can get the page in the results. So yes, I beleive this is what is stopping it from displaying in the results.

    Most of the pages in the site are public pages.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    17 May 2010
    Link to this post
    Hello Laura,

    If you use Page.User.Identity.IsAuthenticated in your login control, replace it with if (HttpContext.Current.User.Identity.IsAuthenticated).  Check whether you call FormsAuthentication.SignOut() in your control that also could be a reason for this issue. You could escape some specific code by using
    if (!CmsContext.IsRequestCrawler(this.Context)) or just remove the Login control from your index as described in How to customize the indexing of html documents

    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. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    17 May 2010
    Link to this post
    Thank you! Very helpful info. I got the index to work using the (!CmsContext.IsRequestCrawler(this.Context))  option directly inside the login view control. However please see comments below.

    If you use Page.User.Identity.IsAuthenticated in your login control, replace it with if (HttpContext.Current.User.Identity.IsAuthenticated). 
    This we are using.

    Check whether you call FormsAuthentication.SignOut() in your control that also could be a reason for this issue.
    We do have this, but it is in the global file. Don't think that is the issue because I can exclude the login view control code and the search works appropriately.

    You could escape some specific code by using if (!CmsContext.IsRequestCrawler(this.Context))
    This I implemented and it woked as expected! It can index the pages, its contents, and return the appropraite results. :) However the next option below, I would like to get to work as well because I think it would be helpful with other items on the master pages however it is giving me an error as described below..

    or just remove the Login control from your index
    I did use the name of the DIV tag that surrounds the login view control for example in the XML file
    <field filterattributes="id:UtilityMenu" filtertag="div" weight="-1" name="exampleExcludeIndexingFieldRule" />

    Afterwards, when I click on "Start Indexing" in the admin I get the error below and the search will not return any results. (As a test I am only indexing one or two pages)
    Server Error in '/' Application.
    --------------------------------------------------------------------------------
      
    Object reference not set to an instance of an object. 
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
      
    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
      
    Source Error: 
      
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  
      
    Stack Trace: 
      
      
    [NullReferenceException: Object reference not set to an instance of an object.]
       Telerik.Search.IndexFieldsProvider.Load(String infoPath) +275
       Telerik.Search.IndexFieldsProvider.Load() +36
       Telerik.Search.Engine.HtmlIndexer..ctor(String directory, String provider, Boolean appendToIndex) +55
      
    [TargetInvocationException: Exception has been thrown by the target of an invocation.]
       System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct& signature, IntPtr declaringType) +0
       System.RuntimeMethodHandle.InvokeConstructor(Object[] args, SignatureStruct signature, RuntimeTypeHandle declaringType) +15
       System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +249
       System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1051
       System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +111
       Telerik.Search.Engine.Crawler.GetIndexer(String key, Dictionary`2 indexers, String provider, Boolean appendToIndex) +323
       Telerik.Search.Engine.Crawler.IndexContent(String provider, LinkedList`1 data, Boolean appendToIndex, Dictionary`2 indexers) +169
       Telerik.Search.Engine.Crawler.Index(String provider, String[] urls, LinkedList`1 data, Boolean appendToIndex) +150
       Telerik.Search.Engine.IndexingManager.StartIndexing(IIndexingService service, Boolean appendToIndex) +86
       Telerik.Search.Engine.IndexingService.Index(Boolean appendToIndex) +11
       Telerik.Search.WebControls.Admin.ControlPanel.Service_Command(Object sender, CommandEventArgs e) +334
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +108
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +135
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
    --------------------------------------------------------------------------------
    Version Information: Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4016
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    17 May 2010
    Link to this post
    Hello Laura,

    The error is thrown by IndexFieldsProvider and its Load method. The method  loads contents from the FieldsInfoProvider.Xml file in the Index provider's folder. The  attribute names are case sensitive and the problem comes form the values that you have added to FieldsInfoProvider.Xml

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

    your xml

    <field filterattributes="id:UtilityMenu" filtertag="div" weight="-1" name="exampleExcludeIndexingFieldRule" /

    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.
  9. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    17 May 2010
    Link to this post
    Yes, sorry - I saw that before and changed the parameters to the correct punctuation but still receive the error. As a test example I tried with the footer div as such:
    XML File:
    <?xml version="1.0" encoding="utf-8"?>
    <fields>
      <field name="title" weight="1" indexAttribute="" filterTag="title" filterAttributes="" />
      <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="" />
      <field name="" weight="-1" filterTag="div" filterAttributes="id:imafooter" />
    </fields>


    Div tag:
    <div id="footer">
     <asp:ContentPlaceHolder ID="Footer_Content" runat="server"></asp:ContentPlaceHolder>
    </div>


    And still receive the error. Tried this on a new index as well using one page that has the footer on it.
  10. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    17 May 2010
    Link to this post
    And I can receive this error after searching in the browser:
    Server Error in '/' Application.
    Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
      
    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
      
    Source Error:
      
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
      
    Stack Trace:
      
    [NullReferenceException: Object reference not set to an instance of an object.]
       Telerik.Search.IndexFieldsProvider.Load(String infoPath) +377
       Telerik.Search.IndexFieldsProvider.Load() +36
       Telerik.Search.Engine.HtmlIndexer..ctor(String directory, String provider, Boolean appendToIndex) +54
      
    [TargetInvocationException: Exception has been thrown by the target of an invocation.]
       System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct& signature, IntPtr declaringType) +0
       System.RuntimeMethodHandle.InvokeConstructor(Object[] args, SignatureStruct signature, RuntimeTypeHandle declaringType) +15
       System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +249
       System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1051
       System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +111
       Telerik.Search.Engine.SearchManager.GetFields(String provider) +312
       Telerik.Search.Engine.SearchManager.Search(String searchQuery, String indexName, Int32 startIndex, Int32 max, String mode, Boolean escapeChars, Int32& totalItems) +41
       Telerik.Search.WebControls.SearchResult.CreateChildControls() +456
       System.Web.UI.Control.EnsureChildControls() +87
       System.Web.UI.Control.PreRenderRecursiveInternal() +44
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
      
      
    Version Information: Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4016
  11. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    17 May 2010
    Link to this post
    Okay, got it to work. Don't know if this had anything to do with it but I put the line first as below and it is now working as it should. Thak you for all your time.
    <?xml version="1.0" encoding="utf-8"?>
    <fields>
      <field name="footer" weight="-1" indexAttribute="" filterTag="div" filterAttributes="id:footer" />
      <field name="title" weight="1" indexAttribute="" filterTag="title" filterAttributes="" />
      <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>
Register for webinar
11 posts, 0 answered