Copied to clipboard

Flag this post as spam?

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


  • Sonni T. 6 posts 36 karma points
    Feb 23, 2015 @ 21:40
    Sonni T.
    0

    Examine / Lucene does return the expected results

    I have a Lucene index where (when using Luke) the data seems ok.

    When i try to query the index i don't get the expected results.

    In my Lucene index i have a series of fields - for example firstname that contains the name 'Dennis' - but when i query the index it returns nothing. In another firstname field i have 'Hanne' - if my search phrase is 'Hanne' it returns nothing - but if it is 'Anne' the name is found.

    I have made a stripped down version of what I am doing. I am using the WhiteSpaceAnalyzer in both my indexer and my searcher.

    Code:
    string[] _internalFieldsToSearch = new[] { "company", "department", "description", "firstname", "jobTitle", "lastname", "mobileNumber", "workArea", "email", "memberPositions" };

    string searchText = searchStr.Trim();
    while (searchText.IndexOf('*') == 0 || searchText.IndexOf('?') == 0 || searchText.IndexOf('.') == 0)
    {
        searchText = searchText.Remove(0, 1);
    }

    if (searchText.Length > 0)
    {
        string[] searchTerms = searchText.Split(' ').ToArray();

        BaseSearchProvider searcher = ExamineManager.Instance.SearchProviderCollection["InternalEUCMemberSearcher"];
        ISearchCriteria searchCriteria = searcher.CreateSearchCriteria(BooleanOperation.Or);

        string term = "*" + searchText.ToString() + "*";

        IBooleanOperation queryFiltered = searchCriteria.GroupedOr(_internalFieldsToSearch, term.ToLower().MultipleCharacterWildcard());

        ISearchResults searchResults = searcher.Search(queryFiltered.Compile());
    }

  • Ayo Adesina 439 posts 1032 karma points
    Feb 24, 2015 @ 15:16
    Ayo Adesina
    0

    Have you tired to do the search in the back office of umbraco?

    Developer > Examine tab

    then select your searcher from the list, then type in your search term

  • Sonni T. 6 posts 36 karma points
    Feb 25, 2015 @ 09:18
    Sonni T.
    0

    Hi again,

    Unfortunately the solution is running on 4.11.1 - so i cannot do that. Thanks for the input though.

    ST

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Feb 25, 2015 @ 09:52
    Ismail Mayat
    100

    Sonni,

    Can you debug and to searchCriteria.ToString() this will give you the generated query and paste that back. Also any reason for using whitespace analyser and not standard one.  If i remember rightly whitespace one is case sensitive? Also why are doing string term = "*" + searchText.ToString() + "*"; the multiple wildcard statement will tag on wildcard at end. 

    Regards

    Ismail

  • Sonni T. 6 posts 36 karma points
    Apr 27, 2015 @ 16:25
    Sonni T.
    0

    Hi Ismail,

    Better late than never (to post a reply) :-)

    Ismail - you pointed me in the right direction. I ended up changing the analyzer to the StandardAnalyzer - and then I removed the standard stop words list by replacing it with an empty on.

    That did the trick. Thank you for your input!

     

    Sonni T.

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Apr 27, 2015 @ 16:57
    Ismail Mayat
    0

    Sonni,

    Awesome, dont forget to mark post as solution will help others.

    Regards

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft