Bug 27597: Remove leading colon in ES query
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 3 Feb 2021 09:33:35 +0000 (10:33 +0100)
committerFridolin Somers <fridolin.somers@biblibre.com>
Fri, 19 Mar 2021 15:13:47 +0000 (16:13 +0100)
commit988e1198298f3281850613d34f2c48e748915c12
treeaadd59d56de4326a826fff67b12071184396c476
parent776fd1ca6b9fc88d1e3faca299af9fdea6465f6c
Bug 27597: Remove leading colon in ES query

If we are searching on kw there is a leading colon at the beginning of
the generated query:
  kw:foo becomes :foo

Note that it only happens when there is no other terms before.

Test plan:
0. Don't apply the patch
1. Search for kw:foo
2. Notice the error
  Error: Unable to perform your search. Please try again.
and the logs say
  Failed to parse query [(:foo*)]
3. Apply the patch
4. Repeat the search and notice that you know get:
   "12 result(s) found for 'kw:foo'."

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 1ff9160a620519e1626044ff7d9205a0015ac1e4)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Koha/SearchEngine/Elasticsearch/QueryBuilder.pm
t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t