Bug 27307

Summary: "Keyword as phrase" option in search dropdown doesn't work with Elastic
Product: Koha Reporter: Andrew Fuerste-Henry <andrewfh>
Component: Searching - ElasticsearchAssignee: Nick Clemens <nick>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P5 - low CC: caroline.cyr-la-rose, fridolin.somers, martin.renvoize, nick, victor
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24895
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.05.00,20.11.02,20.05.09
Attachments: Bug 27307: Unit test
Bug 27307: Don't drop phrase directive when searching keyword index
Bug 27307: Unit test
Bug 27307: Don't drop phrase directive when searching keyword index
Bug 27307: Unit test
Bug 27307: Don't drop phrase directive when searching keyword index

Description Andrew Fuerste-Henry 2020-12-24 13:29:58 UTC
When using Elastic, selecting "Keyword as phrase" from the search dropdown does not properly perform a phrase search. Other "as phrase" options work correctly.
Comment 1 Nick Clemens 2020-12-24 14:08:45 UTC
Created attachment 114699 [details] [review]
Bug 27307: Unit test
Comment 2 Nick Clemens 2020-12-24 14:08:48 UTC
Created attachment 114700 [details] [review]
Bug 27307: Don't drop phrase directive when searching keyword index

We convert 'keyword' to '' as an index since we want it to search all fields

When we are searching 'as phrase', however, we should not drop the search type

To test:
 1 - Enable IntranetCatalogPullDown
 2 - Set searchEngine to Elasticsearch
 3 - Perform a search for 'Keyword as phrase' for a phrase that does appear in a record
 4 - You get the result
 5 - Reverse the order of words in the phrase
 6 - You still get a result?
 7 - Apply patch
 8 - Restart all the things
 9 - Reversed search does not return record
10 - Correct order and search, correct record returned
Comment 3 Andrew Fuerste-Henry 2020-12-24 15:33:31 UTC
Created attachment 114701 [details] [review]
Bug 27307: Unit test

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Comment 4 Andrew Fuerste-Henry 2020-12-24 15:33:34 UTC
Created attachment 114702 [details] [review]
Bug 27307: Don't drop phrase directive when searching keyword index

We convert 'keyword' to '' as an index since we want it to search all fields

When we are searching 'as phrase', however, we should not drop the search type

To test:
 1 - Enable IntranetCatalogPullDown
 2 - Set searchEngine to Elasticsearch
 3 - Perform a search for 'Keyword as phrase' for a phrase that does appear in a record
 4 - You get the result
 5 - Reverse the order of words in the phrase
 6 - You still get a result?
 7 - Apply patch
 8 - Restart all the things
 9 - Reversed search does not return record
10 - Correct order and search, correct record returned

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Comment 5 Martin Renvoize 2021-01-12 12:14:48 UTC
Created attachment 115077 [details] [review]
Bug 27307: Unit test

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 6 Martin Renvoize 2021-01-12 12:14:52 UTC
Created attachment 115078 [details] [review]
Bug 27307: Don't drop phrase directive when searching keyword index

We convert 'keyword' to '' as an index since we want it to search all fields

When we are searching 'as phrase', however, we should not drop the search type

To test:
 1 - Enable IntranetCatalogPullDown
 2 - Set searchEngine to Elasticsearch
 3 - Perform a search for 'Keyword as phrase' for a phrase that does appear in a record
 4 - You get the result
 5 - Reverse the order of words in the phrase
 6 - You still get a result?
 7 - Apply patch
 8 - Restart all the things
 9 - Reversed search does not return record
10 - Correct order and search, correct record returned

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 7 Martin Renvoize 2021-01-12 12:15:57 UTC
Works well, includes tests..

Passing QA
Comment 8 Jonathan Druart 2021-01-12 15:48:27 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 9 Fridolin Somers 2021-01-18 14:33:34 UTC
Pushed to 20.11.x for 20.11.02
Comment 10 Andrew Fuerste-Henry 2021-01-29 14:33:33 UTC
Pushed to 20.05.x for 20.05.09
Comment 11 Andrew Fuerste-Henry 2021-01-29 14:34:31 UTC
Pushed to 20.05.x for 20.05.09
Comment 12 Victor Grousset/tuxayo 2021-02-01 17:36:02 UTC
Not backported to oldoldstable (19.11.x). Feel free to ask if it's needed.