diff --git a/plugins/catalog-backend/src/catalog/DatabaseEntitiesCatalog.ts b/plugins/catalog-backend/src/catalog/DatabaseEntitiesCatalog.ts index f6aec0c268..750d728c67 100644 --- a/plugins/catalog-backend/src/catalog/DatabaseEntitiesCatalog.ts +++ b/plugins/catalog-backend/src/catalog/DatabaseEntitiesCatalog.ts @@ -90,7 +90,7 @@ export class DatabaseEntitiesCatalog implements EntitiesCatalog { const colocatedEntities = location ? await this.database.entities(tx, [ { - key: LOCATION_ANNOTATION, + key: `metadata.annotations.${LOCATION_ANNOTATION}`, values: [location], }, ]) diff --git a/plugins/catalog-backend/src/database/search.test.ts b/plugins/catalog-backend/src/database/search.test.ts index 6da87f9150..fad17da733 100644 --- a/plugins/catalog-backend/src/database/search.test.ts +++ b/plugins/catalog-backend/src/database/search.test.ts @@ -125,46 +125,7 @@ describe('search', () => { }, { entity_id: 'eid', key: 'apiversion', value: 'a' }, { entity_id: 'eid', key: 'kind', value: 'b' }, - { entity_id: 'eid', key: 'name', value: 'n' }, - { entity_id: 'eid', key: 'namespace', value: null }, - { entity_id: 'eid', key: 'uid', value: null }, - { entity_id: 'eid', key: 'namespace', value: ENTITY_DEFAULT_NAMESPACE }, ]); }); - - it('adds prefix-stripped versions', () => { - const input: Entity = { - apiVersion: 'a', - kind: 'b', - metadata: { - name: 'name', - labels: { - lbl: 'lbl', - }, - annotations: { - ann: 'ann', - }, - }, - spec: { - sub: { - spc: 'spc', - }, - }, - }; - expect(buildEntitySearch('eid', input)).toStrictEqual( - expect.arrayContaining([ - { entity_id: 'eid', key: 'metadata.name', value: 'name' }, - { entity_id: 'eid', key: 'name', value: 'name' }, - { entity_id: 'eid', key: 'metadata.labels.lbl', value: 'lbl' }, - { entity_id: 'eid', key: 'labels.lbl', value: 'lbl' }, - { entity_id: 'eid', key: 'lbl', value: 'lbl' }, - { entity_id: 'eid', key: 'metadata.annotations.ann', value: 'ann' }, - { entity_id: 'eid', key: 'annotations.ann', value: 'ann' }, - { entity_id: 'eid', key: 'ann', value: 'ann' }, - { entity_id: 'eid', key: 'spec.sub.spc', value: 'spc' }, - { entity_id: 'eid', key: 'sub.spc', value: 'spc' }, - ]), - ); - }); }); }); diff --git a/plugins/catalog-backend/src/database/search.ts b/plugins/catalog-backend/src/database/search.ts index cbcd01a5d0..bbed2fac47 100644 --- a/plugins/catalog-backend/src/database/search.ts +++ b/plugins/catalog-backend/src/database/search.ts @@ -17,15 +17,6 @@ import { Entity, ENTITY_DEFAULT_NAMESPACE } from '@backstage/catalog-model'; import type { DbEntitiesSearchRow } from './types'; -// Search entries that start with these prefixes, also get a shorthand without -// that prefix -const SHORTHAND_KEY_PREFIXES = [ - 'metadata.', - 'metadata.labels.', - 'metadata.annotations.', - 'spec.', -]; - // These are excluded in the generic loop, either because they do not make sense // to index, or because they are special-case always inserted whether they are // null or not @@ -159,14 +150,5 @@ export function buildEntitySearch( // Visit the entire structure recursively visitEntityPart(entityId, '', entity, result); - // Generate shorthands for fields directly under some common collections - for (const row of result.slice()) { - for (const stripPrefix of SHORTHAND_KEY_PREFIXES) { - if (row.key.startsWith(stripPrefix)) { - result.push({ ...row, key: row.key.substr(stripPrefix.length) }); - } - } - } - return result; }