Skip to content

Commit

Permalink
[ACS-6427] Apply * for TEXT field for highlighting (#3659)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalKinas committed Feb 21, 2024
1 parent 3f182a5 commit 1141b81
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,6 @@ describe('SearchComponent', () => {
expect(query).toBe(`(cm:name:"hello*" OR cm:title:"hello*")`);
});

it('should not apply suffix to the TEXT field for correct highlighting', () => {
const query = component.formatSearchQuery('hello', ['cm:name', 'TEXT']);
expect(query).toBe(`(cm:name:"hello*" OR TEXT:"hello")`);
});

it('should format user input as cm:name if configuration not provided', () => {
const query = component.formatSearchQuery('hello');
expect(query).toBe(`(cm:name:"hello*")`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,7 @@ export class SearchResultsComponent extends PageComponent implements OnInit {
term = term.substring(1);
}

return (
'(' +
fields
.map((field) => {
return field !== 'TEXT' ? `${prefix}${field}:"${term}${suffix}"` : `${prefix}${field}:"${term}"`;
})
.join(' OR ') +
')'
);
return '(' + fields.map((field) => `${prefix}${field}:"${term}${suffix}"`).join(' OR ') + ')';
}

formatSearchQuery(userInput: string, fields = ['cm:name']) {
Expand Down

0 comments on commit 1141b81

Please sign in to comment.