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

(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-1 / +1 lines)
Lines 940-946 sub _clean_search_term { Link Here
940
    }
940
    }
941
941
942
    # Remove unquoted colons that have whitespace on either side of them
942
    # Remove unquoted colons that have whitespace on either side of them
943
    $term =~ s/(\:[:\s]+|[:\s]+:)$lookahead//g;
943
    $term =~ s/((:+)(\s+)|(\s+)(:+))$lookahead/\3\4/g;
944
944
945
    $term = $self->_query_regex_escape_process($term);
945
    $term = $self->_query_regex_escape_process($term);
946
946
(-)a/t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t (-4 / +6 lines)
Lines 187-193 subtest '_split_query() tests' => sub { Link Here
187
};
187
};
188
188
189
subtest '_clean_search_term() tests' => sub {
189
subtest '_clean_search_term() tests' => sub {
190
    plan tests => 10;
190
    plan tests => 11;
191
191
192
    my $qb;
192
    my $qb;
193
    ok(
193
    ok(
Lines 208-217 subtest '_clean_search_term() tests' => sub { Link Here
208
    is($res, ' unbalanced  quotes ', 'unbalanced quotes removed');
208
    is($res, ' unbalanced  quotes ', 'unbalanced quotes removed');
209
209
210
    $res = $qb->_clean_search_term('test : query');
210
    $res = $qb->_clean_search_term('test : query');
211
    is($res, 'test query', 'dangling colon removed');
211
    is($res, 'test  query', 'dangling colon removed');
212
212
213
    $res = $qb->_clean_search_term('test :: query');
213
    $res = $qb->_clean_search_term('test :: query');
214
    is($res, 'test query', 'dangling double colon removed');
214
    is($res, 'test  query', 'dangling double colon removed');
215
215
216
    $res = $qb->_clean_search_term('test "another : query"');
216
    $res = $qb->_clean_search_term('test "another : query"');
217
    is($res, 'test "another : query"', 'quoted dangling colon not removed');
217
    is($res, 'test "another : query"', 'quoted dangling colon not removed');
Lines 221-226 subtest '_clean_search_term() tests' => sub { Link Here
221
221
222
    $res = $qb->_clean_search_term('test {another part');
222
    $res = $qb->_clean_search_term('test {another part');
223
    is($res, 'test  another part', 'unbalanced curly brackets replaced correctly');
223
    is($res, 'test  another part', 'unbalanced curly brackets replaced correctly');
224
225
    $res = $qb->_clean_search_term('ti:test AND kw:test');
226
    is($res, 'title:test AND test', 'ti converted to title, kw converted to empty string, dangling colon removed with space preserved');
224
};
227
};
225
228
226
subtest '_join_queries' => sub {
229
subtest '_join_queries' => sub {
227
- 

Return to bug 24567