From 0f55f5ca8eab643dc1ec246b5e620f75532af03c Mon Sep 17 00:00:00 2001 From: Brian Phillips <28457+brianphillips@users.noreply.github.com> Date: Wed, 12 Jun 2024 22:56:55 -0500 Subject: [PATCH] Index name + title for entity in default catalog collator It's confusing to no longer be able to search for an entity based on name when the entity has a title specified. This changes the behavior so that it's searchable on both. Signed-off-by: Brian Phillips <28457+brianphillips@users.noreply.github.com> --- .changeset/violet-ducks-care.md | 5 +++++ .../src/search/DefaultCatalogCollator.test.ts | 2 +- plugins/catalog-backend/src/search/DefaultCatalogCollator.ts | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/violet-ducks-care.md diff --git a/.changeset/violet-ducks-care.md b/.changeset/violet-ducks-care.md new file mode 100644 index 0000000000..6ba59fd2b5 --- /dev/null +++ b/.changeset/violet-ducks-care.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +Ensure name and title are both indexed by the DefaultCatalogCollator diff --git a/plugins/catalog-backend/src/search/DefaultCatalogCollator.test.ts b/plugins/catalog-backend/src/search/DefaultCatalogCollator.test.ts index 8c8e3f1a25..4c1673b785 100644 --- a/plugins/catalog-backend/src/search/DefaultCatalogCollator.test.ts +++ b/plugins/catalog-backend/src/search/DefaultCatalogCollator.test.ts @@ -117,7 +117,7 @@ describe('DefaultCatalogCollator', () => { }, }); expect(documents[1]).toMatchObject({ - title: expectedEntities[1].metadata.title, + title: `${expectedEntities[1].metadata.title} (${expectedEntities[1].metadata.name})`, location: '/catalog/default/component/test-entity-2', text: expectedEntities[1].metadata.description, namespace: 'default', diff --git a/plugins/catalog-backend/src/search/DefaultCatalogCollator.ts b/plugins/catalog-backend/src/search/DefaultCatalogCollator.ts index 42c6930422..74aab07fc3 100644 --- a/plugins/catalog-backend/src/search/DefaultCatalogCollator.ts +++ b/plugins/catalog-backend/src/search/DefaultCatalogCollator.ts @@ -115,7 +115,9 @@ export class DefaultCatalogCollator { ); return response.items.map((entity: Entity): CatalogEntityDocument => { return { - title: entity.metadata.title ?? entity.metadata.name, + title: entity.metadata.title + ? `${entity.metadata.title} (${entity.metadata.name})` + : entity.metadata.name, location: this.applyArgsToFormat(this.locationTemplate, { namespace: entity.metadata.namespace || 'default', kind: entity.kind,