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)
committerAndrew Fuerste-Henry <andrew@bywatersolutions.com>
Tue, 23 Mar 2021 14:41:06 +0000 (14:41 +0000)
commit622a68f695c3f8e2a9736cd9cf281c49d1b1b8ec
treefe8eb379316ce3b814e4afa7a7f300732546d01f
parent8d57ef995b90a67316f6df3cf831c9160347593d
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>
(cherry picked from commit 988e1198298f3281850613d34f2c48e748915c12)

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Koha/SearchEngine/Elasticsearch/QueryBuilder.pm
t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t