Bug 19565

Summary: Fix regular expression in _truncate_terms so field names are not split up
Product: Koha Reporter: David Gustafsson <glasklas>
Component: Searching - ElasticsearchAssignee: David Gustafsson <glasklas>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P5 - low    
Version: Main   
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 19565: Fix regular expression in _truncate_terms so field names are not split up

Description David Gustafsson 2017-11-02 14:33:52 UTC
The regular expression used for extraction search terms does not allow for field names containing "." or "-". For example Control-number.raw:"123", would be split up into: "Control-number." and "raw\"123\"". "Control-number:"123" into "Control-", "number:\"123\"". The regular expression needs to be adjusted to allow for certain valid characters ("." and "-" most importantly) in field names.
Comment 1 David Gustafsson 2017-11-02 14:53:23 UTC
Created attachment 68893 [details] [review]
Bug 19565: Fix regular expression in _truncate_terms so field names are not split up

The regular expression used for tokenizing search string does not allow for field names containing "." or "-". Fix regular expression to allow for field names containing "." or "-".

Test plan:
1. Make sure Elasticsearch is used as default search engine.
2. Select "Search the catalog" in the staff client front page.
3. Search for Control-number.raw="<control number>" where <control
number> is an existing control number. (The quotes around are value are needed to prevent
Koha from appending "*" to control number).
4. The search should not yield any results.
5. Apply patch.
6. Search again using the same condition.
7. The biblio with the control number used in the search should appear as a match.
8. Search for Control-number="<control number>".
9. The biblio with the control number used in the search should appear as a match.
Comment 2 David Gustafsson 2017-11-02 14:59:38 UTC
Just saw this bug was recently reported in: "https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19559", which also contains a test case. Would be nice if "." could also be included as a valid field name character though.
Comment 3 David Gustafsson 2017-11-02 15:01:25 UTC

*** This bug has been marked as a duplicate of bug 19559 ***