Merge pull request #10 from backstage/master

Fetching commits from main
This commit is contained in:
vidhanshah
2025-11-21 22:41:59 +05:30
committed by GitHub
7 changed files with 45 additions and 5 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-search-backend-node': minor
---
Improving method that search tokenizer breaks apart entity names
+7
View File
@@ -0,0 +1,7 @@
---
'@backstage/ui': patch
---
Fixed Table column sorting indicator to show up arrow when no sort is active, correctly indicating that clicking will sort ascending.
Affected components: Column
@@ -509,6 +509,7 @@ thumbsup
todo
todos
togglable
tokenizer
tolerations
Tolerations
toolchain
@@ -48,10 +48,10 @@ export const Column = (props: ColumnProps) => {
styles[classNames.headSortButton],
)}
>
{sortDirection === 'ascending' ? (
<RiArrowUpLine size={16} />
) : (
{sortDirection === 'descending' ? (
<RiArrowDownLine size={16} />
) : (
<RiArrowUpLine size={16} />
)}
</span>
)}
@@ -520,7 +520,7 @@ describe('LunrSearchEngine', () => {
fields: {
title: `${highlightTags.pre}testTitle${highlightTags.post}`,
text: `${highlightTags.pre}testText${highlightTags.post}`,
location: `${highlightTags.pre}test/location${highlightTags.post}`,
location: `${highlightTags.pre}test${highlightTags.post}/location`,
},
},
rank: 1,
@@ -106,4 +106,31 @@ describe('LunrSearchEngineIndexer', () => {
...[lunr.trimmer, lunr.stopWordFilter, lunr.stemmer],
);
});
it('should tokenize input on non-alphanumeric characters', () => {
const input =
"Tokenize_test string, entity-name. Doesn't break abc123def - also Unicode support also!三 stjärna عربي";
const expectedTokens = [
'tokenize',
'test',
'string',
'entity',
'name',
'doesn',
't',
'break',
'abc123def',
'also',
'unicode',
'support',
'also',
'三',
'stjärna',
'عربي',
];
const tokens = lunr.tokenizer(input).map(token => token.toString());
expect(tokens).toEqual(expectedTokens);
});
});
@@ -29,8 +29,8 @@ export class LunrSearchEngineIndexer extends BatchSearchEngineIndexer {
constructor() {
super({ batchSize: 1000 });
this.builder = new lunr.Builder();
this.builder.tokenizer.separator = /[^\p{L}\p{N}]+/u;
this.builder.pipeline.add(lunr.trimmer, lunr.stopWordFilter, lunr.stemmer);
this.builder.searchPipeline.add(lunr.stemmer);
this.builder.metadataWhitelist = ['position'];