Copied to clipboard

Flag this post as spam?

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


  • Robert 2 posts 53 karma points
    May 29, 2014 @ 21:57
    Robert
    0

    Examine fuzzy searches not working

    Hi there,

     

    We are trying to use the fuzzy field modifier "~" in our raw queries to catch results for misspelled words.

     

    Our search logic looks like this:

     

          Dim searcher = ExamineManager.Instance.SearchProviderCollection(searchProviderName)
          Dim searchCriteria = searcher.CreateSearchCriteria()
          Dim query = searchCriteria.RawQuery("badlyspelledword")
          Dim results As ISearchResults = searcher.Search(query)
          If Not IsNothing(results) Then
            If Not results.Count = 0 Then
              Return results
            End If
          End If
          ' Recheck with misspelled words
          query = searchCriteria.RawQuery("badlyspelledword~")
          Return searcher.Search(query)

     

     

    I have also tried:

     

    • Adjusting the threshold for the fuzzy algorithm to super low: "badlyspelledword~0.2"
    • Using the Fluent API:
    query = searchCriteria.Field("theFieldIWantToSearch", "badlyspelledword".Fuzzy(0.5)).Compile()
    Return searcher.Search(query)

    I've had no luck with any of these.  For example I am trying to find results for a term which has many documents in our tree "ginkgo" by searching for "gink", or "ginko" and none of these methods are successful.

    Our index set is built to include all of the attribute fields as default strings for the node types we want to search in our tree.  It uses the default analyzer (which I assume is the Lucene StandardAnalyzer).

    Can anyone offer me any hints for where I might be going wrong with either the RawQuery use of the modifier ~ or with the Fluent API that would make this not work?

    Thanks,

    Robert Hawkey

     

     

     

     

  • Robert 2 posts 53 karma points
    May 30, 2014 @ 16:37
    Robert
    101

    It turns out that it's bad to re-use the ISearchCriteria object, so this code works:

    ' Recheck with misspelled words
    searchCriteria = searcher.CreateSearchCriteria()
    query = searchCriteria.RawQuery("badlyspelledword~")
    Return searcher.Search(query) 
Please Sign in or register to post replies

Write your reply to:

Draft