Bug 40243 - Single word search terms for 'Title as phrase' searches don't limit properly
Summary: Single word search terms for 'Title as phrase' searches don't limit properly
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: 24.11
Hardware: All All
: P5 - low enhancement
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-06-25 17:40 UTC by Sara Brown
Modified: 2025-07-17 14:18 UTC (History)
7 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sara Brown 2025-06-25 17:40:10 UTC
When using the Title as phrase index on Elasticsearch, single-word searches return results with additional words in the title. A title as phrase search for 'gift horse' returns what I would expect - 'A gift horse', 'The gift horse', and 'Gift horse'. However, a title as phrase search for 'horse' returns 'The horse', 'War horse', 'The gift horse', 'Horse adventures' (etc.).

This happens regardless of whether the search term is surrounded by quotations. And in the testing above,  QueryAutoTruncate was set to 'only if * is added.'
Comment 1 Andrew Fuerste-Henry 2025-06-27 12:41:57 UTC
QueryAutoTruncate determines whether or not Koha truncates individual words within search -- so with QueryAutoTruncate on, a search for "horse" could return "horsefly" and "horsehair." 
(As opposed to QueryStemming, which would allow "horse" to return "horsing" -- the need to drop the "e" when adding the "ing" makes it more than QueryAutoTruncate can handle.) 

The search documentation says Title As Phrase is an exact phrase search and says this about exact searches.
"ext : exact search on whole subfield (does not work with icu)"

You're looking for this to mean "my entire search term must match the entire title." It appears to currently behave as "my entire search term must match part of the title."
Comment 2 Kristi Krueger 2025-06-30 21:06:44 UTC
I'm not sure about the technicalities here, but we'd be grateful to have a search possibility like Sara describes. That is, if I search for title as phrase with a one-word title, I'd hope to see that one-word title at the top of the search results. 

Or, we'd like to see an option for left-anchored searches.
Comment 3 Andrew Fuerste-Henry 2025-07-01 12:09:50 UTC
Bug 38694 should help here, as it will boost exact title matches within title and keyword searches. If those titles were more findable in a general search, would you still find need for a search limited to *only* full title matches?
Comment 4 lthorrat@cuyahogalibrary.org 2025-07-01 13:07:08 UTC
Hi Andrew, 

I think bug 38694 is a great functionality, and I want it, but that doesn't solve my searching issues.  I think this bug and bug 6425 get at what I would like to see improved in Elastasearch.  Sometimes you just need to be able to search with a left anchored index.  The search that prompted Kristi's input to this yesterday was for "Cookies" but I only wanted titles that started with that word.