Bug 24103

Summary: Add option to dump built search query to templates
Product: Koha Reporter: Nick Clemens <nick>
Component: Architecture, internals, and plumbingAssignee: Nick Clemens <nick>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: 1joynelson, david, ere.maijala, jonathan.druart, katrin.fischer, kyle, lucas, martin.renvoize, mkstephens
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24110
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
This enhancement allows you to view the search query used by Zebra or Elasticsearch, to help with troubleshooting. To use, enable the new system preference DumpSearchQueryTemplate, enable `DumpTemplateVarsIntranet` and `DumpTemplateVarsOpac`, and then search the page source in the staff interface or OPAC for 'search_query'. **New system preference**: `DumpSearchQueryTemplate` defaults to disabled.
Version(s) released in:
20.05.00, 19.11.05
Bug Depends on:    
Bug Blocks: 30543    
Attachments: Bug 24103: Add option to dump search query to templates
Bug 24103: (follow-up) Dump query on opac authorities search
Bug 24103: Add option to dump search query to templates
Bug 24103: (follow-up) Dump query on opac authorities search
Bug 24103: Add option to dump search query to templates
Bug 24103: (follow-up) Dump query on opac authorities search
Bug 24103: Add option to dump search query to templates
Bug 24103: (follow-up) Dump query on opac authorities search

Description Nick Clemens 2019-11-25 15:02:14 UTC
It would be nice to be able to see what is actually being searched in the search engine when performing a query
Comment 1 Nick Clemens 2019-11-25 15:09:00 UTC Comment hidden (obsolete)
Comment 2 Myka Kennedy Stephens 2020-01-19 00:36:57 UTC Comment hidden (obsolete)
Comment 3 Nick Clemens 2020-02-14 11:36:52 UTC
Created attachment 98928 [details] [review]
Bug 24103: (follow-up) Dump query on opac authorities search
Comment 4 Owen Leonard 2020-02-14 19:36:16 UTC
Created attachment 99023 [details] [review]
Bug 24103: Add option to dump search query to templates

To test:
1 - Apply patch, update database
2 - Note new syspref 'DumpSearchQueryTemplate'
3 - Leave it off
4 - Enable DumpTemplateVariablesOpac and Staff
5 - Search on staff and opac
6 - View the source
7 - Search for 'search_query' - you shouldn't find it
8 - Enable the new pref
9 - Repeat, but you should find the query
10 - Test staff/opac search and advanced search, cataloguing search, authority search, authfinder search, adding to a basket form a new biblio
11 - All should work and show the query
12 - This will work under both ES and Zebra

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 5 Owen Leonard 2020-02-14 19:36:19 UTC
Created attachment 99024 [details] [review]
Bug 24103: (follow-up) Dump query on opac authorities search

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 6 Owen Leonard 2020-02-14 19:38:22 UTC
I tested these under Zebra ONLY, so I don't think I can mark this as signed off. But I wanted to at least give a signoff for Zebra.
Comment 7 David Nind 2020-02-15 02:58:37 UTC
Created attachment 99054 [details] [review]
Bug 24103: Add option to dump search query to templates

To test:
1 - Apply the patch, update the database 
    (perl installer/data/mysql/updatedatabase.pl)
2 - Note new system preference 'DumpSearchQueryTemplate'
3 - Leave it off
4 - Enable DumpTemplateVarsIntranet and DumpTemplateVarsOpac system 
    preferences
5 - Search on staff and opac
6 - View the page source
7 - Search for 'search_query' - you shouldn't find it
8 - Enable the new system preference
9 - Repeat steps 5-7, but you should now find the 'search_query'
10 - Test staff/opac search and advanced search, cataloguing search, 
     authority search, authfinder search
     (/cgi-bin/koha/authorities/auth_finder.pl),
     adding to a basket form a new biblio
11 - All should work and show the query
12 - This will work under both ES and Zebra

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: David Nind <david@davidnind.com>
Comment 8 David Nind 2020-02-15 02:58:41 UTC
Created attachment 99055 [details] [review]
Bug 24103: (follow-up) Dump query on opac authorities search

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: David Nind <david@davidnind.com>
Comment 9 David Nind 2020-02-15 03:01:15 UTC
Tested on Elastic Search and everything works as per the test plan.

To enable Elastic Search on koha-testing-docker:
1) Start up with ku-es6 (instead of just ku)
   (see the note at bottom of koha-testing-docker README
   about 'Having Elasticsearch run')
2) Change the search engine from Zebra to Elasticsearch
   (SearchEngine system preference)
3) Reindex the content: go into the container using kshell 
   then change to the koha directory and run
   ./misc/search_tools/rebuild_elasticsearch.pl -v -d
4) Search in either the staff interface or OPAC to make sure
   you get results
Comment 10 Katrin Fischer 2020-02-17 22:10:36 UTC
I'd like it if this was not tied to the other preferences. It makes it hard to work with and not sure if we couldn't just have added to the output without needing a new pref? But working and helpful - passing QA.
Comment 11 Katrin Fischer 2020-02-17 22:11:22 UTC
Created attachment 99137 [details] [review]
Bug 24103: Add option to dump search query to templates

To test:
1 - Apply patch, update database
2 - Note new syspref 'DumpSearchQueryTemplate'
3 - Leave it off
4 - Enable DumpTemplateVariablesOpac and Staff
5 - Search on staff and opac
6 - View the source
7 - Search for 'search_query' - you shouldn't find it
8 - Enable the new pref
9 - Repeat, but you should find the query
10 - Test staff/opac search and advanced search, cataloguing search, authority search, authfinder search, adding to a basket form a new biblio
11 - All should work and show the query
12 - This will work under both ES and Zebra

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 12 Katrin Fischer 2020-02-17 22:11:26 UTC
Created attachment 99138 [details] [review]
Bug 24103: (follow-up) Dump query on opac authorities search

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 13 Martin Renvoize 2020-02-19 16:13:06 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 14 Joy Nelson 2020-03-13 00:41:46 UTC
enhancement not backported to 19.11.x
Comment 15 Joy Nelson 2020-04-01 15:38:36 UTC
Backported to 19.11.x branch for 19.11.05
Comment 16 Lucas Gass 2020-04-08 21:04:46 UTC
not backporting enhancement to 19.05