Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nick 14 posts 34 karma points
    Jul 04, 2014 @ 10:54
    Nick
    0

    Examine Search Problem, links are always blank

    Hi, 

    I have recently been working on our company HR site.  I implemented a search for the site using Examine.  I have been made aware of a problem with the search functionality, it returns the correct results but each link item is just blank and doesn't let the user navigate to the article or feature.  The site is very simple and I have not changed anything in the search macro since it was implemented.  Could anyone shed any light on this problem?

    Please see my attached config files and the CSHTML for the search macro. 

    <?xml version="1.0"?>

    <!-- 

    Umbraco examine is an extensible indexer and search engine.

    This configuration file can be extended to create your own index sets.

    Index/Search providers can be defined in the UmbracoSettings.config

     

    More information and documentation can be found on CodePlex: http://umbracoexamine.codeplex.com

    -->

    <ExamineLuceneIndexSets>

      <!-- The internal index set used by Umbraco back-office - DO NOT REMOVE -->

      <IndexSet SetName="InternalIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/Internal/"/>

     

      <!-- The internal index set used by Umbraco back-office for indexing members - DO NOT REMOVE -->

      <IndexSet SetName="InternalMemberIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/InternalMember/">

        <IndexAttributeFields>

          <add Name="id" />

          <add Name="nodeName"/>

          <add Name="updateDate" />

          <add Name="writerName" />

          <add Name="loginName" />

          <add Name="email" />

          <add Name="nodeTypeAlias" />

        </IndexAttributeFields>

      </IndexSet>

     

        <IndexSet SetName="MySiteIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/MySite/">

    <IndexAttributeFields>

     <add Name="id" />

     <add Name="nodeName"/>

     <add Name="updateDate" />

     <add Name="writerName" />  

     <add Name="email" />

     <add Name="nodeTypeAlias" />

     </IndexAttributeFields>

    <ExcludeNodeTypes>

    <add Name="Imgage"/>

    <add Name="Folder"/>

    </ExcludeNodeTypes>

      </IndexSet>

     

      <!-- Default Indexset for external searches, this indexes all fields on all types of nodes-->

      <IndexSet SetName="ExternalIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/External/" />

    </ExamineLuceneIndexSets>

    ------------------------------------------------------------------------------------------------------------------------------------------------------------

    <?xml version="1.0"?>

    <!-- 

    Umbraco examine is an extensible indexer and search engine.

    This configuration file can be extended to add your own search/index providers.

    Index sets can be defined in the ExamineIndex.config if you're using the standard provider model.

     

    More information and documentation can be found on CodePlex: http://umbracoexamine.codeplex.com

    -->

    <Examine>

      <ExamineIndexProviders>

        <providers>

          <add name="InternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"

               supportUnpublished="true"

               supportProtected="true"

               analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net"/>

     

          <add name="InternalMemberIndexer" type="UmbracoExamine.UmbracoMemberIndexer, UmbracoExamine"

               supportUnpublished="true"

               supportProtected="true"

               analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/>

     

          <add name="MySiteIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine" analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/>      

     

            <!-- default external indexer, which excludes protected and unpublished pages-->

            <add name="ExternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"/>

     

        </providers>

      </ExamineIndexProviders>

     

      <ExamineSearchProviders defaultProvider="ExternalSearcher">

        <providers>

          <add name="InternalSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"

               analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net"/>

     

          <add name="ExternalSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine" />

     

          <add name="InternalMemberSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine" analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" enableLeadingWildcards="true"/>

     

          <add name="MySiteSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"/>

     

        </providers>

      </ExamineSearchProviders>

     

    </Examine>

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------
    @using Examine;
    @* Get the search term from query string *@
    @{var searchTerm = Request.QueryString["search"];}
    @{var results = ExamineManager.Instance.SearchProviderCollection["MySiteSearcher"].Search(searchTerm, true); }
    @{if (results.TotalItemCount == 0)
      { 
        <p>No results found</p>
    <ul>
    <li>Check your spelling</li>
    <li>Try using single words</li>
    <li>Try searching for a less specific item</li>
    </ul>
      }
      else
      {
        <ul class="search-results">
            @foreach (var result in results)
            {                                                                    
                <li>
                    <a href="@umbraco.library.NiceUrl(result.Id)">@result.Fields["nodeName"]</a>        
                </li>
        
            }
            </ul>
        }
    }
    Thanks for any help or suggestions. 

     

     

  • Ismael 71 posts 354 karma points
    Jul 06, 2014 @ 01:54
    Ismael
    0

    Hi,

    Not sure if this will make any difference but I notice in your index settings you have set the id attribute as "id" (ie lowercase) and in your macro you have "result.Id" - using an upper case "i".

    If that dosesn't help at all, it will be usefull to know which version of Umbraco you are using.

    cheers

     

  • Charles Afford 1163 posts 1709 karma points
    Jul 07, 2014 @ 16:04
    Charles Afford
    0

    Restart IIS and republish the site.  Check wether the index folder has anything in it.  I had to republish a few times before i got results.  That config looks ok to me. 

    Download luke and look at what is in the file inside of your index :).

    Charlie

  • Charles Afford 1163 posts 1709 karma points
    Jul 07, 2014 @ 16:06
    Charles Afford
    0

    Ismal.  its uppecase because its a property in c# code

    public int Id {get;set;}

    This is a typical naming convention.

    The id (lowercase) relates to the a property (in umbraco) alias, which is what lucene looks for :).

    Charlie

  • Nick 14 posts 34 karma points
    Jul 09, 2014 @ 10:30
    Nick
    0

    Thanks Charles for your reply, I will install Luke now and see if I can get the information.  I have republished the site a few times and it seems to make no difference.  I have rebuilt the index and when I use the internal search I get these results..which says to me I should be able to access the page by its ID?  Although this site is multi-level so do I need to include the parent ID in the construction of the URL?

     

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Jul 09, 2014 @ 10:52
    Ismail Mayat
    0

    Nick,

    In your code instead of :

    umbraco.library.NiceUrl(result.Id)

    try,

    var node = Umbraco.TypedContent(result.Id);
    @node.Url

    You are running v7 and it may be that the older umbraco.library.NiceUrl is playing up?

    Regards

    Ismail

     

  • Nick 14 posts 34 karma points
    Jul 09, 2014 @ 12:07
    Nick
    0

    Hi Ismail, thanks again for your reply! I am determined to get to the bottom of this.  Unfortunately I am on version 6, so I cannot use TypedContent..I really am stumped.  I can print out the Node Names fine but when it comes to the link it is always a "#" symbol.

     

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Jul 09, 2014 @ 12:38
    Ismail Mayat
    0

    Nick,

    You can use in v6, i am assuming that this is a partial that you are working in?  Also the statement is in wrong place, so update your code in the following way

    before the using examine statement add

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage

    then in loop do 

    var node =Umbraco.TypedContent(result.Id);

    @node.Url

    Regards

     

    Ismail

  • Nick 14 posts 34 karma points
    Jul 09, 2014 @ 13:39
    Nick
    0

    I am having trouble with where to place the declaration? Am I even close to correct?

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Jul 09, 2014 @ 15:16
    Ismail Mayat
    0

    Nick,

    That should work, what happens when you check ignore errors then save then hit the page does it still error?

    Regards

    Ismail

  • Nick 14 posts 34 karma points
    Jul 09, 2014 @ 16:05
    Nick
    0

    I get this error on my page - 'Error loading MacroEngine script (file: SearchResults.cshtml)' :(

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Jul 09, 2014 @ 17:31
    Ismail Mayat
    0

    Nick,

    Ok take that inherits statement out then try:

    var Umbraco = new Umbraco.Web.UmbracoHelper(UmbracoContext.Current)

    Regards

    Ismail

  • Nick 14 posts 34 karma points
    Jul 09, 2014 @ 18:01
    Nick
    0

    var Umbraco = new Umbraco.Web.UmbracoHelper(UmbracoContext.Current)

    @using Examine;

     

     

    @* Get the search term from query string *@

    @{var searchTerm = Request.QueryString["search"];}

    @{var results = ExamineManager.Instance.Search(searchTerm, true); }

     

     

    @{if (results.TotalItemCount == 0)

      { 

        <p>No results found</p>

    <ul>

    <li>Check your spelling</li>

    <li>Try using single words</li>

    <li>Try searching for a less specific item</li>

    </ul>

      }

      else

      {

    <ul class="search-results">

    @foreach (var result in results)

    {       

    var node = Umbraco.TypedContent(result.Id);

    <li>

    <a href="@node.Url">@result.Fields["nodeName"]</a>

    </li>    

    }

    </ul>

        }

    }

     

    that is my code? Still getting the same error......I really do appreciate all your help here! 

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Jul 10, 2014 @ 12:46
    Ismail Mayat
    0

    Nick,

    THe var umbraco is outside the @ ?? if needs to be inside after the using statements. Also can you edit the partial in visual studio that will give you intellisense and pick up any errors.

    Regards

     

    Ismail

  • Nick 14 posts 34 karma points
    Jul 10, 2014 @ 13:36
    Nick
    0

    I have made the edits you recommended, it keeps complaining about UmbracoContext, saying it doesn't exist in this context?

  • Nick 14 posts 34 karma points
    Jul 10, 2014 @ 13:42
    Nick
    0

    I am running version Umbraco v6.1.6 if that is any help?

  • Nick 14 posts 34 karma points
    Jul 14, 2014 @ 10:05
    Nick
    0

    Hi Ismail, I am still experiencing problems.  I think this will be my last day of trying to fix it, if I can't by the end of today I will look at implementing a different type of search, do you have any recommendations?

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Jul 14, 2014 @ 13:45
    Ismail Mayat
    0

    Nick,

    Ok get rid of that Umbraco line and at the point where you want the url try umbraco.library.NiceUrl(result.Id)

    Regards

    Ismail

  • Nick 14 posts 34 karma points
    Jul 14, 2014 @ 14:31
    Nick
    0

    That is what I had already implemented when I posted the problem? the search returns the right results, and even the right name for each node that is returned.  It's just the link to that node which isn't correct.  See my attached screenshot, and look at the bottom left hand corner which is when I hover over the link?! It's just linking back to the search it seems? 

    Here is my cshtml code:

    @using Examine;

    @* Get the search term from query string *@

    @{var searchTerm = Request.QueryString["search"];}

    @{var results = ExamineManager.Instance.Search(searchTerm, true); }

     

     

    @{if (results.TotalItemCount == 0)

      { 

        <p>No results found</p>

    <ul>

    <li>Check your spelling</li>

    <li>Try using single words</li>

    <li>Try searching for a less specific item</li>

    </ul>

      }

      else

      {

    <ul class="search-results">

    @foreach (var result in results)

       {

           

    <li>

    <a href="@umbraco.library.NiceUrl(result.Id)">@result.Fields["nodeName"]</a>

    </li>    

       }

    </ul>

        }

    }

     

     

  • Nick 14 posts 34 karma points
    Jul 14, 2014 @ 14:35
    Nick
    0

Please Sign in or register to post replies

Write your reply to:

Draft