feat(search): include Template Variable values in manager search#16902
feat(search): include Template Variable values in manager search#16902Ibochkarev wants to merge 2 commits intomodxcms:3.xfrom
Conversation
- Add search in modTemplateVarResource.value when quick_search_in_content is enabled - Refactor searchResources into smaller methods: getResourceContextKeys, buildResourceSearchCriteria, getResourceIdsMatchingTvValues, applyResourceSearchSortBy, formatResourceSearchResult - Apply relevance ordering: exact pagetitle, pagetitle prefix, other fields, content, TV match, then createdon DESC - Limit TV-matched resource IDs to getMaxResults()*2 and deduplicate Resolves modxcms#16703
Code ReviewSummaryAdds TV value search to manager quick search, refactors Issues
$escaped = addcslashes($this->query, '%_');
$c->where(['value:LIKE' => '%' . $escaped . '%']);Non-blocking — this is a pre-existing issue.
Suggestions
AssessmentClean refactoring — the monolithic method is split into logical parts, each with PHPDoc and return types. TV search uses a separate query with deduplication and limit to prevent oversized IN clauses. Relevance sorting is a solid UX improvement. All queries use xPDO criteria API, VerdictApprove — issues are non-blocking, PR is ready to merge. |
It's a bit counterintuitive that the
So if the pagetitle contains the search term but not at the beginning, then this resource is not at the top of the result-list. Why?
For what reason is a multiplying factor of 2 used here?
|
What does it do?
modTemplateVarResource.value) when "Search in content" is enabled in manager search.getResourceContextKeys,buildResourceSearchCriteria,getResourceIdsMatchingTvValues,applyResourceSearchSortBy,formatResourceSearchResult.createdonDESC).getMaxResults() * 2and deduplicates to avoid oversized IN clauses.Why is it needed?
Manager quick search did not look inside TV values, so resources that matched only by custom TV fields were not found. This change includes TV values in the search scope and orders results by relevance.
How to test
Related issue(s)/PR(s)
Resolves #16703