Bug 20607 - Elasticsearch - ability to add a relevancy weight in mappings.yaml file
Summary: Elasticsearch - ability to add a relevancy weight in mappings.yaml file
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching - Elasticsearch (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Alex Arnaud
QA Contact:
URL:
Keywords:
Depends on: 18316
Blocks:
  Show dependency treegraph
 
Reported: 2018-04-18 13:40 UTC by claire.hernandez@biblibre.com
Modified: 2020-06-04 20:33 UTC (History)
9 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
19.11.00,19.05.03


Attachments
Bug 20607 - Make Koha::SearchEngine::Elasticsearch::reset_elasticsearch_mappings take weight into account (4.38 KB, patch)
2018-04-24 13:15 UTC, Alex Arnaud
Details | Diff | Splinter Review
Bug 20607 - Make Koha::SearchEngine::Elasticsearch::reset_elasticsearch_mappings take weight into account (4.66 KB, patch)
2019-04-04 09:01 UTC, Alex Arnaud
Details | Diff | Splinter Review
Bug 20607 - Make Koha::SearchEngine::Elasticsearch::reset_elasticsearch_mappings take weight into account (4.72 KB, patch)
2019-04-12 09:24 UTC, Nicolas Legrand
Details | Diff | Splinter Review
Bug 20607: Make Koha::SearchEngine::Elasticsearch::reset_elasticsearch_mappings take weight into account (4.79 KB, patch)
2019-07-16 18:15 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 20607: (QA follow-up) (1.22 KB, patch)
2019-07-16 18:15 UTC, Nick Clemens
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description claire.hernandez@biblibre.com 2018-04-18 13:40:59 UTC
The code could be able to inject mappings and weight if a mapping in mappings.yaml file contains boost-in-simple-search:

Exemple:

  Personal-name:                                                                                                                                                                         
    label: Personal-name                                                                                                                                                                 
    mappings:                                                                                                                                                                            
      - facet: ''                                                                                                                                                                        
        marc_field: 100abcdefghjklmnopqrstvxyz                                                                                                                                           
        marc_type: marc21                                                                                                                                                                
        sort: ~                                                                                                                                                                          
        suggestible: ''                                                                                                                                                                  
      - facet: ''                                                                                                                                                                        
        marc_field: 100abcdefghjklmnopqrstvxyz                                                                                                                                           
        marc_type: normarc                                                                                                                                                               
        sort: ~                                                                                                                                                                          
        suggestible: ''                                                                                                                                                                  
    type: '' 
    boost-in-simple-search: 4              

4 is added in field weight in table search_field.
Comment 1 claire.hernandez@biblibre.com 2018-04-18 13:42:35 UTC
(Maybe an enhancement could be :

```
mappings:
    - ...
settings:
    boost-in-simple-search: 4
```

in replacement of

```
mappings:
    - ...
boost-in-simple-search: 4
```

but not sure)
Comment 2 Alex Arnaud 2018-04-24 13:15:29 UTC
Created attachment 74805 [details] [review]
Bug 20607 - Make Koha::SearchEngine::Elasticsearch::reset_elasticsearch_mappings take weight into account

Test plan:
  - apply BZ 18316 and this one,
  - update DB and schema files,
  - edit admin/searchengine/elasticsearch/mappings.yaml
    to add weight for some fields,
  - go to admin > search engine configuration,
  - reset your mappings (add ?op=reset&i_know_what_i_am_doing=1 to url),
  - check that weights you've added are set
Comment 3 Björn Nylén 2019-03-12 13:18:10 UTC
The functionality works but the tests fail due to the weight is beeing returned as a decimal number.

#   Failed test 'Match search field is weighted with 15'
#   at t/db_dependent/Koha/SearchEngine/Elasticsearch/Reset.t line 61.
#          got: '15.00'
#     expected: '15'

#   Failed test 'Title search field is weighted with 20'
#   at t/db_dependent/Koha/SearchEngine/Elasticsearch/Reset.t line 64.
#          got: '20.00'
#     expected: '20'
# Looks like you failed 2 tests of 4.
Comment 4 Michal Denar 2019-04-04 07:49:52 UTC
Alex, can you rebase this bug on master?

Thank you.
Comment 5 Alex Arnaud 2019-04-04 09:01:24 UTC
Created attachment 87402 [details] [review]
Bug 20607 - Make Koha::SearchEngine::Elasticsearch::reset_elasticsearch_mappings take weight into account

Test plan:
  - apply this patch,
  - edit admin/searchengine/elasticsearch/mappings.yaml
    to add weight for some fields,
  - go to admin > search engine configuration,
  - reset your mappings (add ?op=reset&i_know_what_i_am_doing=1 to url),
  - check that weights you've added are set
Comment 6 Alex Arnaud 2019-04-04 09:02:58 UTC
(In reply to Michal Denar from comment #4)
> Alex, can you rebase this bug on master?
> 
> Thank you.

Done! Thank you for reminding me of that BZ
Comment 7 Nicolas Legrand 2019-04-12 09:24:13 UTC
Created attachment 87874 [details] [review]
Bug 20607 - Make Koha::SearchEngine::Elasticsearch::reset_elasticsearch_mappings take weight into account

Test plan:
  - apply this patch,
  - edit admin/searchengine/elasticsearch/mappings.yaml
    to add weight for some fields,
  - go to admin > search engine configuration,
  - reset your mappings (add ?op=reset&i_know_what_i_am_doing=1 to url),
  - check that weights you've added are set

Signed-off-by: Nicolas Legrand <nicolas.legrand@bulac.fr>
Comment 8 Nick Clemens 2019-06-11 13:36:51 UTC
Patches work, however, the tests delete all my data, then start a transaction at the end?

QA tool doesn't like commit title
Comment 9 Nick Clemens 2019-07-16 18:15:01 UTC
Created attachment 91560 [details] [review]
Bug 20607: Make Koha::SearchEngine::Elasticsearch::reset_elasticsearch_mappings take weight into account

Test plan:
  - apply this patch,
  - edit admin/searchengine/elasticsearch/mappings.yaml
    to add weight for some fields,
  - go to admin > search engine configuration,
  - reset your mappings (add ?op=reset&i_know_what_i_am_doing=1 to url),
  - check that weights you've added are set

Signed-off-by: Nicolas Legrand <nicolas.legrand@bulac.fr>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 10 Nick Clemens 2019-07-16 18:15:06 UTC
Created attachment 91561 [details] [review]
Bug 20607: (QA follow-up)

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 11 Martin Renvoize 2019-07-19 09:10:03 UTC
Nice work!

Pushed to master for 19.11.00
Comment 12 Fridolin Somers 2019-08-06 13:55:00 UTC
Pushed to 19.05.x for 19.05.03