Optimize search SQL query (I hope :p)
This commit is contained in:
parent
a3c1738eea
commit
dbfd3e9bfe
2 changed files with 17 additions and 29 deletions
|
@ -51,17 +51,6 @@ function createSimilarityAttribute (col: string, value: string) {
|
|||
)
|
||||
}
|
||||
|
||||
function createSearchTrigramQuery (col: string, value: string) {
|
||||
return {
|
||||
[ Sequelize.Op.or ]: [
|
||||
// FIXME: use word_similarity instead of just similarity?
|
||||
Sequelize.where(searchTrigramNormalizeCol(col), ' % ', searchTrigramNormalizeValue(value)),
|
||||
|
||||
Sequelize.where(searchTrigramNormalizeCol(col), ' LIKE ', searchTrigramNormalizeValue(`%${value}%`))
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
|
@ -69,8 +58,7 @@ export {
|
|||
getSortOnModel,
|
||||
createSimilarityAttribute,
|
||||
throwIfNotValid,
|
||||
buildTrigramSearchIndex,
|
||||
createSearchTrigramQuery
|
||||
buildTrigramSearchIndex
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue