Copied to clipboard

Flag this post as spam?

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


  • Garðar Þorsteinsson 119 posts 565 karma points
    Nov 18, 2013 @ 23:55
    Garðar Þorsteinsson
    0

    Examine Search, how to use fuzzy ?

    Hi,

    I'm using this query which is working fine.

    // Query
    var searchQuery = searchCriteria.Field("excludeFromSearch", "0").Or().Field("excludeFromSearch", "").And()
    .GroupedOr(new string[] { "nodeName", "nodeTypeAlias", "bodyText", "metaDescription"}, searchString)
    .Compile();

    But I dont want it to make an "hard" search for the searchstring.. f.ex if I search for "title on page" I will find the page but with "title on pa" I will not find the page. I figure I need to have fuzzy option to extend the area of the search but I can't figure out where to insert it ".Fuzzy()".

    Any suggestions would be appreciated !

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Nov 19, 2013 @ 09:20
    Ismail Mayat
    2

    Hi,

    You don't need fuzzy in this instance you need wildcard so where you are searchString change that to

    searchString.MultipleCharacterWildcard()
    

    Also if the index is built using standard analyzer the word "on" will not be in the index as its a stop word. Also in examine if your search term contains spaces you need to separate out the words so you would need code like

                if (searchString.Contains(" "))
                {
                    string[] terms = searchString.Split(' ');
                    searchQuery.And().GroupedOr(new List<string>{"bodyText"}, terms);
    
                }
    

    Also you would need to do it for each field you are searching on. One thing I would recommend is to use ezSearch package http://our.umbraco.org/projects/website-utilities/ezsearch it handles all this kind of stuff and just works out of the box.

    Regards

    Ismail

  • Garðar Þorsteinsson 119 posts 565 karma points
    Nov 19, 2013 @ 23:05
    Garðar Þorsteinsson
    100

    Thank you Ismail !

    I don't get the option for "MultipleCharacterWildcard()" and get there for an error, I'm using Umbraco 6.1.6.

     

       var searchQuery = searchCriteria.Field("excludeFromSearch", "0").Or().Field("excludeFromSearch", "").And()
            .GroupedOr(new string[] { "nodeName", "nodeTypeAlias", "bodyText", "metaDescription"}, searchString.MultipleCharacterWildcard())
            .Compile();
    
  • Garðar Þorsteinsson 119 posts 565 karma points
    Nov 20, 2013 @ 00:32
    Garðar Þorsteinsson
    0

    No problem, found it :)

     

    Examine.LuceneEngine.SearchCriteria.LuceneSearchExtensions.MultipleCharacterWildcard(searchString)
  • Jeffrey La Croix 1 post 21 karma points
    Nov 22, 2013 @ 22:51
    Jeffrey La Croix
    0

    Thank you

Please Sign in or register to post replies

Write your reply to:

Draft