fix searching for multiple labels in iOS

This commit is contained in:
Hongbo Wu 2023-12-06 21:09:30 +08:00
parent 7277b27a9f
commit d42f257f9e
2 changed files with 6 additions and 4 deletions

View file

@ -181,15 +181,14 @@ export const buildQuery = (
return null
}
const param = 'implicit_field'
const alias = 'rank'
const param = `implicit_field_${parameters.length}`
const alias = `rank_${parameters.length}`
selects.push({
column: `ts_rank_cd(library_item.search_tsv, websearch_to_tsquery('english', :${param}))`,
alias,
})
// always sort by rank first
orders.unshift({ by: alias, order: SortOrder.DESCENDING })
orders.push({ by: alias, order: SortOrder.DESCENDING })
return escapeQueryWithParameters(
`websearch_to_tsquery('english', :${param}) @@ library_item.search_tsv`,
@ -532,6 +531,7 @@ export const buildQuery = (
}
case 'use':
case 'mode':
case 'event':
// mode is ignored and used only by the frontend
return null
case 'readPosition':

View file

@ -7,6 +7,8 @@ export const parseSearchQuery = (query: string): LiqeQuery => {
.replace('in:library', 'no:subscription') // compatibility with old search
// wrap the value behind colon in quotes if it's not already
.replace(/(\w+):("([^"]+)"|([^")\s]+))/g, '$1:"$3$4"')
// remove any quotes that are in the array value for example: label:"test","test2" -> label:"test,test2"
.replace(/","/g, ',')
return parse(searchQuery)
}