Bug 24807: Add "year" type to improve sorting behaviour
authorDavid Gustafsson <david.gustafsson@ub.gu.se>
Wed, 4 Mar 2020 16:07:11 +0000 (17:07 +0100)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 18 Sep 2020 09:21:31 +0000 (11:21 +0200)
commitd1c8d7eccee6e75473bf7c780617d683f64e5229
tree0d5d480bbf42772275ed556fa85515e242ef986e
parent3b273de5777ac7dd5bebac629dc8c88e6bdc962a
Bug 24807: Add "year" type to improve sorting behaviour

Add a "year" search field type. Fields with this type will only
retain values that looks like years, so invalid values such as
whitespace or word characters will not be indexed.
This for instance improves the behaviour when sorting by
"date-of-publication". If all values are indexed, records with
junk data instead of valid years will appear first among the search
results, drowning out more relevant hits. If assigning this field
the "year" type these records will instead always appear last,
regarless of sort order.

To test:

1) Have at least two biblios, one with a valid year in 008 (pos 7-10)
and another with an invalid one ("uuuu" for example)
2) Perform a wildcard search (*) and sort results by publication date.
3) The record with invalid year of pulication in 008 should appear first
4) Apply patch and run database updates
5) Reindex ElasticSearch
6) Perform the same search as in 2)
7) The record with the invalid year should now appear last

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Koha/SearchEngine/Elasticsearch.pm
Koha/SearchEngine/Elasticsearch/Indexer.pm
admin/searchengine/elasticsearch/field_config.yaml
koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt
t/db_dependent/Koha/SearchEngine/Elasticsearch.t