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