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
    Feb 20, 2013 @ 10:48
    Fuji Kusaka
    0

    Search Phrase / different words using examine

    Hi Guys,

    I have a examine index search under v 4.9.1 and facing some issues whenever i search of some words like for example "Hello World" which will return "zero" but if look for "Hello" or "World" seperately it returns some values.

    Under node content i have a document type textbox where client will be able to add the keywords for his search to work. Having checked with lucene the indexes i actuallly do have both "Hello" and "World" being indexed.

    Is there a way of getting the results for single and double words or even longer ones in examine ? The project being done has some important name such as "Rooms .... " or "Rooms ....", so search is always null when i type  "Rooms...." followed by some other keywords.

    Here is my code

    @using umbraco.MacroEngines;
    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using Examine
    @using Examine.SearchCriteria
    @using Examine.LuceneEngine.SearchCriteria
                 

    @{
       
        var searchTerm = Request.Form["serachTerm"];
        var list = 0;
       
        //Check if SearchQuery is Null
       
       if(String.IsNullOrEmpty(searchTerm)){
           <p>@umbraco.library.GetDictionaryItem("Please Search")</p>
           return;
       }

       
        var searcher = ExamineManager.Instance.SearchProviderCollection["HRSearcher"];   
        var searchCriteria = searcher.CreateSearchCriteria(BooleanOperation.Or);
        var query = searchCriteria.Field("umbracoNaviHide", "1").And().GroupedOr(new string[] { "bodyContent", "metaKeywords", "metaDescriptions", "altPageTitle", "petitPlus", "fileIndex" }, searchTerm.Fuzzy(0.5f)).Compile();

       
        var searchResults = searcher.Search(query);
        var noResults = searchResults.Count();
       
        <p> @umbraco.library.GetDictionaryItem("SearchTxt") <strong><u>@searchTerm</u></strong> @umbraco.library.GetDictionaryItem("Search Found") @noResults  @umbraco.library.GetDictionaryItem("Search Results")</p>
       
       <div id="searchMnu">
        <ul>
            @foreach (var result in searchResults)
            {
                list++;
                if (@result.Fields["nodeTypeAlias"] == "File")
                {

                    var media = @result.Fields["parentID"];
                    var category = Model.MediaById(media);
                    dynamic mediaItem = new DynamicMedia(result.Id);
                   
                    <li onclick='window.location="@mediaItem.umbracoFile"; return false;'>
                      <span> @list. @umbraco.library.GetDictionaryItem("telecharger")  @result.Fields["nodeName"]</span>
                    </li>
                }                  
                   
                   
                    if(@result.Fields.Keys.Contains("bodyContent")){
                         <li onclick='location.href="@umbraco.library.NiceUrl(result.Id)"'>
                              <span> @list.  @result.Fields["nodeName"]</span><br />
                                     @Library.Truncate(@Library.StripHtml(result.Fields["bodyContent"]), 200)
                             </li>
                    }
                else{
                        <li onclick='location.href="@umbraco.library.NiceUrl(result.Id)"'>
                              <span> @list.  @result.Fields["nodeName"]</span><br />
                    </li>
                }          
               
            }
        </ul>
        </div>  
       
      
    }

     

    Any Advice on how to proceed here ?

    //fuji

     

  • Fuji Kusaka 2203 posts 4220 karma points
    Feb 25, 2013 @ 07:05
    Fuji Kusaka
    0

    Any Help on this please? or should i conside using xslt search instead ?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies