@@ -, +, @@ like "Harry" (i.e. with right truncation). truncation. exact word "har" in them (most likely there will be none unless you have Hebrew items). (i.e. right truncated results). --- C4/Search.pm | 5 +++++ Koha/QueryParser/Driver/PQF.pm | 26 ++++++++++++------------ Koha/QueryParser/Driver/PQF/query_plan/node.pm | 4 ++++ 3 files changed, 22 insertions(+), 13 deletions(-) --- a/C4/Search.pm +++ a/C4/Search.pm @@ -112,6 +112,7 @@ sub FindDuplicate { $titleindex = 'title|exact'; $authorindex = 'author|exact'; $op = '&&'; + $QParser->custom_data->{'QueryAutoTruncate'} = C4::Context->preference('QueryAutoTruncate'); } else { $titleindex = 'ti,ext'; $authorindex = 'au,ext'; @@ -233,6 +234,9 @@ sub SimpleSearch { my $QParser; $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser') && ! ($query =~ m/\w,\w|\w=\w/)); + if ($QParser) { + $QParser->custom_data->{'QueryAutoTruncate'} = C4::Context->preference('QueryAutoTruncate'); + } # Initialize & Search Zebra for ( my $i = 0 ; $i < @servers ; $i++ ) { @@ -1177,6 +1181,7 @@ sub parseQuery { if ($QParser) { + $QParser->custom_data->{'QueryAutoTruncate'} = C4::Context->preference('QueryAutoTruncate'); $query = ''; for ( my $ii = 0 ; $ii <= @operands ; $ii++ ) { next unless $operands[$ii]; --- a/Koha/QueryParser/Driver/PQF.pm +++ a/Koha/QueryParser/Driver/PQF.pm @@ -349,23 +349,23 @@ not want to use it. sub clear_all_configuration { my ($self) = @_; %OpenILS::QueryParser::parser_config = ( - 'OpenILS::QueryParser' => { + 'OpenILS::QueryParser' => { filters => [], modifiers => [], operators => { - 'and' => '&&', - 'or' => '||', - float_start => '{{', - float_end => '}}', - group_start => '(', - group_end => ')', - required => '+', - disallowed => '-', - modifier => '#', - negated => '!' + 'and' => '&&', + 'or' => '||', + float_start => '{{', + float_end => '}}', + group_start => '(', + group_end => ')', + required => '+', + disallowed => '-', + modifier => '#', + negated => '!' } - } - ); + } + ); return $self; } --- a/Koha/QueryParser/Driver/PQF/query_plan/node.pm +++ a/Koha/QueryParser/Driver/PQF/query_plan/node.pm @@ -57,6 +57,7 @@ sub target_syntax { $phrase =~ s/"/\\"/g; $pqf .= ' @or ' x (scalar(@fields) - 1); foreach my $attributes (@fields) { + $attributes->{'attr_string'} ||= ''; $pqf .= $attributes->{'attr_string'} . ($attributes->{'4'} ? '' : ' @attr 4=1') . ' "' . $phrase . '" '; } $atom_count++; @@ -70,6 +71,9 @@ sub target_syntax { $pqf .= ' @or ' x (scalar(@fields) - 1); foreach my $attributes (@fields) { $attributes->{'attr_string'} ||= ''; + if ($self->plan->QueryParser->custom_data->{'QueryAutoTruncate'} || $atom->suffix eq '*') { + $attributes->{'attr_string'} .= ($attributes->{'5'} ? '' : ' @attr 5=1 '); + } $pqf .= $attributes->{'attr_string'} . ($attributes->{'4'} ? '' : ' @attr 4=6 ') . $atom_content . ' '; } $atom_count++; --