index a null for large values as well
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend': minor
|
||||
---
|
||||
|
||||
The search index now does retain fields that have a very long value, but in the form of just a null. This makes it possible to at least filter for their existence.
|
||||
@@ -109,10 +109,10 @@ describe('buildEntitySearch', () => {
|
||||
expect(output).toEqual([]);
|
||||
});
|
||||
|
||||
it('skips very large values', () => {
|
||||
it('replaces very large values with null', () => {
|
||||
const input = [{ key: 'foo', value: 'a'.repeat(10000) }];
|
||||
const output = mapToRows(input, 'eid');
|
||||
expect(output).toEqual([]);
|
||||
expect(output).toEqual([{ entity_id: 'eid', key: 'foo', value: null }]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -137,8 +137,12 @@ export function mapToRows(input: Kv[], entityId: string): DbSearchRow[] {
|
||||
result.push({ entity_id: entityId, key, value: null });
|
||||
} else {
|
||||
const value = String(rawValue).toLocaleLowerCase('en-US');
|
||||
if (key.length <= MAX_KEY_LENGTH && value.length <= MAX_VALUE_LENGTH) {
|
||||
result.push({ entity_id: entityId, key, value });
|
||||
if (key.length <= MAX_KEY_LENGTH) {
|
||||
result.push({
|
||||
entity_id: entityId,
|
||||
key,
|
||||
value: value.length <= MAX_VALUE_LENGTH ? value : null,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user