Copied to clipboard

Flag this post as spam?

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


  • Joey 20 posts 44 karma points
    Nov 23, 2011 @ 01:39
    Joey
    0

    Examine API defect

    The following two search criterias should result in the same lucene query but they do not. The examine API is effectively ignoring Or(), And(), and Not() at the end of a statement if it is not followed by another fluent API call. This defect effectively makes it necessary to write queries in one long shot with no conditional logic. This is just not working in the real world. There is a lot of if/then/else logic that goes into searches on my site and I need the API to honor the trailing calls to Or(), And(), and Not() between calls.

     

    ISearchCriteria testCriteria1 = ExamineManager.Instance.SearchProviderCollection[sp.ProviderName].CreateSearchCriteria();
    ISearchCriteria testCriteria2 = ExamineManager.Instance.SearchProviderCollection[sp.ProviderName].CreateSearchCriteria();

    testCriteria1.GroupedAnd(new string[] { "fieldA", "fieldB" }, "myValue1").Or();
    testCriteria1.GroupedNot(new string[] { "fieldC", "fieldC" }, new string[] { "myNotValue1", "myNotValue2" }).Compile();

    testCriteria2.GroupedAnd(new string[] { "fieldA", "fieldB" }, "myValue1").Or().GroupedNot(new string[] { "fieldC", "fieldC" }, new string[] { "myNotValue1", "myNotValue2" }).Compile();

    Logger.Info(String.Format("testCriteria1: {0}", testCriteria1.ToString()));
    Logger.Info(String.Format("testCriteria2: {0}", testCriteria2.ToString()));

     

    Results: (notice the plus symbol discrepency starting at fieldC)

    testCriteria1: { SearchIndexType: , LuceneQuery: +(+fieldA:myvalue1 +fieldB:myvalue1) +(-fieldC:mynotvalue1 -fieldC:mynotvalue2) }
    testCriteria2: { SearchIndexType: , LuceneQuery: +(+fieldA:myvalue1 +fieldB:myvalue1) (-fieldC:mynotvalue1 -fieldC:mynotvalue2) }

Please Sign in or register to post replies

Write your reply to:

Draft