Bug 27113 - Elasticsearch: Autocomplete in search
Summary: Elasticsearch: Autocomplete in search
Status: BLOCKED
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching - Elasticsearch (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Hammat wele
QA Contact:
URL:
Keywords:
Depends on: 25870 32734
Blocks: 27428
  Show dependency treegraph
 
Reported: 2020-11-27 20:17 UTC by Ivan Dziuba
Modified: 2024-06-18 23:10 UTC (History)
17 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Medium patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This enhancement adds autocomplete suggestions for searches in the OPAC and staff interface, including the advanced search forms (when using Elasticsearch). This is enabled using two new system preferences: - StaffInterfaceAutocompleteElasticsearch - OPACAutocompleteElasticSearch Note: For this to work the search index needs rebuilding.
Version(s) released in:
Circulation function:


Attachments
Bug 27113: ElasticSearch: Autocomplete in input search (48.06 KB, patch)
2020-12-03 21:26 UTC, Ivan Dziuba
Details | Diff | Splinter Review
Result (34.12 KB, image/png)
2020-12-03 21:32 UTC, Ivan Dziuba
Details
Bug 27113: ElasticSearch: Autocomplete in input search (52.57 KB, patch)
2021-01-07 21:17 UTC, Ivan Dziuba
Details | Diff | Splinter Review
Bug 27113: ElasticSearch: Autocomplete in input search (44.85 KB, patch)
2021-01-13 16:30 UTC, Ivan Dziuba
Details | Diff | Splinter Review
Bug 27113: ElasticSearch: Autocomplete in input search (43.41 KB, patch)
2021-02-03 19:42 UTC, Ivan Dziuba
Details | Diff | Splinter Review
Bug 27113: ElasticSearch: Autocomplete in input search (43.52 KB, patch)
2021-04-21 21:29 UTC, Ivan Dziuba
Details | Diff | Splinter Review
Bug 27113: ElasticSearch: Autocomplete in input search (45.27 KB, patch)
2021-04-22 21:33 UTC, Ivan Dziuba
Details | Diff | Splinter Review
Bug 27113: ElasticSearch: Autocomplete in input search (45.27 KB, patch)
2021-04-22 21:35 UTC, Ivan Dziuba
Details | Diff | Splinter Review
Bug 27113: (follow-up) Move new CSS to main SCSS files (7.66 KB, patch)
2021-04-23 12:44 UTC, Owen Leonard
Details | Diff | Splinter Review
GIF showing the buggy behavior (249.57 KB, image/gif)
2021-04-23 12:50 UTC, Owen Leonard
Details
Bug 27113: (follow-up) Move new CSS to main SCSS files (7.78 KB, patch)
2021-04-23 14:13 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 27113: ElasticSearch: Autocomplete in input search (45.27 KB, patch)
2021-04-23 21:24 UTC, Ivan Dziuba
Details | Diff | Splinter Review
Bug 27113: (follow-up) QA Tests (6.03 KB, patch)
2021-04-23 21:24 UTC, Ivan Dziuba
Details | Diff | Splinter Review
Bug 27113: (follow-up) QA Tests (10.45 KB, patch)
2021-05-10 19:27 UTC, Ivan Dziuba
Details | Diff | Splinter Review
I have changed CGI::Session->new() from CGI::Session->load() for use session. This condition - 'CGI::Session->load() or die CGI::Session->errstr();' (2.81 KB, patch)
2021-05-28 20:44 UTC, Ivan Dziuba
Details | Diff | Splinter Review
Bug 27113: (follow-up) Correction with Session (1.86 KB, patch)
2021-05-28 20:49 UTC, Ivan Dziuba
Details | Diff | Splinter Review
Bug 27113: ElasticSearch: Autocomplete in input search (45.32 KB, patch)
2021-06-03 00:50 UTC, David Nind
Details | Diff | Splinter Review
Bug 27113: (follow-up) QA Tests (10.49 KB, patch)
2021-06-03 00:50 UTC, David Nind
Details | Diff | Splinter Review
Bug 27113: (follow-up) Correction with Session (1.91 KB, patch)
2021-06-03 00:50 UTC, David Nind
Details | Diff | Splinter Review
Bug 27113: (follow-up) Move new CSS to main SCSS files (7.79 KB, patch)
2021-06-03 00:51 UTC, David Nind
Details | Diff | Splinter Review
Bug 27113: ElasticSearch: Autocomplete in input search (45.40 KB, patch)
2022-03-01 19:49 UTC, The Minh Luong
Details | Diff | Splinter Review
Bug 27113: (follow-up) QA Tests (10.49 KB, patch)
2022-03-01 19:49 UTC, The Minh Luong
Details | Diff | Splinter Review
Bug 27113: (follow-up) Correction with Session (1.91 KB, patch)
2022-03-01 19:49 UTC, The Minh Luong
Details | Diff | Splinter Review
Bug 27113: (follow-up) Move new CSS to main SCSS files (7.79 KB, patch)
2022-03-01 19:49 UTC, The Minh Luong
Details | Diff | Splinter Review
Bug 27113: Rebase and correct autocomplete appearance (2.78 KB, patch)
2022-03-01 19:49 UTC, The Minh Luong
Details | Diff | Splinter Review
Bug 27113: ElasticSearch: Autocomplete in input search (44.88 KB, patch)
2022-03-28 19:53 UTC, The Minh Luong
Details | Diff | Splinter Review
Bug 27113: (follow-up) QA Tests (10.49 KB, patch)
2022-03-28 19:53 UTC, The Minh Luong
Details | Diff | Splinter Review
Bug 27113: (follow-up) Correction with Session (1.91 KB, patch)
2022-03-28 19:53 UTC, The Minh Luong
Details | Diff | Splinter Review
Bug 27113: (follow-up) Move new CSS to main SCSS files (7.81 KB, patch)
2022-03-28 19:53 UTC, The Minh Luong
Details | Diff | Splinter Review
Bug 27113: Rebase and correct autocomplete appearance (2.78 KB, patch)
2022-03-28 19:53 UTC, The Minh Luong
Details | Diff | Splinter Review
Bug 27113: No autosubmit after clicking autocomplete option in advanced search (3.63 KB, patch)
2022-03-31 18:21 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: Removes items in OPACHiddenItems from autocomplete (5.77 KB, patch)
2022-04-04 16:10 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: Removes items in OPACHiddenItems from autocomplete (5.72 KB, patch)
2022-04-04 16:37 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: Removes hidden and suppressed items from OPAC autocomplete (6.30 KB, patch)
2022-04-06 14:54 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: Focus the input after selecting "Search the catalog" (963 bytes, patch)
2022-04-06 16:56 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: ElasticSearch: Autocomplete in input search (52.22 KB, patch)
2022-04-19 17:23 UTC, Blou
Details | Diff | Splinter Review
Bug 27113: ElasticSearch: Autocomplete in input search (52.22 KB, patch)
2022-04-19 17:31 UTC, Blou
Details | Diff | Splinter Review
Bug 27113: (follow-up) Move new CSS to main SCSS files (7.79 KB, patch)
2022-04-19 17:31 UTC, Blou
Details | Diff | Splinter Review
Bug 27113: ElasticSearch: Autocomplete in input search (51.31 KB, patch)
2022-06-17 21:13 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: ElasticSearch: Autocomplete in input search (50.31 KB, patch)
2022-06-23 18:06 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: (follow-up) Move new CSS to main SCSS files (7.79 KB, patch)
2022-06-23 18:07 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: (follow-up) Update descriptions for system preferences (1.72 KB, patch)
2022-06-23 22:45 UTC, David Nind
Details | Diff | Splinter Review
Bug 27113 - Advanced search - more options display issue (89.30 KB, application/pdf)
2022-06-23 23:17 UTC, David Nind
Details
Bug 27113: (follow-up) fix adv. searches - more options display issue (841 bytes, patch)
2022-06-27 16:21 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: ElasticSearch: Autocomplete in input search (50.36 KB, patch)
2022-06-27 18:37 UTC, David Nind
Details | Diff | Splinter Review
Bug 27113: (follow-up) Move new CSS to main SCSS files (7.84 KB, patch)
2022-06-27 18:37 UTC, David Nind
Details | Diff | Splinter Review
Bug 27113: (follow-up) Update descriptions for system preferences (1.77 KB, patch)
2022-06-27 18:38 UTC, David Nind
Details | Diff | Splinter Review
Bug 27113: (follow-up) fix adv. searches - more options display issue (889 bytes, patch)
2022-06-27 18:38 UTC, David Nind
Details | Diff | Splinter Review
Bug 27113: ElasticSearch: Autocomplete in input search (50.33 KB, patch)
2022-07-08 21:05 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: (follow-up) Move new CSS to main SCSS files (7.84 KB, patch)
2022-07-08 21:05 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: (follow-up) Update descriptions for system preferences (1.77 KB, patch)
2022-07-08 21:05 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: (follow-up) fix adv. searches - more options display issue (889 bytes, patch)
2022-07-08 21:05 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: ElasticSearch: Autocomplete in input search (51.58 KB, patch)
2022-07-15 16:15 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: (follow-up) Move new CSS to main SCSS files (7.84 KB, patch)
2022-07-15 16:15 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: (follow-up) Update descriptions for system preferences (1.77 KB, patch)
2022-07-15 16:15 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: (follow-up) fix adv. searches - more options display issue (889 bytes, patch)
2022-07-15 16:15 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: (follow-up) replace removed GetMarcBiblio (1.54 KB, patch)
2022-08-22 19:10 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: Allow for ending special characters in titles (1.57 KB, patch)
2022-10-06 18:29 UTC, Blou
Details | Diff | Splinter Review
Bug 27113: (follow-up) diacritics/acccents in sought word would make autocomplete return nothing (2.21 KB, patch)
2023-01-09 21:35 UTC, Blou
Details | Diff | Splinter Review
Bug 27113: Move filterAutocomplete to a new module and filter the result at search time (9.14 KB, patch)
2023-02-02 15:41 UTC, Hammat wele
Details | Diff | Splinter Review
Bug 27113: (follow-up) Move new CSS to main SCSS files (8.87 KB, patch)
2023-12-12 18:56 UTC, Salah Ghedda
Details | Diff | Splinter Review
Bug 27113: (follow-up) Update descriptions for system preferences (1.77 KB, patch)
2023-12-12 18:56 UTC, Salah Ghedda
Details | Diff | Splinter Review
Bug 27113: (follow-up) fix adv. searches - more options display issue (889 bytes, patch)
2023-12-12 18:56 UTC, Salah Ghedda
Details | Diff | Splinter Review
Bug 27113: (follow-up) replace removed GetMarcBiblio (1.54 KB, patch)
2023-12-12 18:56 UTC, Salah Ghedda
Details | Diff | Splinter Review
Bug 27113: Allow for ending special characters in titles (1.57 KB, patch)
2023-12-12 18:56 UTC, Salah Ghedda
Details | Diff | Splinter Review
Bug 27113: (follow-up) diacritics/acccents in sought word would make autocomplete return nothing (2.21 KB, patch)
2023-12-12 18:56 UTC, Salah Ghedda
Details | Diff | Splinter Review
Bug 27113: Move filterAutocomplete to a new module and filter the result at search time (9.12 KB, patch)
2023-12-12 18:56 UTC, Salah Ghedda
Details | Diff | Splinter Review
Bug 27113: ElasticSearch: Autocomplete in input search (51.61 KB, patch)
2023-12-20 17:09 UTC, Salah Ghedda
Details | Diff | Splinter Review
Bug 27113: (follow-up) Move new CSS to main SCSS files (8.87 KB, patch)
2023-12-20 17:09 UTC, Salah Ghedda
Details | Diff | Splinter Review
Bug 27113: (follow-up) Update descriptions for system preferences (1.77 KB, patch)
2023-12-20 17:09 UTC, Salah Ghedda
Details | Diff | Splinter Review
Bug 27113: (follow-up) fix adv. searches - more options display issue (889 bytes, patch)
2023-12-20 17:09 UTC, Salah Ghedda
Details | Diff | Splinter Review
Bug 27113: (follow-up) replace removed GetMarcBiblio (1.54 KB, patch)
2023-12-20 17:09 UTC, Salah Ghedda
Details | Diff | Splinter Review
Bug 27113: Allow for ending special characters in titles (1.57 KB, patch)
2023-12-20 17:09 UTC, Salah Ghedda
Details | Diff | Splinter Review
Bug 27113: (follow-up) diacritics/acccents in sought word would make autocomplete return nothing (2.21 KB, patch)
2023-12-20 17:09 UTC, Salah Ghedda
Details | Diff | Splinter Review
Bug 27113: Move filterAutocomplete to a new module and filter the result at search time (9.12 KB, patch)
2023-12-20 17:09 UTC, Salah Ghedda
Details | Diff | Splinter Review
Bug 27113: Fix the Input Size of the Catalog Search Bar (1.48 KB, text/plain)
2023-12-20 17:09 UTC, Salah Ghedda
Details
Bug 27113: Fix the Input Size of the Catalog Search Bar (838 bytes, text/plain)
2024-01-16 21:22 UTC, Hammat wele
Details
Bug 27113: Fix the Input Size of the Catalog Search Bar (1.52 KB, patch)
2024-01-16 21:30 UTC, Hammat wele
Details | Diff | Splinter Review
Bug 27113: Fix the issue of the cursor not displaying (881 bytes, patch)
2024-03-25 15:20 UTC, Matthias Le Gac
Details | Diff | Splinter Review
Bug 27113: ElasticSearch: Autocomplete in input search (51.78 KB, patch)
2024-04-30 13:56 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: (follow-up) Move new CSS to main SCSS files (7.91 KB, patch)
2024-04-30 13:56 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: (follow-up) Update descriptions for system preferences (1.77 KB, patch)
2024-04-30 13:56 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: (follow-up) fix adv. searches - more options display issue (889 bytes, patch)
2024-04-30 13:56 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: (follow-up) replace removed GetMarcBiblio (1.54 KB, patch)
2024-04-30 13:56 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: Allow for ending special characters in titles (1.57 KB, patch)
2024-04-30 13:56 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: (follow-up) diacritics/acccents in sought word would make autocomplete return nothing (2.21 KB, patch)
2024-04-30 13:56 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: Move filterAutocomplete to a new module and filter the result at search time (9.12 KB, patch)
2024-04-30 13:56 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: Fix the Input Size of the Catalog Search Bar (1.52 KB, patch)
2024-04-30 13:56 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: Fix the issue of the cursor not displaying (879 bytes, patch)
2024-04-30 13:57 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: Fix input size of all searchbar (857 bytes, patch)
2024-04-30 15:30 UTC, Shi Yao Wang
Details | Diff | Splinter Review
Bug 27113: Fix input size of all searchbar (907 bytes, patch)
2024-04-30 17:03 UTC, Shi Yao Wang
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Dziuba 2020-11-27 20:17:39 UTC

    
Comment 1 Ivan Dziuba 2020-12-03 21:26:59 UTC Comment hidden (obsolete)
Comment 2 Ivan Dziuba 2020-12-03 21:32:38 UTC
Created attachment 114169 [details]
Result
Comment 3 Ivan Dziuba 2021-01-07 21:17:34 UTC Comment hidden (obsolete)
Comment 4 Fridolin Somers 2021-01-08 08:13:07 UTC
Whaou I like this :D

Just a question :
The patch changes some unrelated text in installer/data/mysql/mandatory/sysprefs.sql :
-('AnonymousPatron','0',NULL,'Set the identifier (borrowernumber) of the anonymous patron. Used for suggestion and checkout history privacy',''),
+('AnonymousPatron','0',NULL,'Set the identifier (borrowernumber) of the anonymous patron. Used for Suggestion and reading history privacy',''),

Looks like is it unwanted.
Comment 5 Fridolin Somers 2021-01-08 08:18:56 UTC
In koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc
 + var OL_PREVIEW = _("Preview");

Why this ?
Comment 6 Fridolin Somers 2021-01-08 08:23:46 UTC
I see :
api/elasticsearch/intranet-autocomplete.pl

This is strange, its not using the REST API right ?

Its more a perl script like :
opac/svc/elasticsearch/opac-autocomplete.pl

Should be in svc/elasticsearch I'd say.

BTW :
It is possible to use the REST API ?
It whould provide the service for both opac and intranet.

Best regards,
Comment 7 Ivan Dziuba 2021-01-08 19:54:52 UTC
Yes, I see many errors in the files. I will change it.
I would like to provide the service for both opac and intranet through REST API. But, I see many preferences for REST API:

('RESTBasicAuth'- 'If enabled, Basic authentication is enabled for the REST API.','YesNo'),
('RESTdefaultPageSize' - 'Default page size for endpoints listing objects','Integer'),
('RESTOAuth2ClientCredentials' - 'If enabled, the OAuth2 client credentials flow is enabled for the REST API.','YesNo'),
('RESTPublicAnonymousRequests' -'If enabled, the API will allow anonymous access to public routes that don\'t require authenticated access.','YesNo'),
('RESTPublicAPI' - 'If enabled, the REST API will expose the /public endpoints.','YesNo')

I am not sure that good idea for OPAC because REST API uses Auth. 
It is possible to disable authentication in the preferences for REST API, but this may have a consequences...

Do you have a solution about this?

Thanks!
Comment 8 Fridolin Somers 2021-01-11 10:57:21 UTC
I think you can provide a public API for OPAC :
https://wiki.koha-community.org/wiki/REST_api_RFCs#Unprivileged_.28public.29_routes

datas are the same as searching with OPAC website.
Comment 9 Ivan Dziuba 2021-01-11 15:26:25 UTC
Are you sure that OPAC search uses REST API? It's only GET request (with parametres 'q', 'idx', ...) for file opac-search.pl and return a results for template *-results.tt. 
I don't see here REST API.

Best regards,
Comment 10 Ivan Dziuba 2021-01-13 16:30:36 UTC Comment hidden (obsolete)
Comment 11 Fridolin Somers 2021-01-19 15:43:57 UTC
(In reply to Ivan Dziuba from comment #9)
> Are you sure that OPAC search uses REST API? It's only GET request (with
> parametres 'q', 'idx', ...) for file opac-search.pl and return a results for
> template *-results.tt. 
> I don't see here REST API.
> 
> Best regards,

No indeed, search is not actually using API.

I say your autocomplete feature should use a dedicated API service.
Comment 12 Ivan Dziuba 2021-02-03 19:42:35 UTC Comment hidden (obsolete)
Comment 13 Ivan Dziuba 2021-04-21 21:29:11 UTC
Created attachment 119979 [details] [review]
Bug 27113: ElasticSearch: Autocomplete in input search

Bug 27113: ElasticSearch: Autocomplete in input search. Fix bugs.

Bug 27113: ElasticSearch: Autocomplete in input search. Use Unicode::Normalize instead Text::Unaccent.
Comment 14 Owen Leonard 2021-04-22 12:29:28 UTC
This is very cool, and is working well in the OPAC. I don't think you need to add a separate CSS file. I think it should be incorporated into the main one. It's not a large enough addition to necessitate a separate file.

I wonder if we should have an entry at the end of the autocomplete menu every time which the user can click on to submit the string they've entered? For instance, I type "dogs," and the autocomplete shows the first 10 results. A last menu item could say, "See full search results for <dogs>" or something like that?

This patch adds the feature to the OPAC and staff interface but only adds one preference. I think it should be separated into two, one for each interface.

It doesn't work for me in the staff interface. There is an error:

"Could not compile /kohadevbox/koha/api/elasticsearch/autocomplete.pl: Can't locate Switch.pm in @INC (you may need to install the Switch module)"

There are many errors flagged by the QA tool.

There are instances of "console.log" in the code which must be removed.
Comment 15 Blou 2021-04-22 13:06:27 UTC
Good idea on the button.  But I asked Ivan to focus on feature at hand and everything else can be a new BZ.  If he gets it through, it'll be easy to add on afterward.

For the .css, you mean merging autocomplete.css into opac.css ?  Couldn't that be a RM thing at the end, if really needed?  Otherwise that makes the rebasing very painful. Ivan is certainly not at ease with that demand.
Comment 16 Owen Leonard 2021-04-22 13:48:54 UTC
(In reply to Blou from comment #15)

> For the .css, you mean merging autocomplete.css into opac.css ?

I mean adding the contents of autocomplete.css into opac.scss. I'd be happy to submit a follow-up for this part, converting the CSS to SCSS, if that would help.
Comment 17 Katrin Fischer 2021-04-22 19:34:32 UTC
(In reply to Blou from comment #15)
> Good idea on the button.  But I asked Ivan to focus on feature at hand and
> everything else can be a new BZ.  If he gets it through, it'll be easy to
> add on afterward.
> 
> For the .css, you mean merging autocomplete.css into opac.css ?  Couldn't
> that be a RM thing at the end, if really needed?  Otherwise that makes the
> rebasing very painful. Ivan is certainly not at ease with that demand.

The RM will generate the scss files, you don't need to submit those. But they won't merge CSS changes into the css files. But the risk of conflict is not usually high there.
Comment 18 Ivan Dziuba 2021-04-22 21:33:30 UTC Comment hidden (obsolete)
Comment 19 Ivan Dziuba 2021-04-22 21:35:14 UTC
Created attachment 120029 [details] [review]
Bug 27113: ElasticSearch: Autocomplete in input search

Usually the user knows only part of the title of the book or only the name of the author, etc. When he start search something Koha (ElasticSearch) predicts the rest of a word or expression which user is typing.  Autocomplete predicts that thanks to index of ElasticSearch.

TEST PLAN
Important! In this patch we need to do reindex ElasticSearch. ElasticSearch must have all information in his index.
1. Go Intranet -> Preference -> SearchEngine -> ElasticSearch
!! APPLY PATCH !!
2. Mapping is good (Intranet -> Catalog -> Search engine configuration (Elasticsearch) ).
!Recommended 'Reset Mapping'  -> 'Yes'
3. In your koha-conf.xml file you must have good <index_name> for <elasticsearch> and version ES
4. Update Preference:
./installer/data/mysql/updatedatabase.pl
If that passe good you can look the lines:
 - DEV atomic update: bug_27113-elasticsearch_autocomplete_input_search.perl
 - Upgrade to XXX done : Bug 27113 - Autocomplete input on main page with elasticsearch
5. After that we can look two options in the preferences:
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
4. For add information in the index we must run script for reindexing:
./misc/search_tools/rebuild_elasticsearch.pl -v -d
5. Waiting for the end of indexing
6. Go on Preference and find :
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
Value "Show" turn on autocomplete.
7. Now we have Autocomplete for Intranet/OPAC search input (advanced search also).
Comment 20 Owen Leonard 2021-04-23 12:44:13 UTC
Created attachment 120084 [details] [review]
Bug 27113: (follow-up) Move new CSS to main SCSS files

This patch removes the separate CSS files added for the autocomplete
feature and puts them into the "main" SCSS files. I think a separate
file isn't necessary because the amount of CSS it adds is so small.

I've also tweaked the style of the autocomplete menu shown when you use
the arrow keys to navigate through the autocomplete choices. I think the
previous white-on-light-green didn't have enough contrast.

To test, follow the previous test plan, being careful to observe how it
works when the autocomplete menu has been triggered and you use the
arrow keys to navigate through the results.
Comment 21 Owen Leonard 2021-04-23 12:50:49 UTC
Created attachment 120088 [details]
GIF showing the buggy behavior

I have to mark this "Failed QA" again because the QA tool issues were not all addressed. Please run the QA tool and fix the problems it raises.

The only other thing I noticed in testing today was that there is a change in behavior of the search tabs in the staff client. The layout is off, and the focus doesn't move to the input field like it does on the other tabs. See the attached screen grab.
Comment 22 Ivan Dziuba 2021-04-23 13:51:01 UTC
(In reply to Owen Leonard from comment #21)
> Created attachment 120088 [details]
> GIF showing the buggy behavior
> 
> I have to mark this "Failed QA" again because the QA tool issues were not
> all addressed. Please run the QA tool and fix the problems it raises.
> 
> The only other thing I noticed in testing today was that there is a change
> in behavior of the search tabs in the staff client. The layout is off, and
> the focus doesn't move to the input field like it does on the other tabs.
> See the attached screen grab.

You have changed/moved CSS files and it provoke your problem with the layout (it was not good idea). Katrin Fischer gave you notice of that!  
Thanks!
Comment 23 Owen Leonard 2021-04-23 14:08:39 UTC
(In reply to Ivan Dziuba from comment #22)
> You have changed/moved CSS files and it provoke your problem with the layout

Okay, but the issue with the input field focus is the same without my follow-up.
Comment 24 Owen Leonard 2021-04-23 14:13:14 UTC
(In reply to Owen Leonard from comment #21)
> The layout is off

My mistake--I recorded that screengrab without having rebuilt the CSS from SCSS. I will modify the test plan to make that part clear.
Comment 25 Owen Leonard 2021-04-23 14:13:32 UTC
Created attachment 120109 [details] [review]
Bug 27113: (follow-up) Move new CSS to main SCSS files

This patch removes the separate CSS files added for the autocomplete
feature and puts them into the "main" SCSS files. I think a separate
file isn't necessary because the amount of CSS it adds is so small.

I've also tweaked the style of the autocomplete menu shown when you use
the arrow keys to navigate through the autocomplete choices. I think the
previous white-on-light-green didn't have enough contrast.

To test you must rebuild the OPAC and staff client CSS:
https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client

Follow the previous test plan, being careful to observe how it
works when the autocomplete menu has been triggered and you use the
arrow keys to navigate through the results.
Comment 26 Ivan Dziuba 2021-04-23 21:24:50 UTC
Created attachment 120140 [details] [review]
Bug 27113: ElasticSearch: Autocomplete in input search

Usually the user knows only part of the title of the book or only the name of the author, etc. When he start search something Koha (ElasticSearch) predicts the rest of a word or expression which user is typing.  Autocomplete predicts that thanks to index of ElasticSearch.

TEST PLAN
Important! In this patch we need to do reindex ElasticSearch. ElasticSearch must have all information in his index.
1. Go Intranet -> Preference -> SearchEngine -> ElasticSearch
!! APPLY PATCH !!
2. Mapping is good (Intranet -> Catalog -> Search engine configuration (Elasticsearch) ).
!Recommended 'Reset Mapping'  -> 'Yes'
3. In your koha-conf.xml file you must have good <index_name> for <elasticsearch> and version ES
4. Update Preference:
./installer/data/mysql/updatedatabase.pl
If that passe good you can look the lines:
 - DEV atomic update: bug_27113-elasticsearch_autocomplete_input_search.perl
 - Upgrade to XXX done : Bug 27113 - Autocomplete input on main page with elasticsearch
5. After that we can look two options in the preferences:
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
4. For add information in the index we must run script for reindexing:
./misc/search_tools/rebuild_elasticsearch.pl -v -d
5. Waiting for the end of indexing
6. Go on Preference and find :
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
Value "Show" turn on autocomplete.
7. Now we have Autocomplete for Intranet/OPAC search input (advanced search also).
Comment 27 Ivan Dziuba 2021-04-23 21:24:54 UTC
Created attachment 120141 [details] [review]
Bug 27113: (follow-up) QA Tests

Bug 27113: (follow-up) QA Tests (2)
Comment 28 Katrin Fischer 2021-04-24 10:23:24 UTC
> 
> You have changed/moved CSS files and it provoke your problem with the layout
> (it was not good idea). Katrin Fischer gave you notice of that!  
> Thanks!

I think I am the one who messed up here. Owen is our GUI expert, what he says goes :) I think where I got confused was the file endings. It should have been: RM does generate .css files, but you should commit the .scss changes.

(Basically, the fiels that are minified and generated - don't submit them, but the normal ones you need to).

Owen, please feel free to correct if I got it not quite right again.
Comment 29 Ivan Dziuba 2021-05-10 19:27:38 UTC
Created attachment 120806 [details] [review]
Bug 27113: (follow-up) QA Tests

Bug 27113: (follow-up) QA Tests (2)

Bug 27113: (follow-up) Fixup warnings.

TEST PLAN
Important! In this patch we need to do reindex ElasticSearch. ElasticSearch must have all information in his index.
1. Go Intranet -> Preference -> SearchEngine -> ElasticSearch
!! APPLY PATCH !!
2. Mapping is good (Intranet -> Catalog -> Search engine configuration (Elasticsearch) ).
!Recommended 'Reset Mapping'  -> 'Yes'
3. In your koha-conf.xml file you must have good <index_name> for <elasticsearch> and version ES
4. Update Preference:
./installer/data/mysql/updatedatabase.pl
If that passe good you can look the lines:
 - DEV atomic update: bug_27113-elasticsearch_autocomplete_input_search.perl
 - Upgrade to XXX done : Bug 27113 - Autocomplete input on main page with elasticsearch
5. After that we can look two options in the preferences:
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
4. For add information in the index we must run script for reindexing:
./misc/search_tools/rebuild_elasticsearch.pl -v -d
5. Waiting for the end of indexing
6. Go on Preference and find :
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
Value "Show" turn on autocomplete.
7. Now we have Autocomplete for Intranet/OPAC search input (advanced search also).
Comment 30 Ivan Dziuba 2021-05-28 20:44:37 UTC Comment hidden (obsolete)
Comment 31 Ivan Dziuba 2021-05-28 20:49:07 UTC
Created attachment 121498 [details] [review]
Bug 27113: (follow-up) Correction with Session

I have changed CGI::Session->new() from CGI::Session->load() for use session. This condition - 'CGI::Session->load() or die CGI::Session->errstr();'

I am not sure that was good idea to use 'die' in this condition...What do you think?
Thanks!
Comment 32 David Nind 2021-05-29 23:14:37 UTC
Patch no longer applies 8-(...

Bug 27113 - ElasticSearch: Autocomplete in input search

120109 - Bug 27113: (follow-up) Move new CSS to main SCSS files
120140 - Bug 27113: ElasticSearch: Autocomplete in input search
120806 - Bug 27113: (follow-up) QA Tests
121498 - Bug 27113: (follow-up) Correction with Session

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 27113: (follow-up) Move new CSS to main SCSS files
error: sha1 information is lacking or useless (koha-tmpl/intranet-tmpl/prog/css/elasticsearch/autocomplete.css).
error: could not build fake ancestor
Patch failed at 0001 Bug 27113: (follow-up) Move new CSS to main SCSS files
Comment 33 Ivan Dziuba 2021-05-31 16:07:58 UTC
(In reply to David Nind from comment #32)
> Patch no longer applies 8-(...
> 
> Bug 27113 - ElasticSearch: Autocomplete in input search
> 
> 120109 - Bug 27113: (follow-up) Move new CSS to main SCSS files
> 120140 - Bug 27113: ElasticSearch: Autocomplete in input search
> 120806 - Bug 27113: (follow-up) QA Tests
> 121498 - Bug 27113: (follow-up) Correction with Session
> 
> Apply? [(y)es, (n)o, (i)nteractive] y
> Applying: Bug 27113: (follow-up) Move new CSS to main SCSS files
> error: sha1 information is lacking or useless
> (koha-tmpl/intranet-tmpl/prog/css/elasticsearch/autocomplete.css).
> error: could not build fake ancestor
> Patch failed at 0001 Bug 27113: (follow-up) Move new CSS to main SCSS files

I checked it and it works :). Do you use Koha 21.05? Thanks.

Bug 27113 - ElasticSearch: Autocomplete in input search

120109 - Bug 27113: (follow-up) Move new CSS to main SCSS files
120140 - Bug 27113: ElasticSearch: Autocomplete in input search
120806 - Bug 27113: (follow-up) QA Tests
121498 - Bug 27113: (follow-up) Correction with Session

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 27113: (follow-up) Move new CSS to main SCSS files
Using index info to reconstruct a base tree...
A       koha-tmpl/intranet-tmpl/prog/css/elasticsearch/autocomplete.css
M       koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc
A       koha-tmpl/opac-tmpl/bootstrap/css/opac-elasticsearch/opac-autocomplete.css
M       koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss
M       koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc
Falling back to patching base and 3-way merge...
Auto-merging koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss
Applying: Bug 27113: ElasticSearch: Autocomplete in input search
Applying: Bug 27113: (follow-up) QA Tests
Applying: Bug 27113: (follow-up) Correction with Session
Comment 34 Tomás Cohen Arazi (tcohen) 2021-06-01 15:53:20 UTC
I agree with Fridolin: we should think of adding API routes for this. There should be a privileged route, and an unprivileged route.
You shouldn't worry about sessions and all. Just add the required permissions to interact with the routes.
Comment 35 Blou 2021-06-01 18:14:30 UTC
I'm sorry Tomas, this really muddied the picture for Ivan, and I can't help him as I've no idea how he should proceed.

Do you mean his 
api/elasticsearch/elasticsearch.pl should be put under /v1/ and the routes added to swagger, etc...   Any wiki to help him there?

We had hope this would get into 21.05 initially, but right now it looks like Ivan will recode it for the foreseable future.  Which won't happen, I'll give him one more go at it then drop it.
Comment 36 David Cook 2021-06-02 03:39:53 UTC
(In reply to Tomás Cohen Arazi from comment #34)
> I agree with Fridolin: we should think of adding API routes for this. There
> should be a privileged route, and an unprivileged route.
> You shouldn't worry about sessions and all. Just add the required
> permissions to interact with the routes.

Yeah, I don't get why session data is being used here. 

I don't even know if there needs to be 2 routes. Maybe just 1 public/unprivileged API route.
Comment 37 David Cook 2021-06-02 03:40:39 UTC
Also, it's not clear from the test plan what the user is expected to see/do in terms of the autocomplete...
Comment 38 David Nind 2021-06-02 21:56:46 UTC
(In reply to Ivan Dziuba from comment #33)
..
> I checked it and it works :). Do you use Koha 21.05? Thanks.
..

Hi Ivan. I'm using master - I tried again and still get the same error for the CSS follow-up patch:

..
Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 27113: (follow-up) Move new CSS to main SCSS files
error: sha1 information is lacking or useless (koha-tmpl/intranet-tmpl/prog/css/elasticsearch/autocomplete.css).
error: could not build fake ancestor
Patch failed at 0001 Bug 27113: (follow-up) Move new CSS to main SCSS files
..

I can get the patches to apply if I use interactive, comment out the CSS follow-up patch, then apply again using interactive and then just apply the CSS follow-up patch.

I'm assuming the error is because the follow-up CSS is being applied first, but what it is changing doesn't exist yet as it is one of the later patches.

I don't know enough about patches to fix this up, but will try and test with what I have.
Comment 39 David Nind 2021-06-03 00:50:43 UTC
Created attachment 121555 [details] [review]
Bug 27113: ElasticSearch: Autocomplete in input search

Usually the user knows only part of the title of the book or only the name of the author, etc. When he start search something Koha (ElasticSearch) predicts the rest of a word or expression which user is typing.  Autocomplete predicts that thanks to index of ElasticSearch.

TEST PLAN
Important! In this patch we need to do reindex ElasticSearch. ElasticSearch must have all information in his index.
1. Go Intranet -> Preference -> SearchEngine -> ElasticSearch
!! APPLY PATCH !!
2. Mapping is good (Intranet -> Catalog -> Search engine configuration (Elasticsearch) ).
!Recommended 'Reset Mapping'  -> 'Yes'
3. In your koha-conf.xml file you must have good <index_name> for <elasticsearch> and version ES
4. Update Preference:
./installer/data/mysql/updatedatabase.pl
If that passe good you can look the lines:
 - DEV atomic update: bug_27113-elasticsearch_autocomplete_input_search.perl
 - Upgrade to XXX done : Bug 27113 - Autocomplete input on main page with elasticsearch
5. After that we can look two options in the preferences:
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
4. For add information in the index we must run script for reindexing:
./misc/search_tools/rebuild_elasticsearch.pl -v -d
5. Waiting for the end of indexing
6. Go on Preference and find :
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
Value "Show" turn on autocomplete.
7. Now we have Autocomplete for Intranet/OPAC search input (advanced search also).

Signed-off-by: David Nind <david@davidnind.com>
Comment 40 David Nind 2021-06-03 00:50:50 UTC
Created attachment 121556 [details] [review]
Bug 27113: (follow-up) QA Tests

Bug 27113: (follow-up) QA Tests (2)

Bug 27113: (follow-up) Fixup warnings.

TEST PLAN
Important! In this patch we need to do reindex ElasticSearch. ElasticSearch must have all information in his index.
1. Go Intranet -> Preference -> SearchEngine -> ElasticSearch
!! APPLY PATCH !!
2. Mapping is good (Intranet -> Catalog -> Search engine configuration (Elasticsearch) ).
!Recommended 'Reset Mapping'  -> 'Yes'
3. In your koha-conf.xml file you must have good <index_name> for <elasticsearch> and version ES
4. Update Preference:
./installer/data/mysql/updatedatabase.pl
If that passe good you can look the lines:
 - DEV atomic update: bug_27113-elasticsearch_autocomplete_input_search.perl
 - Upgrade to XXX done : Bug 27113 - Autocomplete input on main page with elasticsearch
5. After that we can look two options in the preferences:
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
4. For add information in the index we must run script for reindexing:
./misc/search_tools/rebuild_elasticsearch.pl -v -d
5. Waiting for the end of indexing
6. Go on Preference and find :
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
Value "Show" turn on autocomplete.
7. Now we have Autocomplete for Intranet/OPAC search input (advanced search also).

Signed-off-by: David Nind <david@davidnind.com>
Comment 41 David Nind 2021-06-03 00:50:57 UTC
Created attachment 121557 [details] [review]
Bug 27113: (follow-up) Correction with Session

I have changed CGI::Session->new() from CGI::Session->load() for use session. This condition - 'CGI::Session->load() or die CGI::Session->errstr();'

I am not sure that was good idea to use 'die' in this condition...What do you think?
Thanks!

Signed-off-by: David Nind <david@davidnind.com>
Comment 42 David Nind 2021-06-03 00:51:04 UTC
Created attachment 121558 [details] [review]
Bug 27113: (follow-up) Move new CSS to main SCSS files

This patch removes the separate CSS files added for the autocomplete
feature and puts them into the "main" SCSS files. I think a separate
file isn't necessary because the amount of CSS it adds is so small.

I've also tweaked the style of the autocomplete menu shown when you use
the arrow keys to navigate through the autocomplete choices. I think the
previous white-on-light-green didn't have enough contrast.

To test you must rebuild the OPAC and staff client CSS:
https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client

Follow the previous test plan, being careful to observe how it
works when the autocomplete menu has been triggered and you use the
arrow keys to navigate through the results.

Signed-off-by: David Nind <david@davidnind.com>
Comment 43 David Nind 2021-06-03 00:55:36 UTC
I finally got this to work for me, and it is a really nice feature. Nice work!

I've signed off, but these are my suggestions for the wording for the new system preferences - the QA Team will probably comment on this is as well, so you may as well get ahead of them!:

1. IntranetAutocompleteElasticSearch: change system preference name to StaffInterfaceAutocompleteElasticsearch - We are using 'staff interface' now, instead of 'intranet' - not sure what the protocol is for system preference names, but for new system preferences we should probably start using StaffInterface; Elasticsearch doesn't have a capital S (see for example the SearchEngine system preference)

2. Wording for IntranetAutocompleteElasticSearch: 
   . Currently: Don't show/Show looking terms based on a provided text by using an ElasticSearch for Intranet. 
   . Suggested: Don't show/Show search suggestions in the staff interface when using Elasticsearch. 

3. Wording for OPACAutocompleteElasticSearch: 
   . Currently: Don't show/Show looking terms based on a provided text by using an ElasticSearch for OPAC. 
   . Change to: Don't show/Show search suggestions in the OPAC when using Elasticsearch.
   
Other testing notes (using koha-testing-docker):
. Package command to rebuild the index: koha-elasticsearch -d --rebuild -a -b kohadev
. Needed to change .env file as a result of recent commits to koha-testing-docker for Elasticsearch (compared default with custom .env file and added new variables)
. As indicated earlier, had to apply patch interactively: 1st excluding CSS patch, then again to include CSS patch
. Rebuild CSS as per CSS patch
Comment 44 David Cook 2021-06-03 01:42:45 UTC
I am tempted to mark this as Failed QA, since I'm pretty sure the session handling doesn't work as intended (I think it's saving the session data in a file rather than in the database), but I haven't actually tested it, so leaving it as is.
Comment 45 Katrin Fischer 2021-06-03 09:46:15 UTC
As QA: I really like David's suggestions for the rephrasing. I think it makes the use much more clear. But before spending time on these, we probably need to sort out the other requirements/comments.

Sessions: 
* David, can you be a bit more precise about what you think doesn't work?
* Tomas, can you help with what you imagined and maybe the sessions bit? Does this need to be fixed here or could it be a follow-up?

(In reply to Tomás Cohen Arazi from comment #34)
> I agree with Fridolin: we should think of adding API routes for this. There
> should be a privileged route, and an unprivileged route.
> You shouldn't worry about sessions and all. Just add the required
> permissions to interact with the routes.
Comment 46 Blou 2021-06-03 12:39:42 UTC
Ivan has already recoded it without sessions in our codebase.  But before pushing that change, we'll be waiting for Tomas' instructions regarding the svc/
Comment 47 Katrin Fischer 2021-06-03 12:41:38 UTC
(In reply to Blou from comment #46)
> Ivan has already recoded it without sessions in our codebase.  But before
> pushing that change, we'll be waiting for Tomas' instructions regarding the
> svc/

Hi Blou, thx for the update! So we can scratch that off the list. I'll ask Tomas to have another look.
Comment 48 David Cook 2021-06-03 23:57:52 UTC
(In reply to Blou from comment #46)
> Ivan has already recoded it without sessions in our codebase.  But before
> pushing that change, we'll be waiting for Tomas' instructions regarding the
> svc/

I'll mostly leave it to Tomas, but it might be worth looking over https://wiki.koha-community.org/wiki/Rest_Api_HowTo

Basically, the "svc/" API scripts are legacy, so we don't want to be adding new ones. We just want to build up the Mojolicious-based REST API.
Comment 49 Tomás Cohen Arazi (tcohen) 2021-06-08 19:27:32 UTC
(In reply to Blou from comment #46)
> Ivan has already recoded it without sessions in our codebase.  But before
> pushing that change, we'll be waiting for Tomas' instructions regarding the
> svc/

I think this is a subject worth discussing in the open, i.e. in koha-devel.

As I mentioned (not sure where) I believe we could try adding some filtering capabilities to GET /biblios to accomplish this. I proposed something similar on bug 25870. In that case, I proposed a 'q_ccl' query param that could take a CCL query so we could accept complex queries. The route would then extract the ids (biblionumbers) and return Koha::Biblios->to_api objects as required.

I don't think CCL is a cool feature, but it felt like good start: allowing people to query records through the API.

The ES syntax might be a high constraint for the feature (leaving Zebra users out), specially if you are querying things like title, author, etc. But that's another possibility: add a query parameter that only works with ES (q_es?).

Regarding routes, you need to think what the response would look like. And it will help you figure what you want. Is it ok/enough for GET /biblios?<filter> to return JSON representation of the biblio+biblioitems table columns? Unfortunately, the OpenAPI v2.0 schema doesn't provide a way to define different response schemas for different content-type responses, and thus we left GET /biblios/:biblio_id under-documented (it is supported on v3) but you can try

GET /biblios/1

and see the response to get an idea of what we already return [1].

It feels like we need to build a good query language, and reuse this routes.

[1] This is how we build the JSON representation of a biblio https://git.koha-community.org/Koha-community/Koha/src/branch/master/Koha/Biblio.pm#L867-L892
Comment 50 Ivan Dziuba 2021-06-14 19:39:02 UTC
(In reply to Tomás Cohen Arazi from comment #49)
> (In reply to Blou from comment #46)
> > Ivan has already recoded it without sessions in our codebase.  But before
> > pushing that change, we'll be waiting for Tomas' instructions regarding the
> > svc/
> 
> I think this is a subject worth discussing in the open, i.e. in koha-devel.
> 
> As I mentioned (not sure where) I believe we could try adding some filtering
> capabilities to GET /biblios to accomplish this. I proposed something
> similar on bug 25870. In that case, I proposed a 'q_ccl' query param that
> could take a CCL query so we could accept complex queries. The route would
> then extract the ids (biblionumbers) and return Koha::Biblios->to_api
> objects as required.
> 
> I don't think CCL is a cool feature, but it felt like good start: allowing
> people to query records through the API.
> 
> The ES syntax might be a high constraint for the feature (leaving Zebra
> users out), specially if you are querying things like title, author, etc.
> But that's another possibility: add a query parameter that only works with
> ES (q_es?).
> 
> Regarding routes, you need to think what the response would look like. And
> it will help you figure what you want. Is it ok/enough for GET
> /biblios?<filter> to return JSON representation of the biblio+biblioitems
> table columns? Unfortunately, the OpenAPI v2.0 schema doesn't provide a way
> to define different response schemas for different content-type responses,
> and thus we left GET /biblios/:biblio_id under-documented (it is supported
> on v3) but you can try
> 
> GET /biblios/1
> 
> and see the response to get an idea of what we already return [1].
> 
> It feels like we need to build a good query language, and reuse this routes.
> 
> [1] This is how we build the JSON representation of a biblio
> https://git.koha-community.org/Koha-community/Koha/src/branch/master/Koha/
> Biblio.pm#L867-L892

I don't understand what is it means `It feels like we need to build a good query language, and reuse these routes.`? 
Here I use dynamic queries $q, $prefix and a kind of "$token" to understand for which query hints were returned and whether to show or skip them. (depends on the speed of writing).

Could you please clarify the structure of URL for that.

Thanks!
Comment 51 The Minh Luong 2022-03-01 19:49:07 UTC
Created attachment 131207 [details] [review]
Bug 27113: ElasticSearch: Autocomplete in input search

Usually the user knows only part of the title of the book or only the name of the author, etc. When he start search something Koha (ElasticSearch) predicts the rest of a word or expression which user is typing.  Autocomplete predicts that thanks to index of ElasticSearch.

TEST PLAN
Important! In this patch we need to do reindex ElasticSearch. ElasticSearch must have all information in his index.
1. Go Intranet -> Preference -> SearchEngine -> ElasticSearch
!! APPLY PATCH !!
2. Mapping is good (Intranet -> Catalog -> Search engine configuration (Elasticsearch) ).
!Recommended 'Reset Mapping'  -> 'Yes'
3. In your koha-conf.xml file you must have good <index_name> for <elasticsearch> and version ES
4. Update Preference:
./installer/data/mysql/updatedatabase.pl
If that passe good you can look the lines:
 - DEV atomic update: bug_27113-elasticsearch_autocomplete_input_search.perl
 - Upgrade to XXX done : Bug 27113 - Autocomplete input on main page with elasticsearch
5. After that we can look two options in the preferences:
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
4. For add information in the index we must run script for reindexing:
./misc/search_tools/rebuild_elasticsearch.pl -v -d
5. Waiting for the end of indexing
6. Go on Preference and find :
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
Value "Show" turn on autocomplete.
7. Now we have Autocomplete for Intranet/OPAC search input (advanced search also).

Signed-off-by: David Nind <david@davidnind.com>
Comment 52 The Minh Luong 2022-03-01 19:49:12 UTC
Created attachment 131208 [details] [review]
Bug 27113: (follow-up) QA Tests

Bug 27113: (follow-up) QA Tests (2)

Bug 27113: (follow-up) Fixup warnings.

TEST PLAN
Important! In this patch we need to do reindex ElasticSearch. ElasticSearch must have all information in his index.
1. Go Intranet -> Preference -> SearchEngine -> ElasticSearch
!! APPLY PATCH !!
2. Mapping is good (Intranet -> Catalog -> Search engine configuration (Elasticsearch) ).
!Recommended 'Reset Mapping'  -> 'Yes'
3. In your koha-conf.xml file you must have good <index_name> for <elasticsearch> and version ES
4. Update Preference:
./installer/data/mysql/updatedatabase.pl
If that passe good you can look the lines:
 - DEV atomic update: bug_27113-elasticsearch_autocomplete_input_search.perl
 - Upgrade to XXX done : Bug 27113 - Autocomplete input on main page with elasticsearch
5. After that we can look two options in the preferences:
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
4. For add information in the index we must run script for reindexing:
./misc/search_tools/rebuild_elasticsearch.pl -v -d
5. Waiting for the end of indexing
6. Go on Preference and find :
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
Value "Show" turn on autocomplete.
7. Now we have Autocomplete for Intranet/OPAC search input (advanced search also).

Signed-off-by: David Nind <david@davidnind.com>
Comment 53 The Minh Luong 2022-03-01 19:49:16 UTC
Created attachment 131209 [details] [review]
Bug 27113: (follow-up) Correction with Session

I have changed CGI::Session->new() from CGI::Session->load() for use session. This condition - 'CGI::Session->load() or die CGI::Session->errstr();'

I am not sure that was good idea to use 'die' in this condition...What do you think?
Thanks!

Signed-off-by: David Nind <david@davidnind.com>
Comment 54 The Minh Luong 2022-03-01 19:49:21 UTC
Created attachment 131210 [details] [review]
Bug 27113: (follow-up) Move new CSS to main SCSS files

This patch removes the separate CSS files added for the autocomplete
feature and puts them into the "main" SCSS files. I think a separate
file isn't necessary because the amount of CSS it adds is so small.

I've also tweaked the style of the autocomplete menu shown when you use
the arrow keys to navigate through the autocomplete choices. I think the
previous white-on-light-green didn't have enough contrast.

To test you must rebuild the OPAC and staff client CSS:
https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client

Follow the previous test plan, being careful to observe how it
works when the autocomplete menu has been triggered and you use the
arrow keys to navigate through the results.

Signed-off-by: David Nind <david@davidnind.com>
Comment 55 The Minh Luong 2022-03-01 19:49:25 UTC
Created attachment 131211 [details] [review]
Bug 27113: Rebase and correct autocomplete appearance

Rebase of previous patches and correct the buggy behavior (See "GIF showing buggy behavior attachment")

Test plan:
1- Search for an item. Notice that the autocomplete functionnality is not available. (See "Result" attachment)
2- Make sure that you are using Elasticsearch as your searching engine. (Preference->SearchEngine->ElasticSearch)
3- Apply the patch.
4- Run ./installer/data/mysql/updatedatabase.pl
5- Looks for the following preferences :
   - IntranetAutocompleteElasticSearch
   - OPACAutocompleteElasticSearch
6- Set their value to show.
7- Rebuild the OPAC and staff client CSS (This step is important because the autocomplete CSS is moved to the main SCSS file):
   Instructions here: https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client
8- Search for an item and notice that the autocomplete functionnality is now available.
9- In the staff interface, go in "Search the catalog".
10- Notice that the buggy behavior is now fixed.
Comment 56 The Minh Luong 2022-03-28 19:53:37 UTC
Created attachment 132360 [details] [review]
Bug 27113: ElasticSearch: Autocomplete in input search

Usually the user knows only part of the title of the book or only the name of the author, etc. When he start search something Koha (ElasticSearch) predicts the rest of a word or expression which user is typing.  Autocomplete predicts that thanks to index of ElasticSearch.

TEST PLAN
Important! In this patch we need to do reindex ElasticSearch. ElasticSearch must have all information in his index.
1. Go Intranet -> Preference -> SearchEngine -> ElasticSearch
!! APPLY PATCH !!
2. Mapping is good (Intranet -> Catalog -> Search engine configuration (Elasticsearch) ).
!Recommended 'Reset Mapping'  -> 'Yes'
3. In your koha-conf.xml file you must have good <index_name> for <elasticsearch> and version ES
4. Update Preference:
./installer/data/mysql/updatedatabase.pl
If that passe good you can look the lines:
 - DEV atomic update: bug_27113-elasticsearch_autocomplete_input_search.perl
 - Upgrade to XXX done : Bug 27113 - Autocomplete input on main page with elasticsearch
5. After that we can look two options in the preferences:
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
4. For add information in the index we must run script for reindexing:
./misc/search_tools/rebuild_elasticsearch.pl -v -d
5. Waiting for the end of indexing
6. Go on Preference and find :
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
Value "Show" turn on autocomplete.
7. Now we have Autocomplete for Intranet/OPAC search input (advanced search also).

Signed-off-by: David Nind <david@davidnind.com>
Comment 57 The Minh Luong 2022-03-28 19:53:42 UTC
Created attachment 132361 [details] [review]
Bug 27113: (follow-up) QA Tests

Bug 27113: (follow-up) QA Tests (2)

Bug 27113: (follow-up) Fixup warnings.

TEST PLAN
Important! In this patch we need to do reindex ElasticSearch. ElasticSearch must have all information in his index.
1. Go Intranet -> Preference -> SearchEngine -> ElasticSearch
!! APPLY PATCH !!
2. Mapping is good (Intranet -> Catalog -> Search engine configuration (Elasticsearch) ).
!Recommended 'Reset Mapping'  -> 'Yes'
3. In your koha-conf.xml file you must have good <index_name> for <elasticsearch> and version ES
4. Update Preference:
./installer/data/mysql/updatedatabase.pl
If that passe good you can look the lines:
 - DEV atomic update: bug_27113-elasticsearch_autocomplete_input_search.perl
 - Upgrade to XXX done : Bug 27113 - Autocomplete input on main page with elasticsearch
5. After that we can look two options in the preferences:
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
4. For add information in the index we must run script for reindexing:
./misc/search_tools/rebuild_elasticsearch.pl -v -d
5. Waiting for the end of indexing
6. Go on Preference and find :
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
Value "Show" turn on autocomplete.
7. Now we have Autocomplete for Intranet/OPAC search input (advanced search also).

Signed-off-by: David Nind <david@davidnind.com>
Comment 58 The Minh Luong 2022-03-28 19:53:46 UTC
Created attachment 132362 [details] [review]
Bug 27113: (follow-up) Correction with Session

I have changed CGI::Session->new() from CGI::Session->load() for use session. This condition - 'CGI::Session->load() or die CGI::Session->errstr();'

I am not sure that was good idea to use 'die' in this condition...What do you think?
Thanks!

Signed-off-by: David Nind <david@davidnind.com>
Comment 59 The Minh Luong 2022-03-28 19:53:51 UTC
Created attachment 132363 [details] [review]
Bug 27113: (follow-up) Move new CSS to main SCSS files

This patch removes the separate CSS files added for the autocomplete
feature and puts them into the "main" SCSS files. I think a separate
file isn't necessary because the amount of CSS it adds is so small.

I've also tweaked the style of the autocomplete menu shown when you use
the arrow keys to navigate through the autocomplete choices. I think the
previous white-on-light-green didn't have enough contrast.

To test you must rebuild the OPAC and staff client CSS:
https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client

Follow the previous test plan, being careful to observe how it
works when the autocomplete menu has been triggered and you use the
arrow keys to navigate through the results.

Signed-off-by: David Nind <david@davidnind.com>
Comment 60 The Minh Luong 2022-03-28 19:53:55 UTC
Created attachment 132364 [details] [review]
Bug 27113: Rebase and correct autocomplete appearance

Rebase of previous patches and correct the buggy behavior (See "GIF showing buggy behavior attachment")

Test plan:
1- Search for an item. Notice that the autocomplete functionnality is not available. (See "Result" attachment)
2- Make sure that you are using Elasticsearch as your searching engine. (Preference->SearchEngine->ElasticSearch)
3- Apply the patch.
4- Run ./installer/data/mysql/updatedatabase.pl
5- Looks for the following preferences :
   - IntranetAutocompleteElasticSearch
   - OPACAutocompleteElasticSearch
6- Set their value to show.
7- Rebuild the OPAC and staff client CSS (This step is important because the autocomplete CSS is moved to the main SCSS file):
   Instructions here: https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client
8- Search for an item and notice that the autocomplete functionnality is now available.
9- In the staff interface, go in "Search the catalog".
10- Notice that the buggy behavior is now fixed.
Comment 61 Shi Yao Wang 2022-03-31 18:21:48 UTC
Created attachment 132808 [details] [review]
Bug 27113: No autosubmit after clicking autocomplete option in advanced search

This patch makes it so it doesn't automatically submit form after clicking an autocomplete option
in advanced search. Also removes autocomplete options after pressing tab.
Comment 62 Shi Yao Wang 2022-04-04 16:10:50 UTC
Created attachment 132945 [details] [review]
Bug 27113: Removes items in OPACHiddenItems from autocomplete

Items specified in OPACHiddenItems preference are removed from search
suggestions in OPAC.

Test plan:
1- Search for an item. Notice that the autocomplete functionnality is not available. (See "Result" attachment)
2- Make sure that you are using Elasticsearch as your searching engine. (Preference->SearchEngine->ElasticSearch)
3- Apply the patch.
4- Run ./installer/data/mysql/updatedatabase.pl
5- Looks for the following preferences :
   - IntranetAutocompleteElasticSearch
   - OPACAutocompleteElasticSearch
6- Set their value to show.
7- Rebuild the OPAC and staff client CSS (This step is important because the autocomplete CSS is moved to the main SCSS file):
   Instructions here: https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client
8- Search for an item and notice that the autocomplete functionnality is now available.
9- In the staff interface, go in "Search the catalog".
10- Notice that the buggy behavior is now fixed.
11- Search for an item with basic search and click on one of the
options.
12- Notice it automatically sends you to the selected items page.
13- This time, search an item using the advanced search and click on one
of the options.
14- Notice it just writes the chosen option in the input instead.
15- Go to Administration -> system preferences -> OPACHiddenItems.
16- Define a rule that applies to an existing item.
17- Search that item in OPAC and notice it doesn't give you the
suggestion for that item.
Comment 63 Shi Yao Wang 2022-04-04 16:16:45 UTC
My concern is that searching with more than 1 prefix is going to be too slow when there are lots of items since it will go through a triple nested loop.
Comment 64 Shi Yao Wang 2022-04-04 16:24:00 UTC
Sorry. I meant double nested loops.
Comment 65 Shi Yao Wang 2022-04-04 16:37:47 UTC
Created attachment 132946 [details] [review]
Bug 27113: Removes items in OPACHiddenItems from autocomplete

Items specified in OPACHiddenItems preference are removed from search
suggestions in OPAC.

Test plan:
1- Search for an item. Notice that the autocomplete functionnality is not available. (See "Result" attachment)
2- Make sure that you are using Elasticsearch as your searching engine. (Preference->SearchEngine->ElasticSearch)
3- Apply the patch.
4- Run ./installer/data/mysql/updatedatabase.pl
5- Looks for the following preferences :
   - IntranetAutocompleteElasticSearch
   - OPACAutocompleteElasticSearch
6- Set their value to show.
7- Rebuild the OPAC and staff client CSS (This step is important because the autocomplete CSS is moved to the main SCSS file):
   Instructions here: https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client
8- Search for an item and notice that the autocomplete functionnality is now available.
9- In the staff interface, go in "Search the catalog".
10- Notice that the buggy behavior is now fixed.
11- Search for an item with basic search and click on one of the
options.
12- Notice it automatically sends you to the selected items page.
13- This time, search an item using the advanced search and click on one
of the options.
14- Notice it just writes the chosen option in the input instead.
15- Go to Administration -> system preferences -> OPACHiddenItems.
16- Define a rule that applies to an existing item.
17- Search that item in OPAC and notice it doesn't give you the
suggestion for that item.
Comment 66 Shi Yao Wang 2022-04-06 14:54:56 UTC
Created attachment 133042 [details] [review]
Bug 27113: Removes hidden and suppressed items from OPAC autocomplete

Items specified in OPACHiddenItems preference and items affected by
OpacSuppression are removed from search suggestions in OPAC.

Test plan:
1- Search for an item. Notice that the autocomplete functionnality is not available. (See "Result" attachment)
2- Make sure that you are using Elasticsearch as your searching engine. (Preference->SearchEngine->ElasticSearch)
3- Apply the patch.
4- Run ./installer/data/mysql/updatedatabase.pl
5- Looks for the following preferences :
   - IntranetAutocompleteElasticSearch
   - OPACAutocompleteElasticSearch
6- Set their value to show.
7- Rebuild the OPAC and staff client CSS (This step is important because the autocomplete CSS is moved to the main SCSS file):
   Instructions here: https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client
8- Search for an item and notice that the autocomplete functionnality is now available.
9- In the staff interface, go in "Search the catalog".
10- Notice that the buggy behavior is now fixed.
11- Search for an item with basic search and click on one of the
options.
12- Notice it automatically sends you to the selected items page.
13- This time, search an item using the advanced search and click on one
of the options.
14- Notice it just writes the chosen option in the input instead.
15- Go to Administration -> system preferences -> OPACHiddenItems.
16- Define a rule that applies to an existing item.
17- Search that item in OPAC and notice it doesn't give you the
suggestion for that item.
18- Go to Administration -> system preferences -> OpacSuppression and
set it to "hide".
19- Add or edit a record and set 942$n field to yes.
20- Search that entry in OPAC and notice it doesn't give you the
suggestion for that entry.
Comment 67 Shi Yao Wang 2022-04-06 16:56:54 UTC
Created attachment 133045 [details] [review]
Bug 27113: Focus the input after selecting "Search the catalog"

Small fix to focus the input after clicking "Search the catalog" in
staff interface.
Comment 68 Blou 2022-04-19 17:23:17 UTC
Created attachment 133407 [details] [review]
Bug 27113: ElasticSearch: Autocomplete in input search

Usually the user knows only part of the title of the book or only the name of the author, etc. When he start search something Koha (ElasticSearch) predicts the rest of a word or expression which user is typing.  Autocomplete predicts that thanks to index of ElasticSearch.

TEST PLAN
Important! In this patch we need to do reindex ElasticSearch. ElasticSearch must have all information in his index.
1. Go Intranet -> Preference -> SearchEngine -> ElasticSearch
!! APPLY PATCH !!
2. Mapping is good (Intranet -> Catalog -> Search engine configuration (Elasticsearch) ).
!Recommended 'Reset Mapping'  -> 'Yes'
3. In your koha-conf.xml file you must have good <index_name> for <elasticsearch> and version ES
4. Update Preference:
./installer/data/mysql/updatedatabase.pl
If that passe good you can look the lines:
 - DEV atomic update: bug_27113-elasticsearch_autocomplete_input_search.perl
 - Upgrade to XXX done : Bug 27113 - Autocomplete input on main page with elasticsearch
5. After that we can look two options in the preferences:
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
4. For add information in the index we must run script for reindexing:
./misc/search_tools/rebuild_elasticsearch.pl -v -d
5. Waiting for the end of indexing
6. Go on Preference and find :
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
Value "Show" turn on autocomplete.
7. Now we have Autocomplete for Intranet/OPAC search input (advanced search also).

Signed-off-by: David Nind <david@davidnind.com>
Comment 69 Blou 2022-04-19 17:31:32 UTC
Created attachment 133409 [details] [review]
Bug 27113: ElasticSearch: Autocomplete in input search

Usually the user knows only part of the title of the book or only the name of the author, etc. When he start search something Koha (ElasticSearch) predicts the rest of a word or expression which user is typing.  Autocomplete predicts that thanks to index of ElasticSearch.

TEST PLAN
Important! In this patch we need to do reindex ElasticSearch. ElasticSearch must have all information in his index.
1. Go Intranet -> Preference -> SearchEngine -> ElasticSearch
!! APPLY PATCH !!
2. Mapping is good (Intranet -> Catalog -> Search engine configuration (Elasticsearch) ).
!Recommended 'Reset Mapping'  -> 'Yes'
3. In your koha-conf.xml file you must have good <index_name> for <elasticsearch> and version ES
4. Update Preference:
./installer/data/mysql/updatedatabase.pl
If that passe good you can look the lines:
 - DEV atomic update: bug_27113-elasticsearch_autocomplete_input_search.perl
 - Upgrade to XXX done : Bug 27113 - Autocomplete input on main page with elasticsearch
5. After that we can look two options in the preferences:
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
4. For add information in the index we must run script for reindexing:
./misc/search_tools/rebuild_elasticsearch.pl -v -d
5. Waiting for the end of indexing
6. Go on Preference and find :
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
Value "Show" turn on autocomplete.
7. Now we have Autocomplete for Intranet/OPAC search input (advanced search also).

Signed-off-by: David Nind <david@davidnind.com>
Comment 70 Blou 2022-04-19 17:31:37 UTC
Created attachment 133410 [details] [review]
Bug 27113: (follow-up) Move new CSS to main SCSS files

This patch removes the separate CSS files added for the autocomplete
feature and puts them into the "main" SCSS files. I think a separate
file isn't necessary because the amount of CSS it adds is so small.

I've also tweaked the style of the autocomplete menu shown when you use
the arrow keys to navigate through the autocomplete choices. I think the
previous white-on-light-green didn't have enough contrast.

To test you must rebuild the OPAC and staff client CSS:
https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client

Follow the previous test plan, being careful to observe how it
works when the autocomplete menu has been triggered and you use the
arrow keys to navigate through the results.

Signed-off-by: David Nind <david@davidnind.com>
Comment 71 Blou 2022-04-19 17:36:30 UTC
I know it's bad form, but since we've been told the functionality requires a re-engineering to use the REST api, a lot of rebase are going to happen until we get this on the master, so I squashed it all.

Well, not all, I kept the one patch contributed from outside our company.
Comment 72 Shi Yao Wang 2022-06-17 21:13:55 UTC
Created attachment 136312 [details] [review]
Bug 27113: ElasticSearch: Autocomplete in input search

Usually the user knows only part of the title of the book or only the name of the author, etc. When he start search something Koha (ElasticSearch) predicts the rest of a word or expression which user is typing.  Autocomplete predicts that thanks to index of ElasticSearch.

TEST PLAN
Important! In this patch we need to do reindex ElasticSearch. ElasticSearch must have all information in his index.
1. Go Intranet -> Preference -> SearchEngine -> ElasticSearch
!! APPLY PATCH !!
2. Mapping is good (Intranet -> Catalog -> Search engine configuration (Elasticsearch) ).
!Recommended 'Reset Mapping'  -> 'Yes'
3. In your koha-conf.xml file you must have good <index_name> for <elasticsearch> and version ES
4. Update Preference:
./installer/data/mysql/updatedatabase.pl
If that passe good you can look the lines:
 - DEV atomic update: bug_27113-elasticsearch_autocomplete_input_search.perl
 - Upgrade to XXX done : Bug 27113 - Autocomplete input on main page with elasticsearch
5. After that we can look two options in the preferences:
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
4. For add information in the index we must run script for reindexing:
./misc/search_tools/rebuild_elasticsearch.pl -v -d
5. Waiting for the end of indexing
6. Go on Preference and find :
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
Value "Show" turn on autocomplete.
7. Now we have Autocomplete for Intranet/OPAC search input (advanced search also).

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

Bug 27113: (follow-up) Move new CSS to main SCSS files

This patch removes the separate CSS files added for the autocomplete
feature and puts them into the "main" SCSS files. I think a separate
file isn't necessary because the amount of CSS it adds is so small.

I've also tweaked the style of the autocomplete menu shown when you use
the arrow keys to navigate through the autocomplete choices. I think the
previous white-on-light-green didn't have enough contrast.

To test you must rebuild the OPAC and staff client CSS:
https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client

Follow the previous test plan, being careful to observe how it
works when the autocomplete menu has been triggered and you use the
arrow keys to navigate through the results.

Signed-off-by: David Nind <david@davidnind.com>
Comment 73 Shi Yao Wang 2022-06-17 21:15:35 UTC
Squashed the two patches at the request of Blou.
Comment 74 Shi Yao Wang 2022-06-20 12:56:46 UTC
Nevermind. Put back the last two patches.
Comment 75 Shi Yao Wang 2022-06-23 18:06:55 UTC
Created attachment 136456 [details] [review]
Bug 27113: ElasticSearch: Autocomplete in input search

Usually the user knows only part of the title of the book or only the name of the author, etc. When he start search something Koha (ElasticSearch) predicts the rest of a word or expression which user is typing.  Autocomplete predicts that thanks to index of ElasticSearch.

TEST PLAN
Important! In this patch we need to do reindex ElasticSearch. ElasticSearch must have all information in his index.
1. Go Intranet -> Preference -> SearchEngine -> ElasticSearch
!! APPLY PATCH !!
2. Mapping is good (Intranet -> Catalog -> Search engine configuration (Elasticsearch) ).
!Recommended 'Reset Mapping'  -> 'Yes'
3. In your koha-conf.xml file you must have good <index_name> for <elasticsearch> and version ES
4. Update Preference:
./installer/data/mysql/updatedatabase.pl
If that passe good you can look the lines:
 - DEV atomic update: bug_27113-elasticsearch_autocomplete_input_search.perl
 - Upgrade to XXX done : Bug 27113 - Autocomplete input on main page with elasticsearch
5. After that we can look two options in the preferences:
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
4. For add information in the index we must run script for reindexing:
./misc/search_tools/rebuild_elasticsearch.pl -v -d
5. Waiting for the end of indexing
6. Go on Preference and find :
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
Value "Show" turn on autocomplete.
7. Now we have Autocomplete for Intranet/OPAC search input (advanced search also).

Signed-off-by: David Nind <david@davidnind.com>
Comment 76 Shi Yao Wang 2022-06-23 18:07:00 UTC
Created attachment 136457 [details] [review]
Bug 27113: (follow-up) Move new CSS to main SCSS files

This patch removes the separate CSS files added for the autocomplete
feature and puts them into the "main" SCSS files. I think a separate
file isn't necessary because the amount of CSS it adds is so small.

I've also tweaked the style of the autocomplete menu shown when you use
the arrow keys to navigate through the autocomplete choices. I think the
previous white-on-light-green didn't have enough contrast.

To test you must rebuild the OPAC and staff client CSS:
https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client

Follow the previous test plan, being careful to observe how it
works when the autocomplete menu has been triggered and you use the
arrow keys to navigate through the results.

Signed-off-by: David Nind <david@davidnind.com>
Comment 77 David Nind 2022-06-23 22:45:33 UTC
Created attachment 136464 [details] [review]
Bug 27113: (follow-up) Update descriptions for system preferences

Update the descriptions for the new system preferences -
IntranetAutocompleteElasticSearch and OPACAutocompleteElasticSearch.

Test plan:
1. Review the descriptions for the IntranetAutocompleteElasticSearch
   and OPACAutocompleteElasticSearch system preferences.
2. Make sure they are readable and make sense.

Signed-off-by: David Nind <david@davidnind.com>
Comment 78 David Nind 2022-06-23 23:17:25 UTC
Created attachment 136465 [details]
Bug 27113 - Advanced search - more options display issue

I've added a follow-up with my suggestions for the descriptions for the two new system preferences.

I've changed the status to Failed QA as there is a slight issue with the staff interface advanced search > more options after the patch is applied. See the attached screenshots.

Also, something for QA to comment on. The spelling for Elasticsearch - the s in search is not capitalised, as it is the product name (not ElasticSearch). Does this need changing for the preference names, and the other code in the patches?

Can confirm everything continues to work otherwise, and I like it!
Comment 79 Shi Yao Wang 2022-06-27 16:21:37 UTC
Created attachment 136653 [details] [review]
Bug 27113: (follow-up) fix adv. searches - more options display issue
Comment 80 Shi Yao Wang 2022-06-27 18:04:06 UTC
Fixed the little display issue.

Also, does anyone know how to have the same relative path to one file from both OPAC and staff interface url? (e.g. http://master/api/elasticsearch/elasticsearch.pl and http://master-intranet/api/elasticsearch/elasticsearch.pl)

With this we would only need to create one .pl file to be used by both interface instead of one for each.
Comment 81 David Nind 2022-06-27 18:37:49 UTC
Created attachment 136657 [details] [review]
Bug 27113: ElasticSearch: Autocomplete in input search

Usually the user knows only part of the title of the book or only the name of the author, etc. When he start search something Koha (ElasticSearch) predicts the rest of a word or expression which user is typing.  Autocomplete predicts that thanks to index of ElasticSearch.

TEST PLAN
Important! In this patch we need to do reindex ElasticSearch. ElasticSearch must have all information in his index.
1. Go Intranet -> Preference -> SearchEngine -> ElasticSearch
!! APPLY PATCH !!
2. Mapping is good (Intranet -> Catalog -> Search engine configuration (Elasticsearch) ).
!Recommended 'Reset Mapping'  -> 'Yes'
3. In your koha-conf.xml file you must have good <index_name> for <elasticsearch> and version ES
4. Update Preference:
./installer/data/mysql/updatedatabase.pl
If that passe good you can look the lines:
 - DEV atomic update: bug_27113-elasticsearch_autocomplete_input_search.perl
 - Upgrade to XXX done : Bug 27113 - Autocomplete input on main page with elasticsearch
5. After that we can look two options in the preferences:
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
4. For add information in the index we must run script for reindexing:
./misc/search_tools/rebuild_elasticsearch.pl -v -d
5. Waiting for the end of indexing
6. Go on Preference and find :
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
Value "Show" turn on autocomplete.
7. Now we have Autocomplete for Intranet/OPAC search input (advanced search also).

Signed-off-by: David Nind <david@davidnind.com>
Comment 82 David Nind 2022-06-27 18:37:57 UTC
Created attachment 136658 [details] [review]
Bug 27113: (follow-up) Move new CSS to main SCSS files

This patch removes the separate CSS files added for the autocomplete
feature and puts them into the "main" SCSS files. I think a separate
file isn't necessary because the amount of CSS it adds is so small.

I've also tweaked the style of the autocomplete menu shown when you use
the arrow keys to navigate through the autocomplete choices. I think the
previous white-on-light-green didn't have enough contrast.

To test you must rebuild the OPAC and staff client CSS:
https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client

Follow the previous test plan, being careful to observe how it
works when the autocomplete menu has been triggered and you use the
arrow keys to navigate through the results.

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

Signed-off-by: David Nind <david@davidnind.com>
Comment 83 David Nind 2022-06-27 18:38:04 UTC
Created attachment 136659 [details] [review]
Bug 27113: (follow-up) Update descriptions for system preferences

Update the descriptions for the new system preferences -
IntranetAutocompleteElasticSearch and OPACAutocompleteElasticSearch.

Test plan:
1. Review the descriptions for the IntranetAutocompleteElasticSearch
   and OPACAutocompleteElasticSearch system preferences.
2. Make sure they are readable and make sense.

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

Signed-off-by: David Nind <david@davidnind.com>
Comment 84 David Nind 2022-06-27 18:38:11 UTC
Created attachment 136660 [details] [review]
Bug 27113: (follow-up) fix adv. searches - more options display issue

Signed-off-by: David Nind <david@davidnind.com>
Comment 85 David Nind 2022-06-27 18:46:34 UTC
(In reply to Shi Yao Wang from comment #80)
> Fixed the little display issue.

Thanks!

> Also, does anyone know how to have the same relative path to one file from
> both OPAC and staff interface url? (e.g.
> http://master/api/elasticsearch/elasticsearch.pl and
> http://master-intranet/api/elasticsearch/elasticsearch.pl)
> 
> With this we would only need to create one .pl file to be used by both
> interface instead of one for each.

Sorry, I don't.
Comment 86 Katrin Fischer 2022-07-02 22:22:58 UTC
> > Also, does anyone know how to have the same relative path to one file from
> > both OPAC and staff interface url? (e.g.
> > http://master/api/elasticsearch/elasticsearch.pl and
> > http://master-intranet/api/elasticsearch/elasticsearch.pl)
> > 
> > With this we would only need to create one .pl file to be used by both
> > interface instead of one for each.
> 
> Sorry, I don't.

AFAIK it's not possible to share files between OPAC and staff interface.
Comment 87 Fridolin Somers 2022-07-05 18:47:03 UTC
You can with REST API.
Public routes are same file between OPAC and staff :
https://wiki.koha-community.org/wiki/REST_api_RFCs#Unprivileged_.28public.29_routes
Comment 88 Shi Yao Wang 2022-07-08 21:05:18 UTC
Created attachment 137436 [details] [review]
Bug 27113: ElasticSearch: Autocomplete in input search

Usually the user knows only part of the title of the book or only the name of the author, etc. When he start search something Koha (ElasticSearch) predicts the rest of a word or expression which user is typing.  Autocomplete predicts that thanks to index of ElasticSearch.

TEST PLAN
Important! In this patch we need to do reindex ElasticSearch. ElasticSearch must have all information in his index.
1. Go Intranet -> Preference -> SearchEngine -> ElasticSearch
!! APPLY PATCH !!
2. Mapping is good (Intranet -> Catalog -> Search engine configuration (Elasticsearch) ).
!Recommended 'Reset Mapping'  -> 'Yes'
3. In your koha-conf.xml file you must have good <index_name> for <elasticsearch> and version ES
4. Update Preference:
./installer/data/mysql/updatedatabase.pl
If that passe good you can look the lines:
 - DEV atomic update: bug_27113-elasticsearch_autocomplete_input_search.perl
 - Upgrade to XXX done : Bug 27113 - Autocomplete input on main page with elasticsearch
5. After that we can look two options in the preferences:
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
4. For add information in the index we must run script for reindexing:
./misc/search_tools/rebuild_elasticsearch.pl -v -d
5. Waiting for the end of indexing
6. Go on Preference and find :
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
Value "Show" turn on autocomplete.
7. Now we have Autocomplete for Intranet/OPAC search input (advanced search also).

Signed-off-by: David Nind <david@davidnind.com>
Comment 89 Shi Yao Wang 2022-07-08 21:05:28 UTC
Created attachment 137437 [details] [review]
Bug 27113: (follow-up) Move new CSS to main SCSS files

This patch removes the separate CSS files added for the autocomplete
feature and puts them into the "main" SCSS files. I think a separate
file isn't necessary because the amount of CSS it adds is so small.

I've also tweaked the style of the autocomplete menu shown when you use
the arrow keys to navigate through the autocomplete choices. I think the
previous white-on-light-green didn't have enough contrast.

To test you must rebuild the OPAC and staff client CSS:
https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client

Follow the previous test plan, being careful to observe how it
works when the autocomplete menu has been triggered and you use the
arrow keys to navigate through the results.

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

Signed-off-by: David Nind <david@davidnind.com>
Comment 90 Shi Yao Wang 2022-07-08 21:05:35 UTC
Created attachment 137438 [details] [review]
Bug 27113: (follow-up) Update descriptions for system preferences

Update the descriptions for the new system preferences -
IntranetAutocompleteElasticSearch and OPACAutocompleteElasticSearch.

Test plan:
1. Review the descriptions for the IntranetAutocompleteElasticSearch
   and OPACAutocompleteElasticSearch system preferences.
2. Make sure they are readable and make sense.

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

Signed-off-by: David Nind <david@davidnind.com>
Comment 91 Shi Yao Wang 2022-07-08 21:05:40 UTC
Created attachment 137439 [details] [review]
Bug 27113: (follow-up) fix adv. searches - more options display issue

Signed-off-by: David Nind <david@davidnind.com>
Comment 92 Shi Yao Wang 2022-07-08 21:10:17 UTC
Fixed an encoding/display problem when using "é", "ù", etc.

(In reply to Fridolin Somers from comment #87)
> You can with REST API.
> Public routes are same file between OPAC and staff :
> https://wiki.koha-community.org/wiki/REST_api_RFCs#Unprivileged_.28public.
> 29_routes

I don't know how to do it, but I think it would be a good idea.
Comment 93 Katrin Fischer 2022-07-15 14:41:40 UTC
First of all: I quite like the functionality and how this looks. It also appears to be pretty fast and accurate as far as I can tell. I especially like that it's not only available for the keyword index, but also on other search options like author search and limits the results down accordingly.

That said: There are a couple things here that would require fixing and a big question we need to resolve for moving this forward.


The small stuff:
1) In the database update, there should still be a description for the system preference.
2) sysprefs.sql is sorted alphabetically to avoid conflicts, please move the prefs into the correct places.
3) Instead of use strict; use warnings; we use use Modern::Perl; (see PERL2 in coding guidelines)
4) In the database update elasticsearch should be Elasticsearch.


Somewhat bigger:

5) I have problems making this work with the "library catalog" and "title" search options in simple search in OPAC. title doesn't give me any results and library catalog looks like author (but it's a keyword search). Something might not be 'wired' correctly there.
6) Updating installations: I believe you also need to reset mappings to make this work? How can we ensure this works out of the box for people updating without them having to "redo" their index configuration? (database update?)
7) sub filterAutocomplete looks complex and I wonder if it should be in the .pl and not in a module where it can be tested. 942 is hardcoded as field for OpacSuppression, which is a little risky. I wonder if it could be more elegant to filter this at search time instead of after?


The last big question, I'll refer to the RM:

This adds to /svc which is the outdated way of doing things as others have pointed out before. I think in order to move on here and before more time is spend, we should come to a decision of what is required for this patch to make it in and if it needs to be rewritten to use REST API or if this could be an exception.
Comment 94 Shi Yao Wang 2022-07-15 16:15:18 UTC
Created attachment 137780 [details] [review]
Bug 27113: ElasticSearch: Autocomplete in input search

Usually the user knows only part of the title of the book or only the name of the author, etc. When he start search something Koha (ElasticSearch) predicts the rest of a word or expression which user is typing.  Autocomplete predicts that thanks to index of ElasticSearch.

TEST PLAN
Important! In this patch we need to do reindex ElasticSearch. ElasticSearch must have all information in his index.
1. Go Intranet -> Preference -> SearchEngine -> ElasticSearch
!! APPLY PATCH !!
2. Mapping is good (Intranet -> Catalog -> Search engine configuration (Elasticsearch) ).
!Recommended 'Reset Mapping'  -> 'Yes'
3. In your koha-conf.xml file you must have good <index_name> for <elasticsearch> and version ES
4. Update Preference:
./installer/data/mysql/updatedatabase.pl
If that passe good you can look the lines:
 - DEV atomic update: bug_27113-elasticsearch_autocomplete_input_search.perl
 - Upgrade to XXX done : Bug 27113 - Autocomplete input on main page with elasticsearch
5. After that we can look two options in the preferences:
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
4. For add information in the index we must run script for reindexing:
./misc/search_tools/rebuild_elasticsearch.pl -v -d
5. Waiting for the end of indexing
6. Go on Preference and find :
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
Value "Show" turn on autocomplete.
7. Now we have Autocomplete for Intranet/OPAC search input (advanced search also).

Signed-off-by: David Nind <david@davidnind.com>
Comment 95 Shi Yao Wang 2022-07-15 16:15:23 UTC
Created attachment 137781 [details] [review]
Bug 27113: (follow-up) Move new CSS to main SCSS files

This patch removes the separate CSS files added for the autocomplete
feature and puts them into the "main" SCSS files. I think a separate
file isn't necessary because the amount of CSS it adds is so small.

I've also tweaked the style of the autocomplete menu shown when you use
the arrow keys to navigate through the autocomplete choices. I think the
previous white-on-light-green didn't have enough contrast.

To test you must rebuild the OPAC and staff client CSS:
https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client

Follow the previous test plan, being careful to observe how it
works when the autocomplete menu has been triggered and you use the
arrow keys to navigate through the results.

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

Signed-off-by: David Nind <david@davidnind.com>
Comment 96 Shi Yao Wang 2022-07-15 16:15:28 UTC
Created attachment 137782 [details] [review]
Bug 27113: (follow-up) Update descriptions for system preferences

Update the descriptions for the new system preferences -
IntranetAutocompleteElasticSearch and OPACAutocompleteElasticSearch.

Test plan:
1. Review the descriptions for the IntranetAutocompleteElasticSearch
   and OPACAutocompleteElasticSearch system preferences.
2. Make sure they are readable and make sense.

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

Signed-off-by: David Nind <david@davidnind.com>
Comment 97 Shi Yao Wang 2022-07-15 16:15:32 UTC
Created attachment 137783 [details] [review]
Bug 27113: (follow-up) fix adv. searches - more options display issue

Signed-off-by: David Nind <david@davidnind.com>
Comment 98 Shi Yao Wang 2022-07-15 16:46:44 UTC
(In reply to Katrin Fischer from comment #93)
> First of all: I quite like the functionality and how this looks. It also
> appears to be pretty fast and accurate as far as I can tell. I especially
> like that it's not only available for the keyword index, but also on other
> search options like author search and limits the results down accordingly.
> 
> That said: There are a couple things here that would require fixing and a
> big question we need to resolve for moving this forward.
> 
> 
> The small stuff:
> 1) In the database update, there should still be a description for the
> system preference.
> 2) sysprefs.sql is sorted alphabetically to avoid conflicts, please move the
> prefs into the correct places.
> 3) Instead of use strict; use warnings; we use use Modern::Perl; (see PERL2
> in coding guidelines)
> 4) In the database update elasticsearch should be Elasticsearch.
> 
> 
> Somewhat bigger:
> 
> 5) I have problems making this work with the "library catalog" and "title"
> search options in simple search in OPAC. title doesn't give me any results
> and library catalog looks like author (but it's a keyword search). Something
> might not be 'wired' correctly there.
> 6) Updating installations: I believe you also need to reset mappings to make
> this work? How can we ensure this works out of the box for people updating
> without them having to "redo" their index configuration? (database update?)
> 7) sub filterAutocomplete looks complex and I wonder if it should be in the
> .pl and not in a module where it can be tested. 942 is hardcoded as field
> for OpacSuppression, which is a little risky. I wonder if it could be more
> elegant to filter this at search time instead of after?

Small stuff fixed.

5) Searching with "title" works for me. Maybe an index issue? or is it just me?

   "library catalog" search displays suggestions for each search options in this order: title-cover, author, subject, title-series, publisher. What I think probably happened is, since "title" search doesn't work for you, it showed "author" suggestions where you had more match than the maximum number of rows displayed.

6) I don't know :/

7) I can move it to a module, but which one? Maybe in a new module? if so, where?
   I reused the code in opac/opac-detail.pl where 942 is hardcoded too.
   I do think it would be better to filter at search time but I don't know how...
Comment 99 Shi Yao Wang 2022-08-22 19:10:44 UTC
Created attachment 139624 [details] [review]
Bug 27113: (follow-up) replace removed GetMarcBiblio
Comment 100 Blou 2022-10-06 18:29:37 UTC
Created attachment 141466 [details] [review]
Bug 27113: Allow for ending special characters in titles

Modifies the cleanup regex that removed )}' and " endings from the
suggested titles or authors.  When selected without those, the record
was not found.

Ex: "MyTitle (1234)" became "MyTitle (123" in the list.  It returned no
results, where the full title or "MyTitle 123" would.
Comment 101 Blou 2022-11-22 18:46:24 UTC
Comments from Kate/RM would be appreciated so that Shi Yao (or others) can move ahead with this patch.  ShiYao has fixed and commented on the bullet points and this is now in Limbo.
Comment 102 Blou 2023-01-09 21:35:07 UTC
Created attachment 145167 [details] [review]
Bug 27113: (follow-up) diacritics/acccents in sought word would make autocomplete return nothing
Comment 103 Hammat wele 2023-02-02 15:41:07 UTC
Created attachment 146015 [details] [review]
Bug 27113: Move filterAutocomplete to a new module and filter the result at search time
Comment 104 Hammat wele 2023-02-02 16:44:56 UTC
sub filterAutocomplete moved to a new module and now the filtering is done at the search time.

(In reply to Katrin Fischer from comment #93)

> 6) Updating installations: I believe you also need to reset mappings to make
> this work? How can we ensure this works out of the box for people updating
> without them having to "redo" their index configuration? (database update?)

It's been wrote in the test plan by precaution but there is no need reset mappings to make this work.
Comment 105 Caroline Cyr La Rose 2023-02-08 19:53:11 UTC
Waiting for some work on bug 25870 and bug 30790 to continue this.
Comment 106 Salah Ghedda 2023-12-12 18:56:07 UTC
Created attachment 159769 [details] [review]
Bug 27113: (follow-up) Move new CSS to main SCSS files

This patch removes the separate CSS files added for the autocomplete
feature and puts them into the "main" SCSS files. I think a separate
file isn't necessary because the amount of CSS it adds is so small.

I've also tweaked the style of the autocomplete menu shown when you use
the arrow keys to navigate through the autocomplete choices. I think the
previous white-on-light-green didn't have enough contrast.

To test you must rebuild the OPAC and staff client CSS:
https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client

Follow the previous test plan, being careful to observe how it
works when the autocomplete menu has been triggered and you use the
arrow keys to navigate through the results.

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

Signed-off-by: David Nind <david@davidnind.com>
Comment 107 Salah Ghedda 2023-12-12 18:56:11 UTC
Created attachment 159770 [details] [review]
Bug 27113: (follow-up) Update descriptions for system preferences

Update the descriptions for the new system preferences -
IntranetAutocompleteElasticSearch and OPACAutocompleteElasticSearch.

Test plan:
1. Review the descriptions for the IntranetAutocompleteElasticSearch
   and OPACAutocompleteElasticSearch system preferences.
2. Make sure they are readable and make sense.

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

Signed-off-by: David Nind <david@davidnind.com>
Comment 108 Salah Ghedda 2023-12-12 18:56:15 UTC
Created attachment 159771 [details] [review]
Bug 27113: (follow-up) fix adv. searches - more options display issue

Signed-off-by: David Nind <david@davidnind.com>
Comment 109 Salah Ghedda 2023-12-12 18:56:20 UTC
Created attachment 159772 [details] [review]
Bug 27113: (follow-up) replace removed GetMarcBiblio
Comment 110 Salah Ghedda 2023-12-12 18:56:23 UTC
Created attachment 159773 [details] [review]
Bug 27113: Allow for ending special characters in titles

Modifies the cleanup regex that removed )}' and " endings from the
suggested titles or authors.  When selected without those, the record
was not found.

Ex: "MyTitle (1234)" became "MyTitle (123" in the list.  It returned no
results, where the full title or "MyTitle 123" would.
Comment 111 Salah Ghedda 2023-12-12 18:56:27 UTC
Created attachment 159774 [details] [review]
Bug 27113: (follow-up) diacritics/acccents in sought word would make autocomplete return nothing
Comment 112 Salah Ghedda 2023-12-12 18:56:31 UTC
Created attachment 159775 [details] [review]
Bug 27113: Move filterAutocomplete to a new module and filter the result at search time
Comment 113 Salah Ghedda 2023-12-12 19:05:09 UTC
Rebased
Comment 114 Salah Ghedda 2023-12-20 17:09:14 UTC
Created attachment 160134 [details] [review]
Bug 27113: ElasticSearch: Autocomplete in input search

Usually the user knows only part of the title of the book or only the name of the author, etc. When he start search something Koha (ElasticSearch) predicts the rest of a word or expression which user is typing.  Autocomplete predicts that thanks to index of ElasticSearch.

TEST PLAN
Important! In this patch we need to do reindex ElasticSearch. ElasticSearch must have all information in his index.
1. Go Intranet -> Preference -> SearchEngine -> ElasticSearch
!! APPLY PATCH !!
2. Mapping is good (Intranet -> Catalog -> Search engine configuration (Elasticsearch) ).
!Recommended 'Reset Mapping'  -> 'Yes'
3. In your koha-conf.xml file you must have good <index_name> for <elasticsearch> and version ES
4. Update Preference:
./installer/data/mysql/updatedatabase.pl
If that passe good you can look the lines:
 - DEV atomic update: bug_27113-elasticsearch_autocomplete_input_search.perl
 - Upgrade to XXX done : Bug 27113 - Autocomplete input on main page with elasticsearch
5. After that we can look two options in the preferences:
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
4. For add information in the index we must run script for reindexing:
./misc/search_tools/rebuild_elasticsearch.pl -v -d
5. Waiting for the end of indexing
6. Go on Preference and find :
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
Value "Show" turn on autocomplete.
7. Now we have Autocomplete for Intranet/OPAC search input (advanced search also).

Signed-off-by: David Nind <david@davidnind.com>
Comment 115 Salah Ghedda 2023-12-20 17:09:18 UTC
Created attachment 160135 [details] [review]
Bug 27113: (follow-up) Move new CSS to main SCSS files

This patch removes the separate CSS files added for the autocomplete
feature and puts them into the "main" SCSS files. I think a separate
file isn't necessary because the amount of CSS it adds is so small.

I've also tweaked the style of the autocomplete menu shown when you use
the arrow keys to navigate through the autocomplete choices. I think the
previous white-on-light-green didn't have enough contrast.

To test you must rebuild the OPAC and staff client CSS:
https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client

Follow the previous test plan, being careful to observe how it
works when the autocomplete menu has been triggered and you use the
arrow keys to navigate through the results.

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

Signed-off-by: David Nind <david@davidnind.com>
Comment 116 Salah Ghedda 2023-12-20 17:09:22 UTC
Created attachment 160136 [details] [review]
Bug 27113: (follow-up) Update descriptions for system preferences

Update the descriptions for the new system preferences -
IntranetAutocompleteElasticSearch and OPACAutocompleteElasticSearch.

Test plan:
1. Review the descriptions for the IntranetAutocompleteElasticSearch
   and OPACAutocompleteElasticSearch system preferences.
2. Make sure they are readable and make sense.

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

Signed-off-by: David Nind <david@davidnind.com>
Comment 117 Salah Ghedda 2023-12-20 17:09:25 UTC
Created attachment 160137 [details] [review]
Bug 27113: (follow-up) fix adv. searches - more options display issue

Signed-off-by: David Nind <david@davidnind.com>
Comment 118 Salah Ghedda 2023-12-20 17:09:29 UTC
Created attachment 160138 [details] [review]
Bug 27113: (follow-up) replace removed GetMarcBiblio
Comment 119 Salah Ghedda 2023-12-20 17:09:32 UTC
Created attachment 160139 [details] [review]
Bug 27113: Allow for ending special characters in titles

Modifies the cleanup regex that removed )}' and " endings from the
suggested titles or authors.  When selected without those, the record
was not found.

Ex: "MyTitle (1234)" became "MyTitle (123" in the list.  It returned no
results, where the full title or "MyTitle 123" would.
Comment 120 Salah Ghedda 2023-12-20 17:09:36 UTC
Created attachment 160140 [details] [review]
Bug 27113: (follow-up) diacritics/acccents in sought word would make autocomplete return nothing
Comment 121 Salah Ghedda 2023-12-20 17:09:40 UTC
Created attachment 160141 [details] [review]
Bug 27113: Move filterAutocomplete to a new module and filter the result at search time
Comment 122 Salah Ghedda 2023-12-20 17:09:44 UTC
Created attachment 160142 [details]
Bug 27113: Fix the Input Size of the Catalog Search Bar

This patch addresses the sizing issue with the catalog search bar, ensuring
that the input zone now covers the entire white bar area.

TEST PLAN:

   1) Apply the patches that precede this one.
   2) Activate IntranetAutocompleteElasticSearch and
      OPACAutocompleteElasticSearch in the system preferences.
   2) Click "Catalog search" in the navigation bar.
   3) Click on the right side of the white area of the search bar.
   4) Confirm that it does not allow you to start typing unless you click on the left side of the search bar.
   5) Apply this patch.
   6) Repeat steps 2 and 3.
   7) Verify that this time it allows you to type in the search bar even if you click on the right side of the searc      h bar.
Comment 123 Magnus Enger 2023-12-21 07:29:05 UTC
(In reply to Katrin Fischer from comment #93)
> The last big question, I'll refer to the RM:
> This adds to /svc which is the outdated way of doing things as others have
> pointed out before. I think in order to move on here and before more time is
> spend, we should come to a decision of what is required for this patch to
> make it in and if it needs to be rewritten to use REST API or if this could
> be an exception.

As far as I can see, the patches are still adding to svc, not the REST API? So I guess we need to resolve this question for the bug to move forward?
Comment 124 Katrin Fischer 2023-12-23 12:36:08 UTC
I believe we had a plan here involving solving bug 25870 first as a better base for the work here. It's already linked as a dependency, but needs some more work right now.

I know a lot of people would love to see this functionality and I hope we can figure out the implementation bits this cycle.
Comment 125 Hammat wele 2024-01-16 21:22:14 UTC
Created attachment 161076 [details]
Bug 27113: Fix the Input Size of the Catalog Search Bar
Comment 126 Hammat wele 2024-01-16 21:30:00 UTC
Created attachment 161077 [details] [review]
Bug 27113: Fix the Input Size of the Catalog Search Bar

This patch addresses the sizing issue with the catalog search bar, ensuring
that the input zone now covers the entire white bar area.

TEST PLAN:

   1) Apply the patches that precede this one.
   2) Activate IntranetAutocompleteElasticSearch and
      OPACAutocompleteElasticSearch in the system preferences.
   2) Click "Catalog search" in the navigation bar.
   3) Click on the right side of the white area of the search bar.
   4) Confirm that it does not allow you to start typing unless you click on the left side of the search bar.
   5) Apply this patch.
   6) Repeat steps 2 and 3.
   7) Verify that this time it allows you to type in the search bar even if you click on the right side of the searc      h bar.
Comment 127 Katrin Fischer 2024-01-28 13:24:48 UTC
(In reply to Katrin Fischer from comment #124)
> I believe we had a plan here involving solving bug 25870 first as a better
> base for the work here. It's already linked as a dependency, but needs some
> more work right now.
> 
> I know a lot of people would love to see this functionality and I hope we
> can figure out the implementation bits this cycle.

Can you have a look at bug 25870 maybe?
Comment 128 Matthias Le Gac 2024-03-25 15:20:05 UTC
Created attachment 163826 [details] [review]
Bug 27113: Fix the issue of the cursor not displaying
Comment 129 Caroline Cyr La Rose 2024-04-10 14:48:34 UTC
Blocked by bug 25870
Comment 130 Shi Yao Wang 2024-04-30 13:56:32 UTC
Created attachment 165895 [details] [review]
Bug 27113: ElasticSearch: Autocomplete in input search

Usually the user knows only part of the title of the book or only the name of the author, etc. When he start search something Koha (ElasticSearch) predicts the rest of a word or expression which user is typing.  Autocomplete predicts that thanks to index of ElasticSearch.

TEST PLAN
Important! In this patch we need to do reindex ElasticSearch. ElasticSearch must have all information in his index.
1. Go Intranet -> Preference -> SearchEngine -> ElasticSearch
!! APPLY PATCH !!
2. Mapping is good (Intranet -> Catalog -> Search engine configuration (Elasticsearch) ).
!Recommended 'Reset Mapping'  -> 'Yes'
3. In your koha-conf.xml file you must have good <index_name> for <elasticsearch> and version ES
4. Update Preference:
./installer/data/mysql/updatedatabase.pl
If that passe good you can look the lines:
 - DEV atomic update: bug_27113-elasticsearch_autocomplete_input_search.perl
 - Upgrade to XXX done : Bug 27113 - Autocomplete input on main page with elasticsearch
5. After that we can look two options in the preferences:
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
4. For add information in the index we must run script for reindexing:
./misc/search_tools/rebuild_elasticsearch.pl -v -d
5. Waiting for the end of indexing
6. Go on Preference and find :
-  IntranetAutocompleteElasticSearch;
-  OPACAutocompleteElasticSearch;
Value "Show" turn on autocomplete.
7. Now we have Autocomplete for Intranet/OPAC search input (advanced search also).

Signed-off-by: David Nind <david@davidnind.com>
Comment 131 Shi Yao Wang 2024-04-30 13:56:36 UTC
Created attachment 165896 [details] [review]
Bug 27113: (follow-up) Move new CSS to main SCSS files

This patch removes the separate CSS files added for the autocomplete
feature and puts them into the "main" SCSS files. I think a separate
file isn't necessary because the amount of CSS it adds is so small.

I've also tweaked the style of the autocomplete menu shown when you use
the arrow keys to navigate through the autocomplete choices. I think the
previous white-on-light-green didn't have enough contrast.

To test you must rebuild the OPAC and staff client CSS:
https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client

Follow the previous test plan, being careful to observe how it
works when the autocomplete menu has been triggered and you use the
arrow keys to navigate through the results.

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

Signed-off-by: David Nind <david@davidnind.com>
Comment 132 Shi Yao Wang 2024-04-30 13:56:39 UTC
Created attachment 165897 [details] [review]
Bug 27113: (follow-up) Update descriptions for system preferences

Update the descriptions for the new system preferences -
IntranetAutocompleteElasticSearch and OPACAutocompleteElasticSearch.

Test plan:
1. Review the descriptions for the IntranetAutocompleteElasticSearch
   and OPACAutocompleteElasticSearch system preferences.
2. Make sure they are readable and make sense.

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

Signed-off-by: David Nind <david@davidnind.com>
Comment 133 Shi Yao Wang 2024-04-30 13:56:42 UTC
Created attachment 165898 [details] [review]
Bug 27113: (follow-up) fix adv. searches - more options display issue

Signed-off-by: David Nind <david@davidnind.com>
Comment 134 Shi Yao Wang 2024-04-30 13:56:46 UTC
Created attachment 165899 [details] [review]
Bug 27113: (follow-up) replace removed GetMarcBiblio
Comment 135 Shi Yao Wang 2024-04-30 13:56:49 UTC
Created attachment 165900 [details] [review]
Bug 27113: Allow for ending special characters in titles

Modifies the cleanup regex that removed )}' and " endings from the
suggested titles or authors.  When selected without those, the record
was not found.

Ex: "MyTitle (1234)" became "MyTitle (123" in the list.  It returned no
results, where the full title or "MyTitle 123" would.
Comment 136 Shi Yao Wang 2024-04-30 13:56:52 UTC
Created attachment 165901 [details] [review]
Bug 27113: (follow-up) diacritics/acccents in sought word would make autocomplete return nothing
Comment 137 Shi Yao Wang 2024-04-30 13:56:56 UTC
Created attachment 165902 [details] [review]
Bug 27113: Move filterAutocomplete to a new module and filter the result at search time
Comment 138 Shi Yao Wang 2024-04-30 13:56:59 UTC
Created attachment 165903 [details] [review]
Bug 27113: Fix the Input Size of the Catalog Search Bar

This patch addresses the sizing issue with the catalog search bar, ensuring
that the input zone now covers the entire white bar area.

TEST PLAN:

   1) Apply the patches that precede this one.
   2) Activate IntranetAutocompleteElasticSearch and
      OPACAutocompleteElasticSearch in the system preferences.
   2) Click "Catalog search" in the navigation bar.
   3) Click on the right side of the white area of the search bar.
   4) Confirm that it does not allow you to start typing unless you click on the left side of the search bar.
   5) Apply this patch.
   6) Repeat steps 2 and 3.
   7) Verify that this time it allows you to type in the search bar even if you click on the right side of the searc      h bar.
Comment 139 Shi Yao Wang 2024-04-30 13:57:03 UTC
Created attachment 165904 [details] [review]
Bug 27113: Fix the issue of the cursor not displaying
Comment 140 Shi Yao Wang 2024-04-30 13:57:17 UTC
rebase
Comment 141 Shi Yao Wang 2024-04-30 15:30:28 UTC
Created attachment 165913 [details] [review]
Bug 27113: Fix input size of all searchbar
Comment 142 Shi Yao Wang 2024-04-30 17:03:44 UTC
Created attachment 165922 [details] [review]
Bug 27113: Fix input size of all searchbar