Bug 23649 - Elasticsearch offer an option to weight search results by type
Summary: Elasticsearch offer an option to weight search results by type
Status: In Discussion
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching - Elasticsearch (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement with 20 votes (vote)
Assignee: Bugs List
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-19 20:38 UTC by Nick Clemens
Modified: 2023-08-31 19:13 UTC (History)
7 users (show)

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


Attachments
[Do not push] - Experimental support for function_score (2.27 KB, patch)
2023-02-13 15:43 UTC, Björn Nylén
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens 2019-09-19 20:38:43 UTC
Some libraries would like to be able to prioritize "books" over "large print" , audios, etc in the search results
Comment 1 Barbara Johnson 2019-09-20 14:12:57 UTC
Providing a way to organize the different formats for a title would provide an expected and reliable results display. It would improve searching for both patrons and staff.
Comment 2 Mwoo 2019-09-20 20:54:44 UTC
Assigning "weight" values to items would be a huge timesaver and alleviate a lot of patron frustrations.  Our patrons will often put a hold on a large print book simply because it shows up first in their search. Invariably they didn't want the large print and are mad and disappointed.
Comment 3 Mwoo 2019-09-20 20:55:38 UTC
Assigning "weight" values to items would be a huge timesaver and alleviate a lot of patron frustrations.  Our patrons will often put a hold on a large print book simply because it shows up first in their search. Invariably they didn't want the large print and are mad and disappointed.
Comment 4 Björn Nylén 2023-02-13 15:43:35 UTC
Created attachment 146585 [details] [review]
[Do not push] - Experimental support for function_score

We've been experimenting a bit with function_score query in our ES-searches as we're having the same problems with not very relevant records showing high in the results.

The patch allows us to assign different function_score-functions to promote/demote records in the resultlist.

It's a bit of work in progress but if someone wants to try it out:
Apply patch
Create a Local use syspref, ElasticsearchFunctionScore , textarea
Fill in syspref with yaml representing av array of function scores as understood by ES.
Eg(modify itype to local condidtions):
- filter:
    match:
      itype: "3"
  weight: 1.5
Comment 5 Björn Nylén 2023-02-13 15:53:26 UTC
More interesting things can be done eg. maths:  

In this case we want to promote newer books over older. So define a new numeric field 'pubyear-numeric' in the ES mappings and map it to 008/07-10.
After some existance- and sanity-checking we weight records (in this case) newer than 1980 higher. 

- script_score:
    script:
      source: "long y = doc['pubyear-numeric'].size()==0 ? params.start : doc['pubyear-numeric'].value; y = (y<params.start || y>2100) ? params.start : y;  return (y-params.start)/params.divider+1;"
      params:
        start: 1980
        divider: 20
Comment 6 Michael Adamyk 2023-08-31 19:13:17 UTC
This would be great! We often get random items like cake pans, kits, etc. near the top of our search results, which can be frustrating. More customization for search weights would be fantastic.