diff --git a/.changeset/chilly-hotels-walk.md b/.changeset/chilly-hotels-walk.md new file mode 100644 index 0000000000..e9b1ff66ba --- /dev/null +++ b/.changeset/chilly-hotels-walk.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-search-backend-node': minor +--- + +Improving method that search tokenizer breaks apart entity names diff --git a/.changeset/twenty-ducks-relate.md b/.changeset/twenty-ducks-relate.md new file mode 100644 index 0000000000..359eda66f3 --- /dev/null +++ b/.changeset/twenty-ducks-relate.md @@ -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 diff --git a/.github/vale/config/vocabularies/Backstage/accept.txt b/.github/vale/config/vocabularies/Backstage/accept.txt index 7c780c1079..6697fad858 100644 --- a/.github/vale/config/vocabularies/Backstage/accept.txt +++ b/.github/vale/config/vocabularies/Backstage/accept.txt @@ -509,6 +509,7 @@ thumbsup todo todos togglable +tokenizer tolerations Tolerations toolchain diff --git a/packages/ui/src/components/Table/components/Column.tsx b/packages/ui/src/components/Table/components/Column.tsx index f534da565a..78c45f6a3c 100644 --- a/packages/ui/src/components/Table/components/Column.tsx +++ b/packages/ui/src/components/Table/components/Column.tsx @@ -48,10 +48,10 @@ export const Column = (props: ColumnProps) => { styles[classNames.headSortButton], )} > - {sortDirection === 'ascending' ? ( - - ) : ( + {sortDirection === 'descending' ? ( + ) : ( + )} )} diff --git a/plugins/search-backend-node/src/engines/LunrSearchEngine.test.ts b/plugins/search-backend-node/src/engines/LunrSearchEngine.test.ts index 407fa779ab..acd18771c8 100644 --- a/plugins/search-backend-node/src/engines/LunrSearchEngine.test.ts +++ b/plugins/search-backend-node/src/engines/LunrSearchEngine.test.ts @@ -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, diff --git a/plugins/search-backend-node/src/engines/LunrSearchEngineIndexer.test.ts b/plugins/search-backend-node/src/engines/LunrSearchEngineIndexer.test.ts index ff76f0fa7c..46f0317d33 100644 --- a/plugins/search-backend-node/src/engines/LunrSearchEngineIndexer.test.ts +++ b/plugins/search-backend-node/src/engines/LunrSearchEngineIndexer.test.ts @@ -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); + }); }); diff --git a/plugins/search-backend-node/src/engines/LunrSearchEngineIndexer.ts b/plugins/search-backend-node/src/engines/LunrSearchEngineIndexer.ts index e723957077..ac7f7b1c0d 100644 --- a/plugins/search-backend-node/src/engines/LunrSearchEngineIndexer.ts +++ b/plugins/search-backend-node/src/engines/LunrSearchEngineIndexer.ts @@ -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'];