Implement search for rich text fields and use it for notes (#7953)
Co-authored-by: Weiko <corentin@twenty.com>
This commit is contained in:
@ -282,6 +282,7 @@ export const NOTE_STANDARD_FIELD_IDS = {
|
||||
attachments: '20202020-4986-4c92-bf19-39934b149b16',
|
||||
timelineActivities: '20202020-7030-42f8-929c-1a57b25d6bce',
|
||||
favorites: '20202020-4d1d-41ac-b13b-621631298d67',
|
||||
searchVector: '20202020-7ea8-44d4-9d4c-51dd2a757950',
|
||||
};
|
||||
|
||||
export const NOTE_TARGET_STANDARD_FIELD_IDS = {
|
||||
|
||||
@ -75,8 +75,9 @@ const getColumnExpression = (
|
||||
): string => {
|
||||
const quotedColumnName = `"${columnName}"`;
|
||||
|
||||
if (fieldType === FieldMetadataType.EMAILS) {
|
||||
return `
|
||||
switch (fieldType) {
|
||||
case FieldMetadataType.EMAILS:
|
||||
return `
|
||||
COALESCE(
|
||||
replace(
|
||||
${quotedColumnName},
|
||||
@ -86,7 +87,9 @@ const getColumnExpression = (
|
||||
''
|
||||
)
|
||||
`;
|
||||
} else {
|
||||
return `COALESCE(${quotedColumnName}, '')`;
|
||||
case FieldMetadataType.RICH_TEXT:
|
||||
return `COALESCE(jsonb_path_query_array(${quotedColumnName}::jsonb, '$[*].content[*]."text"'::jsonpath)::text, '')`;
|
||||
default:
|
||||
return `COALESCE(${quotedColumnName}, '')`;
|
||||
}
|
||||
};
|
||||
|
||||
@ -6,6 +6,7 @@ const SEARCHABLE_FIELD_TYPES = [
|
||||
FieldMetadataType.EMAILS,
|
||||
FieldMetadataType.ADDRESS,
|
||||
FieldMetadataType.LINKS,
|
||||
FieldMetadataType.RICH_TEXT,
|
||||
] as const;
|
||||
|
||||
export type SearchableFieldType = (typeof SEARCHABLE_FIELD_TYPES)[number];
|
||||
|
||||
Reference in New Issue
Block a user