Copied to clipboard

Flag this post as spam?

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


  • Martin Lingstuyl 202 posts 379 karma points
    Jan 26, 2011 @ 10:39
    Martin Lingstuyl
    1

    Umbraco Examine and Wildcardsearching

    Hi,

    I'm creating a simple Lucene search module for one of my websites. I first watched the umbraco.tv episodes to get it all in my head.

    So I first copied the example from umbraco.tv to start. created a demoindex, checked it through luke. Everything worked. Created the usercontrol, did a search. It worked...but then I ran into something strange:

    when I search for 'word' (without quotes of course) it does not find 'largerword'. Using * doesn't seem to help in this, and I cannot seem to find the problem.

    Anyone have experience with Examine and know what this is about?

     

    thanks

    Martin

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Jan 26, 2011 @ 11:51
    Ismail Mayat
    4

    Martin,

    In you query code you need to ensure you do wild card query this is done by

    var criteria = searcher.CreateSearchCriteria();           
                IBooleanOperation query = criteria.Field("contents",searchQuery.MultipleCharacterWildcard());

    the MultipleCharacterWildCard() is an extension method on strings and is part of the examine library. That will when query is compile tag the * wildcard character giving you a wildcard query.

    Regards

    Ismail

  • Martin Lingstuyl 202 posts 379 karma points
    Jan 26, 2011 @ 12:37
    Martin Lingstuyl
    0

    Hi Ismail,

    thanks for replying that quickly. I'm trying it out, but maybe I'm missing something:

    SearchTerm.MultipleCharacterWildCard() doesnt work with me because SearchTerm is a protected string SearchTerm { get; private set; }

     

    Do I need to include a reference to the extensionlibrary? It should be a string right? Not a IExamineValue?

     

    martin

     

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Jan 26, 2011 @ 12:48
    Ismail Mayat
    1

    Its a member of UmbracoExamine.SearchCriteria.LuceneSearchExtensions 

    Regards

    Ismail

  • Martin Lingstuyl 202 posts 379 karma points
    Jan 26, 2011 @ 12:56
    Martin Lingstuyl
    1

    Thanks a lot!

    a last question, where do I input the IbooleanOperation query?

    somewhere in here?

    var filter = criteria 
                       .GroupedOr(new string[] { "nodeName", "naamArtikel", "omschrijving" }, SearchTerm.ToLower())
                       .Not()
                       .Field("umbracoNaviHide", "1")                  
                       .Compile();

     

  • Antoinette Silago 21 posts 92 karma points notactivated
    Jun 05, 2017 @ 20:19
    Antoinette Silago
    0

    Thank for this post... been trying to figure this out!!

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Jan 26, 2011 @ 13:20
    Ismail Mayat
    1

    where you have SearchTerm.ToLower() just add the MultipleCharacterWildCard() so you have

    SearchTerm.ToLower().MultipleCharacterWildCard()

    Regards

    Ismail

  • Martin Lingstuyl 202 posts 379 karma points
    Jan 26, 2011 @ 15:13
    Martin Lingstuyl
    0

     

    Hi Ismail,

     

    thanks for the reply. The wildcards' working now.

    But putting the * before the word doesnt work. So now I can search ' larger* ' and find 'largerword'. But I cannot search ' *word ' and find 'largerword'

    Any ideas?

     

  • Matt Taylor 873 posts 2086 karma points
    Mar 14, 2011 @ 17:52
    Matt Taylor
    0

    I'm hoping this post will help me as I have the same issue.

    To answer your last question Martin, a wild card is not permitted at the start of a search, http://lucene.apache.org/java/2_3_2/queryparsersyntax.html

  • Martin Lingstuyl 202 posts 379 karma points
    Mar 14, 2011 @ 19:55
    Martin Lingstuyl
    0

    I learned that already, but thanks anyway.

    It's just a weird not really thought out issue with lucene.

    although I heard that it is possible to enable it, but hten you have to extend the examine class.

     

  • Matt Taylor 873 posts 2086 karma points
    Mar 15, 2011 @ 13:36
    Matt Taylor
    0

    Can somebody tell me what I'm doing wrong?

    It won't recognise MultipleCharacterWildcard() as a valid string extension so I cannot compile it.

    I have references to Examine & UmbracoExamine and the folowing code:

    using Examine;
    using Examine.SearchCriteria;
    private void PerformSearch(string searchTerm)
            {
                if (string.IsNullOrEmpty(searchTerm)) return;
               
                var criteria = ExamineManager.Instance
                    .SearchProviderCollection["SiteSearchSearcher"]
                    .CreateSearchCriteria(UmbracoExamine.IndexTypes.Content);

                var filter = criteria
                    .GroupedOr(new string[] { "nodeName", "browserTitle", "metaKeywords", "metaDescription",
                        "featureTitle", "featureSummary", "title", "searchKeywords", "summary", "body", "footer" }, searchTerm.MultipleCharacterWildCard())
                    .Not()
                    .Field("umbracoNaviHide", "1")
                    .Compile();

                SearchResults = ExamineManager.Instance
                    .SearchProviderCollection["SiteSearchSearcher"]
                    .Search(filter);

                searchResultsRepeater.DataSource = SearchResults.Skip(CurrentPage * _pageSize).Take(_pageSize);
               
                searchResultsRepeater.DataBind();

            }

    Thanks, Matt

  • Martin Lingstuyl 202 posts 379 karma points
    Mar 15, 2011 @ 14:37
    Martin Lingstuyl
    0

    the MultipleSearchCriteria extension is hidden somewhere deeper within the examine namespace, because otherwise the string extension would pop up everywhere.

    I think you only have to add:

     

    using UmbracoExamine.SearchCriteria.LuceneSearchExtensions

     

    Then it will work

  • Connie DeCinko 931 posts 1160 karma points
    Sep 28, 2011 @ 23:12
    Connie DeCinko
    0

    Adding that does not work.  LuceneSearchExtensions does not exist in that namespace.

     

  • suzyb 474 posts 932 karma points
    Jul 03, 2012 @ 17:49
    suzyb
    0

    Does anyone have an answer to the MultipleCharacterWildCard extension is.  I am trying to use it but can't find where it is.

  • Matt Taylor 873 posts 2086 karma points
    Jul 03, 2012 @ 18:23
    Matt Taylor
    0

    Hmmm this may not help you but I looked back at what I did and ended up using .Fuzzy() instead.

  • suzyb 474 posts 932 karma points
    Jul 04, 2012 @ 12:18
    suzyb
    3

    I'm just searching for the first initial of a name so don't really need fuzzy.

    But for anyone finding this in the future it seems to be in Examine.LuceneEngine.SearchCriteria.

Please Sign in or register to post replies

Write your reply to:

Draft