Copied to clipboard

Flag this post as spam?

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


  • René Pjengaard 118 posts 702 karma points c-trib
    Feb 16, 2011 @ 20:41
    René Pjengaard
    0

    Examine confusion

    Hi there,

    i´m a bit lost right now. I´m trying to create an index with examine, and i need the analyser to accept lowercase. Ex. I need Examine to find the word "Exception" when i search for "exception". I have read some forum posts, where Slace recomends using the StandardAnalyzer for both the indexer and the searcher (http://our.umbraco.org/forum/developers/extending-umbraco/14449-Examine-Search-Incase-sensitive). I have tried that, and it still won´t work. The wird part is, that if i use the searchbox in the backend it finds words, even though the search is in lower case.

    I have rebuild the index (deleted folder + save & publish) with the StandardAnalyzer.

     

     

    I have also tried to open the index in Luke, and do a search on bodyText with StandardAnalyzer. Result: no luck!

    The code for the searchpage looks like this:

    SearchTerm = Request.QueryString["q"].Trim().ToLower();
    string[] searchFields = FieldsToSearh.Split(',');

    if(string.IsNullOrEmpty(SearchTerm)) return;

    var criteria = ExamineManager.Instance
    .SearchProviderCollection[ExamineSearchName]
    .CreateSearchCriteria(UmbracoExamine.IndexTypes.Content);
    var query = criteria
    .GroupedOr(searchFields, SearchTerm)
    .Or()
    .GroupedOr(searchFields, SearchTerm.MultipleCharacterWildcard())
    .Not()
    .Field("umbracoNaviHide", "1");
    SearchResults = ExamineManager.Instance.Search(query.Compile()).Distinct();
    SearchCount = SearchResults.Count();
    SearchResultListing.DataSource = SearchResults;
    SearchResultListing.DataBind();

     

    Actually i belive it worked before i upgraded the solution to 4.6.1, but i´m not sure.

    Can anyone help me with this one?

     

    Cheers
    René

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Feb 17, 2011 @ 10:15
    Ismail Mayat
    0

    Rene,

    What you do get when you query with luke? http://www.getopt.org/luke/

  • René Pjengaard 118 posts 702 karma points c-trib
    Feb 17, 2011 @ 10:25
    René Pjengaard
    0

    Hi Ismail,

    if I for example search for the name "rasmus" in the field bodyText with the StandardAnalyzer i get two results. But no results doing the same with the code above.

     

    Thanks
    René

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Feb 17, 2011 @ 10:30
    Ismail Mayat
    0

    Are you using the latest Examine from codeplex?

    Regards

     

    Ismail

  • René Pjengaard 118 posts 702 karma points c-trib
    Feb 17, 2011 @ 10:35
    René Pjengaard
    0

    I use the on that came with Umbraco 4.6.1. Actually i think it worked before i upgradet to 4.6.1

     

    René

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Feb 17, 2011 @ 10:47
    Ismail Mayat
    0

    after the query.Compile() statement can you do a criteria.ToString() and write that out and paste here it should give you the actual lucene query generated.  compare that query with what actually works with luke see if you can see any issues there.

    Regards

    Ismail

  • René Pjengaard 118 posts 702 karma points c-trib
    Feb 17, 2011 @ 12:33
    René Pjengaard
    0

    Thanks for you input. Here is the output from my search: 

    {
    SearchIndexType: content,
    LuceneQuery: +(+(
    nodeName:rasmus
    bodyText:rasmus
    medarbejderFornavn:rasmus
    medarbejderEfternavn:rasmus
    medarbejderEmail:rasmus) (
    nodeName:rasmus*
    bodyText:rasmus*
    medarbejderFornavn:rasmus*
    medarbejderEfternavn:rasmus*
    medarbejderEmail:rasmus*)
    -umbracoNaviHide:1) +__IndexType:content }

    Is there a way to se the compiled search from Luke?

     

    Regards
    René

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Feb 17, 2011 @ 12:39
    Ismail Mayat
    1

    Rene,

    Try pasting that query i.e.

     +(+(
    nodeName:rasmus 
    bodyText:rasmus 
    medarbejderFornavn:rasmus 
    medarbejderEfternavn:rasmus 
    medarbejderEmail:rasmus) (
    nodeName:rasmus* 
    bodyText:rasmus* 
    medarbejderFornavn:rasmus* 
    medarbejderEfternavn:rasmus* 
    medarbejderEmail:rasmus*) 
    -umbracoNaviHide:1) +__IndexType:content

     

    into luke and fiddle with it until you figure out what is stopping it from working. One thing i do with my indexes is add all the fields content into one combined field called contents and do search on that. The advantage of this is i dont have to do group query i can just query on that one contents field so my query ends like contents:blah* +__IndexType:content 

    Regards

    Ismail

  • René Pjengaard 118 posts 702 karma points c-trib
    Feb 17, 2011 @ 12:54
    René Pjengaard
    0

    Thanks Ismail,

    i really preciate your help. When i put the query in Luke i get results?!?! What is the differens between my search and Luke? 

    How do you combine the fields content into one combined field? In the index or in the search control (usercontrol)?

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Feb 17, 2011 @ 12:58
    Ismail Mayat
    1

    what is the analyser being used in luke standard?  You can get disparity with results when using different analysers usually if using whitespace and standard if both same in your code and luke then you should get same results.

    with regards to combined field you need to implement gatheringnode method and inject combined field in there see slaces cg10 examine demo for sample code or if your really stuck i can paste some code for you.

  • René Pjengaard 118 posts 702 karma points c-trib
    Feb 17, 2011 @ 13:14
    René Pjengaard
    0

    Hi again,

    found the problem. Even though i have assigned the provider in the code it wouldn´t work (see below). Then when i changed the defaultProvider for ExamineSearchProviders to the new searcher it worked exactly as in Luke

     var criteria = ExamineManager.Instance.SearchProviderCollection[ExamineSearchName].CreateSearchCriteria(UmbracoExamine.IndexTypes.Content);

    Once again, thanks a lot Ismail, you really helped me understand Examine better. I´ll buy you a drink at CG11 ;-)

    Cheers
    René

Please Sign in or register to post replies

Write your reply to:

Draft