Copied to clipboard

Flag this post as spam?

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


  • Fuji Kusaka 2203 posts 4220 karma points
    Jan 25, 2013 @ 15:12
    Fuji Kusaka
    0

    Search Result not displaying "nodeName"

    Hi everyone,

    Am getting some weird issues here with my examine search result where @nodeName is causing the razor file to crash.

    Whenever i add the @result.Fields["nodeName"] the script crash, and if changed to bodyContent or @result.Id I works just fine.

    Here is my razor script

     var searchTerm = Request.Form["searchTerm"];
        var list = 0;
        
        //Check if SearchQuery is Null   
       if(String.IsNullOrEmpty(searchTerm)){
           <p>Please use the search Box</p>
           return;
       }

        var searcher = ExamineManager.Instance.SearchProviderCollection["EspralSearcher"];
        var searchCriteria = searcher.CreateSearchCriteria(BooleanOperation.Or);
        var query = searchCriteria.GroupedOr(new string[] { "nodename", "nodeName", "bodyContent", "altPageTitle"}, searchTerm).Compile();
        var searchResults = searcher.Search(query);
        var noResults = searchResults.Count();
        
        <p> You Searched for <strong><u>@searchTerm</u></strong>, and found @noResults results</p>
        
       <div id="searchMnu">
        <ul>
            @foreach (var result in searchResults)
            {
    list++;   
          
    <li><a href="@umbraco.library.NiceUrl(result.Id)">@result.Fields["nodeName"]</a></li>
            <li><a href="@umbraco.library.NiceUrl(result.Id)">@result.Id</a>
               <br/>@Library.Truncate(@Library.StripHtml(result.Fields["bodyContent"]), 300)</li>
            }
        </ul>
        </div>

     

     Anyone ever had this issue ?  i have other site running with examine but they work just fine.

     

    //fuji

  • Fuji Kusaka 2203 posts 4220 karma points
    Jan 25, 2013 @ 15:43
    Fuji Kusaka
    0

    Any help please? ?

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Jan 25, 2013 @ 16:37
    Ismail Mayat
    0

    Fuji,

    Run the query in luke and see what you are getting back see if nodeName is missing for one of the results

  • Fuji Kusaka 2203 posts 4220 karma points
    Jan 25, 2013 @ 16:52
    Fuji Kusaka
    0

    Hi Ismail,

    How can i be missing nodeName from the results ? Damn i cant use luke from where i am, need to access a local server at office .

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Jan 25, 2013 @ 17:21
    Ismail Mayat
    0

    You may have one dodgy result in there? Try re publishing the xml then rebuild the index see if that fixes it.

  • Fuji Kusaka 2203 posts 4220 karma points
    Jan 25, 2013 @ 17:24
    Fuji Kusaka
    0

    Well since i cant access the local network from where i am, i instead changed part of code to this

                @foreach (var result in searchResults)
            {
                list++;         
              
                 dynamic node = new DynamicNode(@result.Id);
                 
               <li>@node.Name  <br/> <a href="@umbraco.library.NiceUrl(result.Id)">@node.Url </a>        
               <br/>@Library.Truncate(@Library.StripHtml(result.Fields["bodyContent"]), 300)</li>
           
            }
  • Fuji Kusaka 2203 posts 4220 karma points
    Jan 28, 2013 @ 05:59
    Fuji Kusaka
    0

    Wierd i just check my config file and do have nodeName attributes set up but still search crashes

     <add Name="nodeName" />
  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Jan 28, 2013 @ 09:23
    Ismail Mayat
    0

    did you try re publishing the xml and rebuilding the index?

  • Fuji Kusaka 2203 posts 4220 karma points
    Jan 28, 2013 @ 10:02
    Fuji Kusaka
    0

    Yes but still not getting any result from @result.Fields["nodeName"] the other issue am getting is whenever i type Test in the search the script crashes.

    Is Test a reserved tex here ? tes, tests, testing works perfectly. 

  • Fuji Kusaka 2203 posts 4220 karma points
    Jan 29, 2013 @ 05:12
    Fuji Kusaka
    100

    Hi Ismail,

    Finally got it working, what was wrong is that i was actually getting some results from some other property field that was not being displayed. My mistake i guess for not checking if the field was empty or not and if so to display the content and URL.

     

     if (@result.Fields.Keys.Contains("bodyContent"))
                {
                    <li><strong><a href="@umbraco.library.NiceUrl(result.Id)">@result.Fields["nodeName"]</a></strong>
                    <br/><span><a href="@umbraco.library.NiceUrl(result.Id)">@umbraco.library.NiceUrl(result.Id)</a> </span>
                   <br/>@Library.Truncate(@Library.StripHtml(result.Fields["bodyContent"]), 200) </li>
               }
                     else{
                    <li><strong><a href="@umbraco.library.NiceUrl(result.Id)">@node.Name</a></strong><br/> <span><a href="@umbraco.library.NiceUrl(result.Id)">@umbraco.library.NiceUrl(result.Id)</a> </span></li>
                 }

     

Please Sign in or register to post replies

Write your reply to:

Draft