fix(search): recover exact-name and mid-token matches in the legacy relationship dialog (#37052) - #37056
Conversation
…elationship dialog (#37052)
|
Claude finished @ihoffmann-dot's task in 2m 15s —— View job Code ReviewI reviewed the diff against
FindingsThe fix is correct and faithfully mirrors One item worth a look before merge: New Issues
No security, transaction, or convention issues (query-construction only, values escaped via the existing Overall this is a clean, well-scoped, well-tested fix — the Medium item is non-blocking. |
| // including mid-word). Mirrors GlobalSearchAttributeStrategy, which is | ||
| // the equivalent gate for the new Content Search / Content Drive path. | ||
| luceneQuery.append("+(catchall:" + fieldValueStr + "*^10 OR title_dotraw:*" | ||
| + fieldValueStr + "*^2) "); |
There was a problem hiding this comment.
how did you choose the ^10 and ^2?
Problem
#36791 / PR #36793 fixed the exact-name and mid-token matching gap in
GlobalSearchAttributeStrategy— the shared strategy behind the Content Search portlet, Content Drive's keyword search, and the new (Angular) edit content Relationships dialog.The legacy (Dojo/JSP) edit content screen never goes through that code. Its "Relate" dialog is
dotcms.dijit.form.ContentSelector, which dispatches over DWR toContentletAjax.searchContentletsByUser— a separate, drifted copy of the same logic that still gates on a catchall-only prefix:The
title_dotrawwildcard was already there, but only as an optional boost clause — the mandatory+catchall:<term>*had already excluded the document, so it never rescued anything. Surfaced during QA of #36791.Fix
Make the
catchallgate a disjunction, mirroringGlobalSearchAttributeStrategy:title_dotrawis scoped to a single field, so this recovers mid-token and exact-full-value matches without reintroducing the broad, whole-documentcatchall:*term*removed in [BUG] Content Drive: keyword/title search returns inconsistent or incoherent results #36688.Two deliberate secondary changes worth a reviewer's eye:
catchallbranch is now evaluated before thecontains("-")branch. Previously a term containing a dash (e.g.nordic-skiing) fell into the no-wildcard branch and behaved differently.GlobalSearchAttributeStrategyhas no such special case, so this aligns the two.languageIdkeeps its existing handling.title_dotraw:*value*^5boost was removed, since the same clause is now part of the mandatory gate at^2. Keeping both would duplicate the clause.Validation
New integration test
ContentletAjaxTest#test_searchContentletsByUser_globalSearch_matchesMidTokenAndExactFullName, seeding a File Asset namedIMG_<uniqueToken>_0004.jpeg(tokenizes toimg_<uniqueToken>_0004+jpeg):IMG_<uniqueToken>(genuine token prefix)<uniqueToken>(mid-token)title_dotrawsubstringIMG_<uniqueToken>_0004.jpeg(exact full name, spans the.)title_dotrawsubstringzz<uniqueToken>(in no field)The term is unique per run so the assertions hold against the shared test index.
Red/Green verified. With the production change reverted the test fails on the mid-token assertion (
expected:<1> but was:<0>) while the preceding token-prefix assertion passes — so it isolates this defect rather than failing for an unrelated reason. With the fix,ContentletAjaxTestis 10/10 green (9 pre-existing + 1 new). The class is already registered inMainSuite2a, so no suite changes were needed.Scope
Closes #37052. Follow-up to #36791 / PR #36793 — same defect, second code path.
Out of scope / follow-ups
ContentletAjaxcallGlobalSearchAttributeStrategydirectly (asBrowserAPIImplalready does). Removes the drift at the root, but touches more legacy surface than this fix warrants.