Copied to clipboard

Flag this post as spam?

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


  • Pawel Bres 39 posts 160 karma points c-trib
    Apr 24, 2015 @ 00:32
    Pawel Bres
    0

    Examine - GroupedNot issue

    Hi folks, I ran into strange situation with GroupedNot method, when I'm trying to set NodeTypeAlias filter and then GroupedNot filter like this:

    _searchCriteria.NodeTypeAlias("myDocumentTypeAlias");
    _searchCriteria.GroupedNot(new[] { "id" }.ToList(), new [] {"1","2","3"});
    

    I'm getting Lucene Query like this:

    LuceneQuery: {+__NodeTypeAlias:myDocumentTypeAlias +(-id:1)}
    

    So I has correct NodeTypeAlias value but the rest is messed up. Instead of

    +(-id:1) 
    

    there should be

    -id:(1 2 3) 
    or 
    -id:1 -id:2 -id:3 
    or 
    -(id:1 id:2 id:3)
    

    For example if I make the same steps with GroupedOr method, Examine appears to work correctly:

    _searchCriteria.NodeTypeAlias("myDocumentTypeAlias");
    _searchCriteria.GroupedOr(new[] { "id" }.ToList(), new [] {"1","2","3"});
    

    gives:

    +__NodeTypeAlias:myDocumentTypeAlias +(id:1 id:2 id:3)
    

    Any ideas if this is a bug or a feature ? :)

    Many thanks, Pawel

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Apr 24, 2015 @ 15:56
    Ismail Mayat
    100

    Pawel,

    I would raise it on issue tracker looks like there is a problem with the underlying DSL that generates the lucene query. For now as a working around you can make the query yourself and use examine raw query.

    Regards

    Ismail

  • Pawel Bres 39 posts 160 karma points c-trib
    Apr 24, 2015 @ 16:09
    Pawel Bres
    0

    Hey Ismail,

    big thanks for reply!

    that's what I'm going to do, I was just wondering if it is something underlying or I'm doing something wrong.

    Greetings,

    Pawel

  • Shannon Deminick 1524 posts 5270 karma points MVP 2x
    Apr 27, 2015 @ 00:34
    Shannon Deminick
    0

    @Pawel, did you create an issue ? https://github.com/Shazwazza/examine/issues

    Also you are not using And() which is how to join things (or Or() or Not()):

     _searchCriteria.NodeTypeAlias("myDocumentTypeAlias")
          .And()
          .GroupedNot(new[] { "id" }.ToList(), new [] {"1","2","3"});
    

    Please create an issue on the tracker so it can be resolved.

  • Pawel Bres 39 posts 160 karma points c-trib
    Apr 27, 2015 @ 11:07
    Pawel Bres
    0

    Hi Shannon,

    I'm using searchCriteria with default operation set to AND, so in the end it looks like the code you've posted.

    I think the soulution might be to ommit AND operation when parsing query from Examine do Lucene because by default NOT operator works like AND NOT.

    I will post the issue on github and I could also try to fix it if you have better things to do right now :)

    Cheers,

    Pawel

  • Shannon Deminick 1524 posts 5270 karma points MVP 2x
    Apr 27, 2015 @ 11:11
    Shannon Deminick
    0

    Well Examine's AND OR and NOT aren't really synonymous with Lucene. The syntax was created so that people familiar with SQL query logic could try to grasp what is happening. The And() operator just ensures that a '+' is prefixed (in lucene = MUST) and Or() doesn't prefix anything and NOT() is actually synonymous and prefixes '-'

    I've actually never tested not having the fluent And(), Or() or Not() fluency with queries so if it works that is by fluke i suppose. If you post the issue with steps to re-create i'll fix it this week as I need to release another update.

Please Sign in or register to post replies

Write your reply to:

Draft