Copied to clipboard

Flag this post as spam?

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


  • Mark Evans 86 posts 116 karma points
    Sep 29, 2014 @ 17:38
    Mark Evans
    0

    fuzzy searching

    ive got  a basic search solution working based on examine, but want to incorporate the ability to cater for fuzzy searching, however im not sure how to implement this, i found examples adding .fuzzy(0.8) to the search strings but this doesnt work....

    var searchCriteria = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"].CreateSearchCriteria();
        var query = searchCriteria.GroupedOr(new string[] { "bodyText", "pageTitle", "pageIntro", "nodeName" }, searchTerm)
            .Not()
            .Field("umbracoNaviHide", "1")
            .Not()
            .Field("nodeTypeAlias", "Image")
            .Not()
            .Field("nodeTypeAlias", "Tabs")
            .Not()
            .Field("nodeTypeAlias", "Contact")
            .Not()
            .Field("nodeTypeAlias", "ContactUs")
            .Not()
            .Field("nodeTypeAlias", "ContactDetails")
            .Not()
            .Field("nodeTypeAlias", "Contactrequest")        
            .Compile();

     

  • Alex Lindgren 159 posts 356 karma points
    Sep 30, 2014 @ 03:25
    Alex Lindgren
    0

    I'm not good with Fluent queries of the top of my head, but one thing you can do to simplify it is to create a separate IndexSet with just the content you want to search on. It appears that you are excluding a bunch of document types. You could create an indexset with just the doc types you want to index or one that excludes the ones you don't want to search on (but don't do both at the same time). For example on defining IndexSets see http://our.umbraco.org/documentation/reference/searching/examine/full-configuration.

  • Dallas 132 posts 404 karma points
    Sep 30, 2014 @ 06:01
    Dallas
    0

    Mark - by doesn't work do you mean it won't compile or it isn't returning the results you are expecting?

    If searchTerm is a string you should be able to add .Fuzzy() to the string. Check the parameter type of Fuzzy() - if it is a float, you can add an f to the number and this should work.

    var query = searchCriteria.GroupedOr(newstring[]{"bodyText","pageTitle","pageIntro","nodeName"}, searchTerm.Fuzzy(0.8f))

    Dallas

  • Mark Evans 86 posts 116 karma points
    Sep 30, 2014 @ 09:09
    Mark Evans
    0

    thanks 

Please Sign in or register to post replies

Write your reply to:

Draft