[Xapian-discuss] Query parser bug?
    Ron Kass 
    ron at pidgintech.com
       
    Mon Oct 22 15:38:17 BST 2007
    
    
  
The following test script was written to test what I found as a possible 
bug in query parser
    #!/usr/bin/perl
    use strict;
    use Search::Xapian qw/:standard/;
    my $QueryParser = new Search::Xapian::QueryParser();
    $QueryParser->set_default_op(OP_AND);
    $QueryParser->set_stemmer(new Search::Xapian::Stem("english"));
    $QueryParser->set_stemming_strategy(STEM_SOME);
    print "this script is to test the LoveHate feature. Notice that when
    phrases are not surrounded by brackets, the -notallowed translates
    to a regular AND search rather than a AND_NOT as it should be\n\n";
    print "right: ".$QueryParser->parse_query(qq{testing search
    -notallowed},(FLAG_BOOLEAN | FLAG_PHRASE | FLAG_LOVEHATE |
    FLAG_WILDCARD))."\n";
    print "right: ".$QueryParser->parse_query(qq{("testing phrase")
    -notallowed},(FLAG_BOOLEAN | FLAG_PHRASE | FLAG_LOVEHATE |
    FLAG_WILDCARD))."\n";
    print "wrong: ".$QueryParser->parse_query(qq{"testing phrase"
    -notallowed},(FLAG_BOOLEAN | FLAG_PHRASE | FLAG_LOVEHATE |
    FLAG_WILDCARD))."\n";  
This is the output:
    this script is to test the LoveHate feature. Notice that when
    phrases are not surrounded by brackets, the -notallowed translates
    to a regular AND search rather than a AND_NOT as it should be
    right: Xapian::Query(((Ztest:(pos=1) AND Zsearch:(pos=2)) AND_NOT
    Znotallow:(pos=3)))
    right: Xapian::Query(((testing:(pos=1) PHRASE 2 phrase:(pos=2))
    AND_NOT Znotallow:(pos=3)))
    wrong: Xapian::Query(((testing:(pos=1) PHRASE 2 phrase:(pos=2)) AND
    Znotallow:(pos=3)))
Notice that the third search has [AND Znotallow:(pos=3)] rather than 
[AND_NOT Znotallow:(pos=3)]
As you can see from the second, if forcing the phrase into (), it 
manages to parse the query properly, but it should have done the same 
without it.
Your thoughts?
Ron
    
    
More information about the Xapian-discuss
mailing list