Skip to content

postgrelize / setWeight

Function: setWeight() ​

setWeight(vector, weight): Fn

Defined in: src/expressions/search-helpers.ts:212

postgrelize extension

setweight(vector, weight): labels every lexeme of a tsvector A, B, C or D. PostgreSQL extension.

Parameters ​

vector ​

unknown

tsvector expression, e.g. toTsVector.

weight ​

"A" | "B" | "C" | "D"

Label 'A', 'B', 'C' or 'D'.

Returns ​

Fn

Function call expression.

Throws ​

Error when weight is not one of the four labels.

Example ​

ts
await Post.findAll({ attributes: [[setWeight(toTsVector(col('title'), 'english'), 'A'), 'titleVector']] });

Released under the MIT License.