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: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching - Elasticsearch (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement (vote)
Target Milestone: ---
Assignee: Alex Arnaud
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 18316
Blocks:
  Show dependency treegraph
 
Reported: 2018-04-18 13:40 UTC by claire.hernandez@biblibre.com
Modified: 2019-04-12 09:24 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:


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

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>