Copied to clipboard

Flag this post as spam?

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


  • Arun 8 posts 28 karma points
    Jul 21, 2014 @ 16:14
    Arun
    0

    unable to show the Embedded content in search Result page

    Umbraco Version -7.1

    asp.net version vs2012 framework 4

    Windows and its version -Windows 7

    Hi 

    I have implemented Embedded package into my website the content of this package is working fine .But  I am unable to search the content which is in embedded content for the search module.

    please kindly help me

     

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jul 21, 2014 @ 17:24
    Jeavon Leopold
    0

    Hi Arun,

    Welcome to Our!

    Could you please post a link to the embedded package to which you are referring?

    Jeavon

  • Arun 8 posts 28 karma points
    Jul 21, 2014 @ 17:49
    Arun
    0

    Hi,

     

    I have used the embeded content package from the below link 

    http://our.umbraco.org/projects/backoffice-extensions/embedded-content

    and also i am using Examine search for showing the search results.

     

    Thanks

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jul 21, 2014 @ 17:52
    Jeavon Leopold
    0

    and are you sure you using this in Umbraco v7.1?

  • Arun 8 posts 28 karma points
    Jul 21, 2014 @ 17:57
    Arun
    0

    hey i am sorry i am using this in umbraco v6.1.6

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jul 21, 2014 @ 18:12
    Jeavon Leopold
    0

    Ok, could you post your code as it stands, including in the first line of the cshtml file?

  • Arun 8 posts 28 karma points
    Jul 21, 2014 @ 18:25
    Arun
    0
    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    
    @using umbraco.MacroEngines;
    
    @using Lucene.Net;
    
    @using Examine;
    
    @using Examine.LuceneEngine;
    
    @using Examine.LuceneEngine.SearchCriteria;
    
    @{
    
        Layout = "Home.cshtml";
    
        string searchTerm = Context.Request.QueryString["search"];
    
        string currentURL = string.Empty;
    
        Uri baseUri, myUri;
    
    
    
    
    
        /* This is your basic query to select the nodes you want */
    
    
    
        Examine.Providers.BaseSearchProvider baseSearchProvider = ExamineManager.Instance.DefaultSearchProvider;
    
        IEnumerable<SearchResult> nodes = null;
    
        //ISearchResults nodes = null;
    
        Lucene.Net.Search.Searcher luceneSearcher = null;
    
        int totalNodes = 0;
    
    
    
        if (!String.IsNullOrEmpty(searchTerm))
    
        {
    
            //nodes = baseSearchProvider.Search(searchTerm, true);
    
            var searchCriteria = Examine.ExamineManager.Instance.CreateSearchCriteria(Examine.SearchCriteria.BooleanOperation.And);
    
    
    
            var query = searchCriteria.GroupedOr(
    
                new string[] { "nodeName", "bodyText","headerDescription","historyIntroduction","year1Description",
    
    "year2Description","year3Description","content","GroundfloorArtists","Tenantname","EmbeddedContent"}
    
                , searchTerm.Fuzzy(0.7f))
    
                .Compile();
    
    
    
            var results = baseSearchProvider.Search(query); //.OrderByDescending(x => x.Score)
    
            luceneSearcher = ((Examine.LuceneEngine.SearchResults)results).LuceneSearcher;
    
            nodes = results.OrderByDescending(x => x.Score);
    
            totalNodes = nodes.Count();
    
        }
    
    
    
    }
    
    <div class="row tennantBanner banner">
    
        <h2 class="bannerTitle" data-0="transform:translate(0,12%);" data-20p="transform:translate(0,-100%);">
    
            Search</h2>
    
    </div>
    
    <div class="row backToTenantDir">
    
        <div class="containerSmall">
    
            <span>Search Result</span>
    
        </div>
    
    </div>
    
    <div class="searchContentContainer containerSmall">
    
        <div class="col-md-12">
    
            <div id="mainContent" class="fc">
    
                <div id="content">
    
                    @if (totalNodes == 0)
    
                    {
    
                        <div class="containerSmall innerMainContent">
    
                            <div class="noResult">
    
                                <img src="/images/zoom.png" />
    
                                <p>
    
                                    No results match your search</p>
    
                            </div>
    
                        </div>
    
                    }
    
                    else
    
                    {
    
                        currentURL = Request.Url.Scheme + "://" + Request.Url.Host + Request.ApplicationPath.TrimEnd('/') + "/";
    
                        baseUri = new Uri(currentURL);
    
    
    
                        <ul id="newsList">
    
                            @foreach (var item in nodes)
    
                            {
    
                                <li>
    
                                    <h3>
    
                                        @if (@item.Fields["__NodeTypeAlias"] == "new" || @item.Fields["__NodeTypeAlias"] == "event")
    
                                        {
    
                                            myUri = new Uri(baseUri, "/about/news-events/"); 
    
                                            <a href= @myUri>@item.Fields["nodeName"] </a>
    
                                        }
    
                                        else
    
                                        {
    
                                            if (@item.Fields["__NodeTypeAlias"] == "about" || @item.Fields["__NodeTypeAlias"] == "units")
    
                                            {
    
                                            <a href="#">
    
                                                @item.Fields["nodeName"]
    
                                            </a>
    
                                            }
    
                                            else if (@item.Fields["__NodeTypeAlias"].ToLower() == "history")
    
                                            {
    
                                                myUri = new Uri(baseUri, "/#divHistory");                                  
    
                                            <a href= @myUri>@item.Fields["nodeName"] </a>
    
                                            }
    
                                            else if (@item.Fields["__NodeTypeAlias"].ToLower() == "gallery")
    
                                            {
    
                                                myUri = new Uri(baseUri, "/#gallery");                                  
    
                                            <a href= @myUri>@item.Fields["nodeName"] </a>
    
                                            }
    
                                            else if (@item.Fields["__NodeTypeAlias"].ToLower() == "companies")
    
                                            {
    
                                                myUri = new Uri(baseUri, "/tenant-directory?type=companies");                                  
    
                                            <a href= @myUri>@item.Fields["nodeName"] </a>
    
                                            }
    
                                            else if (@item.Fields["__NodeTypeAlias"].ToLower() == "artistsstudios")
    
                                            {
    
                                                myUri = new Uri(baseUri, "/tenant-directory?type=artists");                                  
    
                                            <a href= @myUri>@item.Fields["nodeName"] </a>
    
                                            }
    
                                            else
    
                                            {
    
                                                if (@item.Fields["__NodeTypeAlias"] != "image")
    
                                                {
    
                                                    <a href="@Umbraco.NiceUrl(Convert.ToInt32(@item.Fields["id"]))">
    
                                                        @item.Fields["nodeName"]
    
                                                    </a>
    
                                                }
    
                                            }
    
    
    
    
    
                                        }
    
                                    </h3>
    
                                    @{
    
    
    
                                        string[] propertyArray = { "bodyText", "headerDescription", "historyIntroduction", "year1Description", "year2Description", "year3Description", "content", "GroundfloorArtists", "Tenantname", "EmbeddedContent" };
    
    
    
                                        foreach (string searchKey in propertyArray)
    
                                        {
    
                                            if (@item.Fields.ContainsKey(searchKey))
    
                                            {
    
                                                if (@item.Fields[searchKey].ToLower().Contains(searchTerm.ToLower()))
    
                                                {
    
                                                    string fieldName = searchKey;
    
                                                    string searchHiglight = "";
    
    
    
                                                    string fieldValue = item.Fields[fieldName];
    
                                                    searchHiglight = LuceneHighlightHelper.Instance.GetHighlight(fieldValue, fieldName, luceneSearcher, searchTerm);
    
    
    
                                                    if (String.IsNullOrEmpty(searchHiglight))
    
                                                    {
    
                                                        searchHiglight = Umbraco.Truncate(fieldValue, 200).ToString();
    
                                                    }
    
                                                    else
    
                                                    {
    
                                                        searchHiglight = System.Text.RegularExpressions.Regex.Replace(searchHiglight, searchTerm, "<strong>" + searchTerm + "</strong>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
    
                                                    }
    
    
    
                                        <p>@Html.Raw(searchHiglight)</p>
    
                                                }
    
                                            }
    
                                        }
    
    
    
                                    }
    
                                </li>   
    
                            }
    
                        </ul>
    
                    }
    
                </div>
    
            </div>
    
        </div>
    
        <div class="clear">
    
        </div>
    
    </div>
    
  • Arun 8 posts 28 karma points
    Jul 21, 2014 @ 18:31
    Arun
    0

    This is the code i have written for search. and also I am unable to search the content for a full text

    Example :

    If the content i want to search is "creative community", If i enter the text "Creative"its working fine and displaying the result.and also if i search for the content community it is searching well .if i enter the multiple word (i.e creative community)thought it is in same line,i am unable to search for the result.

     

    Kindly help me

    thanks

     

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jul 21, 2014 @ 18:32
    Jeavon Leopold
    0

    Ok, and you want Examine/Lucene to search the xml contents of the embedded content properties, correct?

  • Arun 8 posts 28 karma points
    Jul 21, 2014 @ 18:33
    Arun
    0

    exactly

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jul 21, 2014 @ 18:34
    Jeavon Leopold
    0

    Ok, this has been answered before here :-)

  • Arun 8 posts 28 karma points
    Jul 21, 2014 @ 18:40
    Arun
    0

    ya i have already seen this link ,I am confused :-( and also i tried as well can you please tell me how to implement these things in my code and can you please tell me for the above post which i posted before.

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jul 21, 2014 @ 19:43
    Jeavon Leopold
    0

    I don't have a implementation of this exact requirement to post for you.

    But you will need to use the OnGatheringNodeData event to strip the XML from embedded content and add it into the index as currently it will not be there to be searched, this is not something you can just do in Razor.

    I will see if I can find anything else that might help you.

Please Sign in or register to post replies

Write your reply to:

Draft