https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23649

--- Comment #16 from Pedro Amorim (ammopt) <[email protected]> ---
Created attachment 200656
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200656&action=edit
Bug 23649: Add tests for function_score value boosts in QueryBuilder

Tests _get_value_boost_functions and the function_score wrapping in
build_query. Covers: empty arrayref when no boosts configured, correct
filter/weight structure per boost, score_mode/boost_mode values, the
original bool query preserved inside function_score, and authorities
index not wrapped.

Mocks _get_value_boost_functions at module level so existing build_query
tests are unaffected by any value boosts present in the test DB or cache.

0) Launch ktd with elastic search:
$ ktd --search-engine es8 up
1) Apply patches, updatedatabase and restart plack.
2) Do a search for 'music' and leave this tab available (so we can come back to
it and compare relevance sorting):
<staff_url>/cgi-bin/koha/catalogue/search.pl?q=music
3) Go to the Elasticsearch mappings admin page:
<staff_url>/cgi-bin/koha/admin/searchengine/elasticsearch/mappings.pl
4) Click the 'bibliographic records' tab. Confirm a 'Relevance boosts' section
appears at the bottom with an empty table and an add form.
5) In the add form, select a facetable field (e.g. 'Item type'), enter value
'MU' and weight '2.00'. Click 'Add'.
6) Confirm the boost appears in the table with the correct field, value and
weight.
7) Add a second boost on the same field (Item type) with value 'BK' and weight
'0.5'. Click 'Add'.
8) Confirm both boosts are listed.
9) Perform the same 'music' search on a new tab:
<staff_url>/cgi-bin/koha/catalogue/search.pl?q=music
10) Confirm that 'MU' (music) biblios now appear first. And BK (Books) only
show more prominently towards the end of the results.
11) Click 'Delete' on the MU boost. Confirm it disappears from the table.
12) Perform the search again. Notice many 'MU' music biblios still show first,
because BK (Books) are still being penalized (0.50 weight). But e.g. biblio 437
'Clothes, clothes, clothes' now appears in position #15 instead of position
#20.
12) Go to the 'authorities' tab. Confirm no 'Relevance boosts' section appears
there.
13) Try adding a new search field value boost with the '+Add' button with an
empty field value. Confirm an error message appears and nothing is saved.
14) Try submitting with weight '0' or a negative number. Confirm a "must be a
positive decimal" error appears.
Note: boosts are applied at search time, not index time — changing or deleting
a boost takes effect immediately with no reindexing required.

prove t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t
prove t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t
prove t/db_dependent/Koha/SearchEngine/Elasticsearch/Search.t
prove t/db_dependent/Koha/SearchEngine/Elasticsearch/Reset.t
prove t/db_dependent/Koha/SearchField.t
prove t/00-load.t

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to