Copied to clipboard

Flag this post as spam?

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


  • Neil Tootell 73 posts 118 karma points
    Aug 11, 2010 @ 19:21
    Neil Tootell
    0

    Examine results doesn't match what Luke says

    Hi all,

    I'm getting on very well with Examine now, and using the fluentAPI system (nice work Shannon).

    I seem to be getting different results depending whether or not I query the index using examine or use the Java Applet Luke.

    For example

    "+((nodeName:chris sauls*)) +__IndexType:content" using examine in debug mode through VS brings back zero results, but if I do the same query on the same index using Luke I get 2 results.

    I've set the default Boolean operation to be "Or". I don't think there is any other logic in my code to interfere with the results - here's a simplified version of my code with only one query...

     

    var criteria2 = m_Searcher.CreateSearchCriteria(IndexTypes.Content, Examine.SearchCriteria.BooleanOperation.Or);

    var filter2 = criteria2.GroupedOr(

                    new string[] 
                    {  "nodeName"  },

                    new IExamineValue[] 

                    { queryText.MultipleCharacterWildcard() }

                    ).Compile();
    ISearchResults searchResults = m_Searcher.Search(filter2);

     

    Is there an extra option I have to set or is Luke just a better searcher?

    Many thanks

    Neil

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Aug 12, 2010 @ 01:03
    Aaron Powell
    0

    Luke allows you to specify a default field when doing a search, something which Examine doesn't allow.

    I think the problem is that your not escaping your search term before passing it into Examine, this part:

    nodeName:chris sauls*

    That will search on the NodeName of 'chris' and a default field of 'sauls*', and I have no idea what the default field will be interpreted as.

    To do an Escape and then a MultipleCharacterWildcard you'll need this:

    queryText.Escape().Then(string.Empty).MulipleCharacterWildcard()

    As I was writing this answer though I realised that it was a bit silly to have to pass 'string.Empty' in, so I fixed it. The latest check in allows you to do this:

    queryText.Escape().Then().MultipleCharacterWildcard()

    Should make it a bit simpler ;).

     

    And you don't need to specify the default boolean operation, in fact if you look at your compiled search query this actually doesn't do anything for you. This query:

    +((nodeName:..)) +__IndexType:...

    Is treated the same by lucene as this:

    +(+(nodeName:...)) +__IndexType:...

    The reason for using a default boolean operation that is not AND is if you wanted something like this:

    +((+nodeName:hello +nodeTypeAlias:someDocType) (+nodeName:world +nodeTypeAlias:someOtherDocType)) +__IndexType:...

    Although that example is something that's is a real fringe-case, that's what it's for, when you want multiple conditions grouped together and none of them being a 'master' condition.
    Here you'd be wanting either the nodeName to have Hello and of type someDocType OR nodeName to have World and of type someOtherDocType.

    If you didn't change the default boolean operation the first group would always have to match.

     

    Hmm... maybe I should blog this now :P

  • Neil Tootell 73 posts 118 karma points
    Aug 18, 2010 @ 19:30
    Neil Tootell
    0

    Hi Slace - thanks for the update - it was very helpful. If you do blog it - could you change the search name used please (;

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Aug 18, 2010 @ 23:49
    Aaron Powell
    0

    (For future reference here's the blog post: http://farmcode.org/post/2010/08/12/How-to-build-a-search-query-in-Examine.aspx )

    What do you mean by the search name?

Please Sign in or register to post replies

Write your reply to:

Draft