Bug 22426

Summary: Elasticsearch - Index location is missing in advanced search
Product: Koha Reporter: Marjorie Barry-Vila <marjorie.barry-vila>
Component: Searching - ElasticsearchAssignee: Fridolin Somers <fridolin.somers>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P5 - low CC: 1joynelson, black23, bouzid.fergani, e.betemps, fridolin.somers, jonathan.druart, mkstephens, nick, patrick.robitaille, s.deflache, sandboxes
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24127
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24109
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.05.00, 19.11.03
Attachments: Bug 22426: Elasticsearch - Index location is missing in advanced search
Bug 22426: (alternate) Elasticsearch fix location limit in advanced search
Bug 22426: Elasticsearch - Index location is missing in advanced search
Bug 22426: (alternate) Elasticsearch fix location limit in advanced search
Bug 22426: (alternate) Elasticsearch fix location limit in advanced search
Bug 22426: Map 'loc' to 'location' when building ES queries

Description Marjorie Barry-Vila 2019-02-27 17:21:32 UTC
Hi,

A search made on Shelving location tab in advanced search gives 0 result.

Test plan :
- in advanced search, choose a location in shelving location tab and start search (opac-search.pl?idx=kw&op=and&idx=kw&op=and&idx=kw&do=Search&limit=mc-loc)
- 0 result
- check that location exist by doing a simple search and filtering on the location facet
- have some results

I think problem is index "loc" is used in advanced search or it could be index "location" like facet.

Or is it a configuration problem?

Regards
Marjorie
Comment 1 Bouzid Fergani 2019-05-06 17:39:48 UTC
Created attachment 89378 [details] [review]
Bug 22426: Elasticsearch - Index location is missing in advanced search
Comment 2 Michal Denar 2019-05-06 21:05:30 UTC
Any test plan?
Comment 3 Bouzid Fergani 2019-05-07 12:41:25 UTC
Test plan :
Without patch:
    - in advanced search, choose a location in shelving location tab and start search (opac-search.pl?idx=kw&op=and&idx=kw&op=and&idx=kw&do=Search&limit=mc-loc)
    - 0 result
    - check that location exist by doing a simple search and filtering on the    location facet
    - have some results

With patch:
     
    - in advanced search, choose a location in shelving location tab and start search (opac-search.pl?idx=kw&op=and&idx=kw&op=and&idx=kw&do=Search&limit=mc-loc)
    - found results
Thanks.
Comment 4 Michal Denar 2019-05-07 19:38:30 UTC
Sorry, but link from test plan gives me:

No results found!

You did not specify any search criteria.
Error:
Unable to perform your search. Please try again. 

I tried reindex ES, but same result.

Link from working search looks like:
cgi-bin/koha/opac-search.pl?advsearch=1&idx=kw&q=a&idx=kw&idx=kw&limit=branch%3ACPL&limit=available&sort_by=relevance&do=Search
Comment 5 Marjorie Barry-Vila 2019-05-13 15:45:42 UTC
(In reply to Michal Denar from comment #4)
> Sorry, but link from test plan gives me:
> 
> No results found!
> 
> You did not specify any search criteria.
> Error:
> Unable to perform your search. Please try again. 
> 
> I tried reindex ES, but same result.
> 
> Link from working search looks like:
> cgi-bin/koha/opac-search.
> pl?advsearch=1&idx=kw&q=a&idx=kw&idx=kw&limit=branch%3ACPL&limit=available&so
> rt_by=relevance&do=Search

Hi Michal,


In your url I see the limitation by branch (limit=branch%3ACPL) but not on a location (mc-loc)
The patch is to solve the problem of searching on the index location.

You should have a result of type opac-search.pl?idx=kw&op=and&idx=kw&op=and&idx=kw&do=Search&limit=mc-loc


Regards,
Marjorie
Comment 6 Fridolin Somers 2019-06-17 14:12:48 UTC
I see that there is a removal of "mc-" before index to field convertion : 

Added by commit : 
Bug 12478: fix multi-choice stuff in advanced search

In Koha/SearchEngine/Elasticsearch/QueryBuilder.pm :
        my $mc = '';
        if ($f =~ /^mc-/) {
            $mc = 'mc-';
            $f =~ s/^mc-//;
        }

And in %index_field_convert there is :
'mc-loc' => 'location'

So I think adding loc => location should fix the problem.
That is why there is no problem with mc-ccode and mc-itemtype.
Comment 7 Fridolin Somers 2019-06-17 14:18:33 UTC
Created attachment 90670 [details] [review]
Bug 22426: (alternate) Elasticsearch fix location limit in advanced search

A search made on Shelving location tab in advanced search gives 0 result.

Test plan :
Without patch:
    - in advanced search, choose a location in shelving location tab and start search (opac-search.pl?idx=kw&op=and&idx=kw&op=and&idx=kw&do=Search&limit=mc-loc)
    - 0 result
    - check that location exist by doing a simple search and filtering on the    location facet
    - have some results
With patch:
    - in advanced search, choose a location in shelving location tab and start search (opac-search.pl?idx=kw&op=and&idx=kw&op=and&idx=kw&do=Search&limit=mc-loc)
    - found results
Comment 8 Fridolin Somers 2019-06-17 14:19:55 UTC
Here is my alternate patch.
Don't hesitate to discuss it.
Kind regards ;)
Comment 9 Biblibre Sandboxes 2019-10-02 08:01:11 UTC
Patch tested with a sandbox, by Séverine QUEUNE <severine.queune@bulac.fr>
Comment 10 Biblibre Sandboxes 2019-10-02 08:01:44 UTC
Created attachment 93397 [details] [review]
Bug 22426: Elasticsearch - Index location is missing in advanced search

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Comment 11 Biblibre Sandboxes 2019-10-02 08:01:48 UTC
Created attachment 93398 [details] [review]
Bug 22426: (alternate) Elasticsearch fix location limit in advanced search

A search made on Shelving location tab in advanced search gives 0 result.

Test plan :
Without patch:
    - in advanced search, choose a location in shelving location tab and start search (opac-search.pl?idx=kw&op=and&idx=kw&op=and&idx=kw&do=Search&limit=mc-loc)
    - 0 result
    - check that location exist by doing a simple search and filtering on the    location facet
    - have some results
With patch:
    - in advanced search, choose a location in shelving location tab and start search (opac-search.pl?idx=kw&op=and&idx=kw&op=and&idx=kw&do=Search&limit=mc-loc)
    - found results

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Comment 12 Jonathan Druart 2019-12-05 11:48:59 UTC
I am not sure which is the best fix here.
Comment 13 Nick Clemens 2020-01-10 14:13:57 UTC
*** Bug 24109 has been marked as a duplicate of this bug. ***
Comment 14 Nick Clemens 2020-01-10 14:14:54 UTC
The alternate patch would be my preference - the first treats mc-loc as a special case, I think it fits more to add it to the map like other mc-fields are
Comment 15 Jonathan Druart 2020-01-10 14:19:37 UTC
Created attachment 97223 [details] [review]
Bug 22426: (alternate) Elasticsearch fix location limit in advanced search

A search made on Shelving location tab in advanced search gives 0 result.

Test plan :
Without patch:
    - in advanced search, choose a location in shelving location tab and start search (opac-search.pl?idx=kw&op=and&idx=kw&op=and&idx=kw&do=Search&limit=mc-loc)
    - 0 result
    - check that location exist by doing a simple search and filtering on the    location facet
    - have some results
With patch:
    - in advanced search, choose a location in shelving location tab and start search (opac-search.pl?idx=kw&op=and&idx=kw&op=and&idx=kw&do=Search&limit=mc-loc)
    - found results

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 16 Jonathan Druart 2020-01-10 14:20:25 UTC
Created attachment 97224 [details] [review]
Bug 22426: Map 'loc' to 'location' when building ES queries

A search made on Shelving location tab in advanced search gives 0 result.

Test plan :
Without patch:
    - in advanced search, choose a location in shelving location tab and start search (opac-search.pl?idx=kw&op=and&idx=kw&op=and&idx=kw&do=Search&limit=mc-loc)
    - 0 result
    - check that location exist by doing a simple search and filtering on the    location facet
    - have some results
With patch:
    - in advanced search, choose a location in shelving location tab and start search (opac-search.pl?idx=kw&op=and&idx=kw&op=and&idx=kw&do=Search&limit=mc-loc)
    - found results

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 17 Martin Renvoize 2020-01-10 16:23:28 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 18 Joy Nelson 2020-01-31 00:20:44 UTC
Pushed to 19.11.x branch for 19.11.03