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)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 16 Mar 2021 11:04:03 +0000 (12:04 +0100)
commit1ff9160a620519e1626044ff7d9205a0015ac1e4
tree1d26ac281b906d2ca1b3268937e6c1b3864502d5
parent41d33deba40622ca132560d6827157fb11322e79
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>
Koha/SearchEngine/Elasticsearch/QueryBuilder.pm
t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t