fix(search-service): fix global search issue#2561
Conversation
e242a42 to
8e3d9eb
Compare
There was a problem hiding this comment.
Pull request overview
Fixes PostgreSQL global-search token sanitization so search terms containing dots (e.g., Deal 10.1) are preserved instead of being split/removed, and adds unit coverage for the updated sanitization behavior.
Changes:
- Update
PsqlQueryBuilder._formatAndSanitizeto allow.in tokens and strip unsafeto_tsqueryoperators. - Add unit tests covering dotted terms (decimals, project names, IPs) and mixed punctuation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| services/search-service/src/classes/psql/query.builder.ts | Adjusts match sanitization/tokenization to preserve dots for PostgreSQL full-text search queries. |
| services/search-service/src/tests/unit/psql/query.builder.unit.ts | Adds targeted unit tests for _formatAndSanitize with dotted search terms and mixed characters. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| _formatAndSanitize(param: string) { | ||
| return param | ||
| .replace(/[^A-Za-z\s0-9]/g, ' ') | ||
| .split(' ') | ||
| .filter(p => p) | ||
| .map(p => `${p}:*`) | ||
| .join('<->'); | ||
| } | ||
| let result = param; | ||
| while (result.endsWith('.')) { | ||
| result = result.slice(0, -1); | ||
| } |
fix global search issue GH-2553
SonarQube reviewer guideSummary: Add comprehensive unit tests and improve sanitization logic for the Review Focus: The sanitization logic change is critical—verify that the new regex patterns correctly preserve dots in identifiers (e.g., "Deal 10.1", "testlift.QA") while removing PostgreSQL tsquery special characters, and ensure the trailing dot removal doesn't introduce edge cases. Confirm the test cases adequately cover expected input patterns. Start review at:
|
| let result = param; | ||
| while (result.endsWith('.')) { | ||
| result = result.slice(0, -1); | ||
| } | ||
|
|
||
| return result | ||
| .replace(/[!&|<>():'"]/g, ' ') // Remove PostgreSQL tsquery special chars | ||
| .replace(/[^A-Za-z0-9.\s]/g, ' ') // Keep dots, remove other symbols | ||
| .split(/\s+/) // Split on any whitespace (not just spaces) | ||
| .filter(p => p && p !== '.') // Filter empty and standalone dots | ||
| .map(p => `${p}:*`) // Add prefix match operator |
There was a problem hiding this comment.
does this need a fix in mysql builder as well
check and confirm
There was a problem hiding this comment.
This issue is specific to PostgreSQL's tsquery syntax requirements. MySQL's full-text search handles dots correctly by default.





fix global search issue
GH-2553
Description
In Global Search, users are unable to see search results when searching for names containing . (dot), for example: Deal 10.1.
The issue originates from the _formatAndSanitize method in query.builder.ts, which is used by search.provider.ts.
Type of change
Checklist: