fix label search

This commit is contained in:
Hongbo Wu
2023-09-06 11:07:41 +08:00
parent 0747c4603c
commit 86cff913fb
2 changed files with 8 additions and 8 deletions

View File

@ -154,7 +154,7 @@ const buildWhereClause = (
if (includeLabels && includeLabels.length > 0) {
includeLabels.forEach((includeLabel) => {
queryBuilder.andWhere(
'library_item.label_names @> ARRAY[:...includeLabels]::text[] OR library_item.highlight_labels @> ARRAY[:...includeLabels]::text[]',
'(lower(library_item.label_names::text)::text[] @> ARRAY[:...includeLabels]::text[] OR lower(library_item.highlight_labels::text)::text[] @> ARRAY[:...includeLabels]::text[])',
{
includeLabels: includeLabel.labels,
}
@ -164,7 +164,7 @@ const buildWhereClause = (
if (excludeLabels && excludeLabels.length > 0) {
queryBuilder.andWhere(
'NOT library_item.label_names && ARRAY[:...excludeLabels]::text[] AND NOT library_item.highlight_labels && ARRAY[:...excludeLabels]::text[]',
'(NOT lower(library_item.label_names::text)::text[] && ARRAY[:...excludeLabels]::text[] AND NOT lower(library_item.highlight_labels::text)::text[] && ARRAY[:...excludeLabels]::text[])',
{
excludeLabels,
}
@ -221,7 +221,7 @@ const buildWhereClause = (
if (args.noFilters) {
args.noFilters.forEach((filter) => {
queryBuilder.andWhere(`library_item.${filter.field} IS NULL`)
queryBuilder.andWhere(`library_item.${filter.field} = '{}'`)
})
}
}

View File

@ -303,11 +303,11 @@ const parseNoFilter = (str?: string): NoFilter | undefined => {
}
const strLower = str.toLowerCase()
const accepted = ['highlight', 'label']
if (accepted.includes(strLower)) {
return {
field: `${strLower}s`,
}
switch (strLower) {
case 'highlight':
return { field: 'highlight_annotations' }
case 'label':
return { field: 'label_names' }
}
return undefined