[Koha-devel] QueryParser does not manage more than 1 operator?
Jonathan Druart
jonathan.druart at biblibre.com
Tue Dec 23 16:44:47 CET 2014
Hello dev,
I tried to hack C4::Search to permit to search for a record from its
ISBN whatever the form used (10 vs 13, with vs without dash).
I have easily done it for the non QP form (~3 lines in C4::Search::buildQuery).
It looked easy to do for using the QP too (almost the same ~3 lines in
C4::Search::parseQuery).
But I think there is a bug somewhere because the PQF query generated
by QP is wrong, or I did not use the correct syntax.
If I search for
nb:foo && nb:bar => OK
nb:foo || nb:bar => OK
But with a 3rd term:
nb:foo && nb:bar && nb:foobar => OK
nb:foo && nb:bar || nb:foobar => KO (same as nb:foo && nb:bar && nb:foobar)
nb:foo || nb:bar || nb:foobar => KO (same as nb:foo || nb:bar && nb:foobar)
Actually the second operator is always replaced with && (AND)
I don't know the the bug is come from Koha::QueryParser or OpenILS::QueryParser.
Could someone familiar with this code help me giving some tricks?
Regards,
Jonathan
PS:
The tests are:
is($QParser->target_syntax('
biblioserver', 'au:smith || ti:johnson ||
au:doe'), '@or @attr 1=1003 @attr 4=6 "smith" @or @attr 1=4 @attr 4=6
"johnson" @attr 1=1003 @attr 4=6 "doe"', 'query with 2 boolean ||');
is($QParser->target_syntax('biblioserver', 'au:smith && ( ti:johnson
|| au:doe )'), '@and @attr 1=1003 @attr 4=6 "smith" @or @attr 1=4
@attr 4=6 "johnson" @attr 1=1003 @attr 4=6 "doe"', 'query with 2
boolean && + ||');
And the result is:
# Failed test 'query with 2 boolean ||'
# at /home/koha/src/t/QueryParser.t line 56.
# got: '@or @attr 1=1003 @attr 4=6 "smith" @and @attr 1=4
@attr 4=6 "johnson" @attr 1=1003 @attr 4=6 "doe"'
# expected: '@or @attr 1=1003 @attr 4=6 "smith" @or @attr 1=4
@attr 4=6 "johnson" @attr 1=1003 @attr 4=6 "doe"'
# Failed test 'query with 2 boolean && + ||'
# at /home/koha/src/t/QueryParser.t line 59.
# got: '@and @attr 1=1003 @attr 4=6 "smith" @and @attr 1=4
@attr 4=6 "johnson" @attr 1=1003 @attr 4=6 "doe"'
# expected: '@and @attr 1=1003 @attr 4=6 "smith" @or @attr 1=4
@attr 4=6 "johnson" @attr 1=1003 @attr 4=6 "doe"'
More information about the Koha-devel
mailing list