Bugzilla – Attachment 147161 Details for
Bug 28884
ElasticSearch: Question mark in title search returns no results
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PATCH] Bug 28884: ElasticSearch: Question mark in title search returns no results
0001-Bug-28884-ElasticSearch-Question-mark-in-title-searc.patch (text/plain), 3.00 KB, created by
Janusz Kaczmarek
on 2023-02-22 14:57:30 UTC
(
hide
)
Description:
[PATCH] Bug 28884: ElasticSearch: Question mark in title search returns no results
Filename:
MIME Type:
Creator:
Janusz Kaczmarek
Created:
2023-02-22 14:57:30 UTC
Size:
3.00 KB
patch
obsolete
>From fa53ccb30c257058529b4904493b8ba011b9dc76 Mon Sep 17 00:00:00 2001 >From: Janusz Kaczmarek <januszop@gmail.com> >Date: Wed, 22 Feb 2023 15:45:20 +0100 >Subject: [PATCH] Bug 28884: ElasticSearch: Question mark in title search > returns no results >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >1. It happens that question mark (â?â) is contained in bibliographic >data (e.g. in title). > >2. It happens that user perform searches with that contain question >mark (e.g. searching with a title taken verbatim). > >3. In ES queries, in particular in query_string query, question >mark has a special meaning â substitutes one character >(https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-wildcard). >Question mark has also special meaning in regexp inside >quiery_string >(https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_regular_expressions). > >4. Ordinary users are not aware of this special function of the >question mark and, as a result, receive no results (e.g. >while searching for title like "Will libraries survive? : >the future of public libraries"). > >Test plan: >========== >1. Have biblio record with title like > 245 10 $a Will libraries survive? : $b the future of public libraries. > (= with question mark attached to a word) in Koha instance with ES. >2. Search for: Will libraries survive? the future of public libraries > You should get no results. >3. Apply the patch, controll that QueryRegexEscapeOptions is set to > Escape. >4. Repeat the search. You should get the record. >--- > Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index 53042b4303..6e37ab4829 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -1033,13 +1033,13 @@ sub _query_regex_escape_process { > # replaced with a more general parser solution > # so that this function is ever only provided with unquoted > # query parts >- $query =~ s@(?:(?<!\\)((?:[\\]{2})*)(?=/))(?![^"]*"(?:[^"]*"[^"]*")*[^"]*$)@\\$1@g; >+ $query =~ s@(?:(?<!\\)((?:[\\]{2})*)(?=[/\?]))(?![^"]*"(?:[^"]*"[^"]*")*[^"]*$)@\\$1@g; > } > elsif($regex_escape_options eq 'unescape_escaped') { > # Will unescape escaped slashes (\/) and escape > # unescaped slashes (/) while preserving slashes within quotes > # The same limitatations as above apply for handling of quotes >- $query =~ s@(?:(?<!\\)(?:((?:[\\]{2})*[\\])|((?:[\\]{2})*))(?=/))(?![^"]*"(?:[^"]*"[^"]*")*[^"]*$)@($1 ? substr($1, 0, -1) : ($2 . "\\"))@ge; >+ $query =~ s@(?:(?<!\\)(?:((?:[\\]{2})*[\\])|((?:[\\]{2})*))(?=[/\?]))(?![^"]*"(?:[^"]*"[^"]*")*[^"]*$)@($1 ? substr($1, 0, -1) : ($2 . "\\"))@ge; > } > } > return $query; >-- >2.30.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28884
: 147161