View | Details | Raw Unified | Return to bug 28316
Collapse All | Expand All

(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-1 / +15 lines)
Lines 940-945 sub _clean_search_term { Link Here
940
940
941
    $term = $self->_query_regex_escape_process($term);
941
    $term = $self->_query_regex_escape_process($term);
942
942
943
    # because of _truncate_terms and if QueryAutoTruncate enabled
944
    # we will have any special operators ruined by _truncate_terms:
945
    # for ex. search for "test [6 TO 7]" will be converted to "test* [6* TO* 7]"
946
    # so no reason to keep ranges in QueryAutoTruncate==true case:
947
    my $truncate = C4::Context->preference("QueryAutoTruncate") || 0;
948
    unless($truncate) {
949
        # replace all ranges with any square/curly brackets combinations to temporary substitutions (ex: "{a TO b]"" -> "~~LC~~a TO b~~RS~~")
950
        $term =~ s/(\{|\[)([^\s\[\]\{\}]+ TO [^\s\[\]\{\}]+)(\}|\])/'~~L'.($1 eq '[' ? 'S':'C').'~~'.$2.'~~R'.($3 eq ']' ? 'S':'C').'~~'/ge;
951
    }
952
943
    # save all regex contents away before escaping brackets:
953
    # save all regex contents away before escaping brackets:
944
    my @saved_regexes;
954
    my @saved_regexes;
945
    my $rgx_i = 0;
955
    my $rgx_i = 0;
Lines 974-979 sub _clean_search_term { Link Here
974
        $term =~ s/~~XI$i~~/$saved_regexes[$i]/;
984
        $term =~ s/~~XI$i~~/$saved_regexes[$i]/;
975
    }
985
    }
976
986
987
    unless($truncate) {
988
        # restore temporary weird substitutions back to normal brackets
989
        $term =~ s/~~L(C|S)~~([^\s\[\]\{\}]+ TO [^\s\[\]\{\}]+)~~R(C|S)~~/($1 eq 'S' ? '[':'{').$2.($3 eq 'S' ? ']':'}')/ge;
990
    }
991
977
    return $term;
992
    return $term;
978
}
993
}
979
994
980
- 

Return to bug 28316