Lines 715-725
to ensure those parts are correct.
Link Here
|
715 |
sub _clean_search_term { |
715 |
sub _clean_search_term { |
716 |
my ( $self, $term ) = @_; |
716 |
my ( $self, $term ) = @_; |
717 |
|
717 |
|
|
|
718 |
my $auto_truncation = C4::Context->preference("QueryAutoTruncate") || 0; |
719 |
|
718 |
# Some hardcoded searches (like with authorities) produce things like |
720 |
# Some hardcoded searches (like with authorities) produce things like |
719 |
# 'an=123', when it ought to be 'an:123' for our purposes. |
721 |
# 'an=123', when it ought to be 'an:123' for our purposes. |
720 |
$term =~ s/=/:/g; |
722 |
$term =~ s/=/:/g; |
721 |
$term = $self->_convert_index_strings_freeform($term); |
723 |
$term = $self->_convert_index_strings_freeform($term); |
722 |
$term =~ s/[{}]/"/g; |
724 |
$term =~ s/[{}]/"/g; |
|
|
725 |
$term = $self->_truncate_terms($term) if ( $auto_truncation ); |
723 |
return $term; |
726 |
return $term; |
724 |
} |
727 |
} |
725 |
|
728 |
|
Lines 780-783
sub _sort_field {
Link Here
|
780 |
return $f; |
783 |
return $f; |
781 |
} |
784 |
} |
782 |
|
785 |
|
|
|
786 |
=head2 _truncate_terms |
787 |
|
788 |
my $query = $self->_truncate_terms($query); |
789 |
|
790 |
Given a string query this function appends '*' wildcard to all terms except |
791 |
operands. |
792 |
|
793 |
=cut |
794 |
|
795 |
sub _truncate_terms { |
796 |
my ($self, $query) = @_; |
797 |
my @stops = qw/and or not/; |
798 |
my @new_terms; |
799 |
my @split_query = split /[\(\s\)]/, $query ; |
800 |
foreach my $term ( @split_query ) { |
801 |
next if ($term eq '' || $term eq ' ' ) ; |
802 |
$term .= "*" unless ( ( grep { lc($term) =~ /^$_$/ } @stops ) || ($term =~ /\*$/ ) ); |
803 |
push @new_terms, $term; |
804 |
} |
805 |
$query=join ' ' ,@new_terms; |
806 |
return $query; |
807 |
} |
808 |
|
783 |
1; |
809 |
1; |
784 |
- |
|
|