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 114 posts 556 karma points
    Nov 18, 2013 @ 23:55
    Garðar Þorsteinsson

    Examine Search, how to use fuzzy ?


    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)

    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 10091 karma points MVP 2x admin c-trib
    Nov 19, 2013 @ 09:20
    Ismail Mayat


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


    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 it handles all this kind of stuff and just works out of the box.



  • Garðar Þorsteinsson 114 posts 556 karma points
    Nov 19, 2013 @ 23:05
    Garðar Þorsteinsson

    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())
  • Garðar Þorsteinsson 114 posts 556 karma points
    Nov 20, 2013 @ 00:32
    Garðar Þorsteinsson

    No problem, found it :)


  • Jeffrey La Croix 1 post 21 karma points
    Nov 22, 2013 @ 22:51
    Jeffrey La Croix

    Thank you

Please Sign in or register to post replies

Write your reply to: