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

            Bug ID: 44061
           Summary: Advanced search call number index truncates each word
                    and matches unrelated classmarks
   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: ---

With QueryAutoTruncate enabled and Elasticsearch, an advanced search on the
Call number index for "W 4" is sent as:

  local-classification:(W* 4*)

QueryAutoTruncate appends * to every whitespace-separated word (_truncate_terms
in Koha::SearchEngine::Elasticsearch::QueryBuilder). local-classification is
not excluded by _is_safe_to_auto_truncate, it is a plain text field analysed
with icu_tokenizer, and the default operator is AND. So W* matches W, WA, WB,
WX... and 4* matches 4, 40, 400..., in any order, and the two words can come
from different items on the same record because the field is multi-valued
(952$o of every item).

Searching for the classmark "W 4" therefore returns records with call numbers
such as "WA 410" or "QA 40 W". Putting the term in quotes gives an adjacent
whole-token phrase match and avoids this, but staff do not expect to have to.

Options to discuss:
- Treat the callnum/lcn index as a phrase search by default (like quoting) and
do not auto truncate it. Loses prefix searching such as "QA 7" finding "QA
76.73".
- Truncate only the last word of the call number (phrase prefix), so "W 4"
still finds "W 410" but not "WA 4".
- Leave behaviour as is and document using ElasticsearchPreventAutoTruncate =
local-classification plus quotes.

Test plan to reproduce:
1. Use Elasticsearch with QueryAutoTruncate on
2. Create items with call numbers "W 4", "W 410", "WA 4" and "QA 40 W"
3. Advanced search, Call number index, term W 4
4. All four records match; with "W 4" in quotes only W 4 does

Note: found by reading the code; the reproduction above has not yet been
confirmed on a live Elasticsearch instance.

-- 
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