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

            Bug ID: 43885
           Summary: Elasticsearch: sorting on a field without a sort
                    mapping makes the whole search fail
   Initiative type: ---
        Sponsorship ---
            status:
           Product: Koha
           Version: Main
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P5 - low
         Component: Searching - Elasticsearch
          Assignee: [email protected]
          Reporter: [email protected]
        QA Contact: [email protected]
  Target Milestone: ---

QueryBuilder::_sort_field appends "__sort" to the sort field without
checking that such a field exists in the index. When a field used for
sorting (call number, author, title, date of acquisition, popularity...)
is configured as not sortable, or is not mapped at all, Elasticsearch
rejects the whole query:

  No mapping found for [cn-sort__sort] in order to sort on

and Koha shows "You did not specify any search criteria" /
"Unable to perform your search". If defaultSortField or
OPACdefaultSortField points to that field, every search fails.

The code was meant to handle fields without a sort mapping (sorting on
their .raw version for text fields), but that branch is never reached:
get_elasticsearch_mappings only records sortable fields in sort_fields,
so a field that is not sortable is indistinguishable from an unknown
field, and both get "__sort" appended. The existing tests did not catch
it because they mock sort_fields with explicit 0 values.

To reproduce:
1. Administration > Search engine configuration (Elasticsearch):
   set "Sortable" to No for cn-sort and save.
2. Rebuild the index so that the mapping is recreated:
   misc/search_tools/rebuild_elasticsearch.pl -d -b
3. Search the staff interface and sort by call number: the search fails.
4. Set OPACdefaultSortField to "call number": every OPAC search fails.

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to