Copied to clipboard

Flag this post as spam?

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


  • Anton Gildebrand 49 posts 149 karma points c-trib
    May 20, 2015 @ 15:00
    Anton Gildebrand
    0

    Examine improve search suggestions

    I've recently deployed a fairly large site running Umbraco 7, and the site is using Examine for search functionality. Our search form auto suggest pages based on what the user enters.

    It doesn't work optimally however, the user have to enter pretty many characters before Examine returns any results.

    We want that if the user enters the letter "A" Examine returns all pages starting with A (big or small shouldn't matter). They should be sorted alphabetically. So when the user enters more characters more pages are shown. Right now the user have to spell out the entire word before Examine shows any results.

  • TikTakToe 60 posts 102 karma points
    May 20, 2015 @ 15:13
    TikTakToe
    0

    Whenever i need to do anything complicated, i usually dip in RawQuery mode and use this guide to help: http://www.lucenetutorial.com/lucene-query-syntax.html

    ...
    var query = string.format("Name:{0}*",term);
    var searchResults = searcher.Search(searcher.CreateSearchCriteria().RawQuery(query));
    ...
    

    For some reason i find RawQuery easier to pick up and understand, but as ever, i'm sure there are a million and 1 ways to do it!

    enjoy

    Ian

  • Anton Gildebrand 49 posts 149 karma points c-trib
    May 20, 2015 @ 16:03
    Anton Gildebrand
    0

    Thank you TikTakToe for your quick reply, works great :)

    However as soon as there are spaces in the search term, the results is weird and doesn't have any relevance anymore.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    May 20, 2015 @ 16:12
    Ismail Mayat
    0

    Anton,

    You need to look at  your code that is doing the search I take it autosuggest is being called using jquery and that is making request to webapi?  

    If you want really good autosuggest then I would take a look at the elastic search definitive guide book (http://www.amazon.co.uk/Elasticsearch-Definitive-Guide-Clinton-Gormley/dp/1449358543/ref=sr_1_1?s=books&ie=UTF8&qid=1432131102&sr=1-1&keywords=elasticsearch+the+definitive+guide) there is chapter in there about the concepts of auto suggest.  Although its related to elastic search the principles (ngrams and edgegrams) relate to lucene or in this case lucene.net examine is just a wrapper around lucene.net just as elastic is wrapper around lucene.  

    Regards

    Ismail

  • TikTakToe 60 posts 102 karma points
    May 20, 2015 @ 16:37
    TikTakToe
    0

    hi anton

    can you not just add quotes around your term, like so?

    var query = string.format("Name:'{0}*'",term);

    Not tried this, so just a guess - also, your analysers will play an important part in how your queries return results and how whitespace is handled (aside: it may work to add in a custom field with the name stripped of spaces and also strip the spaces from your search term when you pass it in - look at gatheringnodedata event handler for more info)

    Also, donwload luke and open your index and you can play around with lucene queries to your hearts content - it's a good way to test raw queries and explore lucene: http://www.getopt.org/luke/

    just remember to set the correct analyser to match the one in your examine config so you get the right results.

  • TikTakToe 60 posts 102 karma points
    May 20, 2015 @ 16:43
    TikTakToe
    0

    something like

        private void OnGatheringNodeData(object sender, IndexingNodeDataEventArgs e)
        {
            var currentItem = Helper.TypedContent(e.NodeId);
            e.Fields.Add("lucenceSearchFriendlyName", e.Name.Replace(" ",""));
        }
    

    then in your search:

    var query = string.format("lucenceSearchFriendlyName:{0}*",term.Replace(" ",""));
    
Please Sign in or register to post replies

Write your reply to:

Draft