Bug 22228

Summary: Elasticsearch - standalone colons should be escaped when performing a search
Product: Koha Reporter: Nick Clemens <nick>
Component: Searching - ElasticsearchAssignee: Ere Maijala <ere.maijala>
Status: CLOSED FIXED QA Contact: Josef Moravec <josef.moravec>
Severity: normal    
Priority: P5 - low CC: ere.maijala, fridolin.somers, josef.moravec, lucas, marjorie.barry-vila, martin.renvoize
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 22228: Escape lone colons and make sure term is balanced
Bug 22228: Escape lone colons and make sure term is balanced
Bug 22228: Escape lone colons and make sure term is balanced

Description Nick Clemens 2019-01-29 16:30:23 UTC
Currently if you search with a colon it can cause failure or no results

To recreate:
Search for a term containing a colon
i.e. Harry potter : the creature vault
Note search fails
Now try
Harry potter \: the creature vault
It works (maybe returns nothing)
Comment 1 Ere Maijala 2019-01-31 11:54:42 UTC
Created attachment 84568 [details] [review]
Bug 22228: Escape lone colons and make sure term is balanced

Escapes unquoted colons that have whitespace on either side. Removed unbalanced quotes.

Test plan:

1. Make sure the test case described in the bug works
2. Make sure tests pass:
  prove t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t
Comment 2 Björn Nylén 2019-03-04 14:04:51 UTC
Created attachment 85993 [details] [review]
Bug 22228: Escape lone colons and make sure term is balanced

Escapes unquoted colons that have whitespace on either side. Removed unbalanced quotes.

Test plan:

1. Make sure the test case described in the bug works
2. Make sure tests pass:
  prove t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t

Signed-off-by: Björn Nylén <bjorn.nylen(at)ub.lu.se>
Comment 3 Josef Moravec 2019-03-04 15:58:02 UTC
Created attachment 86010 [details] [review]
Bug 22228: Escape lone colons and make sure term is balanced

Escapes unquoted colons that have whitespace on either side. Removed unbalanced quotes.

Test plan:

1. Make sure the test case described in the bug works
2. Make sure tests pass:
  prove t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t

Signed-off-by: Björn Nylén <bjorn.nylen(at)ub.lu.se>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 4 Nick Clemens 2019-03-04 18:49:55 UTC
Awesome work all!

Pushed to master for 19.05
Comment 5 Martin Renvoize 2019-03-05 15:09:13 UTC
Pushed to 18.11.x for 18.11.04
Comment 6 Lucas Gass 2019-03-13 16:13:56 UTC
not backporting this to the 18.05.x series