Copied to clipboard

Flag this post as spam?

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


  • Vipul Patel 18 posts 37 karma points
    Oct 26, 2009 @ 16:51
    Vipul Patel
    0

    umbraco search and Lucene

    I am a newbie and want to know how to install Lucene and make it work with umbraco , can anyone point me to a video tutorial (i have subcribed to umbraco.tv already) or would like to know a blog post which shows from first step to last step how i can use Lucene search with umbraco, i dont have any knowledge of Lucene.

     

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 26, 2009 @ 22:54
    Aaron Powell
    0

    One of the core team members has released an add-in called Umbraco Examine which is a Lucene indexer for Umbraco (http://umbracoexamine.codeplex.com/).

    The documentation is a bit lacking at the moment, you may need to look into the 4.1 release package for umbraco (as Examine is being included in that).

    Essentially you need to just specify in the web.config the doc types and their properties to index and Examine does the rest

  • trfletch 598 posts 604 karma points
    Jan 11, 2010 @ 17:52
    trfletch
    0

    Any news as to when more documentation is going to be released on this? I have download the files but I'm not too sure how I make use of them, as in how I create a search page etc that is capable of searching through Umbraco pages and the text in uploaded documents. I am currently using XSLT Search.

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Jan 11, 2010 @ 19:28
    Nik Wahlberg
    2

    The following takes you through from basic to Advanced setups of Examine. Should be pretty straight forward:

    http://farmcode.org/post/2009/04/20/Umbraco-Examine-v4x-Powerful-Umbraco-Indexing.aspx

    Here's a quick example (in-page):

    SearchResults.ascx.cs

    string keyWords = "";
    if (Request.QueryString["k"] != null)
    {
        keyWords = Request.QueryString["k"].ToString();
    }
    var sb = new StringBuilder();
    
    // perform the search...
    var examine = new UmbracoIndexer();
    List<SearchResult> results = examine.Search(keyWords, true);
    
    sb.Append("<p class=\"notification\">Your search for <span class=\"words\">" + keyWords + "</span> yielded <span class=\"numItms\">" + results.Count + "</span> items.</p>");
    sb.Append("<ul class=\"search-results\">");
    foreach (SearchResult sr in results)
    {
        sb.Append("<li>");
            sb.Append("<a href=\"" + url + "\" target=\""+target+"\">");
                sb.Append(sr.Fields["nodeName"]);
            sb.Append("</a> ");
            sb.Append("<div class=\"desc\">");
                var descStr=sr.Fields["bodyText"];
                if (descStr.Length > 250)
                {
                    sb.Append(descStr.Substring(0, 250));
                    sb.Append("...");
                }
                else
                {
                    sb.Append(descStr);
                }
            sb.Append("</div>");
        sb.Append("</li>");
    }
    sb.Append("</ul>");
    
    _resultsContainer.Text = sb.ToString();

     

    SearchResults.aspx

    <asp:Literal id="_resultsContainer" runat="server"></asp:Literal>

     

    Of course, you can also do this using DataTables or something for sorting, paging, etc. This is just a quick/dirty example. 

    -- Nik

  • Morten Kjerulff 7 posts 27 karma points
    Mar 09, 2010 @ 11:04
    Morten Kjerulff
    0

    Thanks Nik.

    Your example was very helpful (at least to me) :-)

    Cheers
    Morten

Please Sign in or register to post replies

Write your reply to:

Draft