Function quaint::ast::text_search_relevance
source · pub fn text_search_relevance<'a, E, Q>(exprs: &[E], query: Q) -> Function<'a>where
E: Into<Expression<'a>> + Clone,
Q: Into<Cow<'a, str>>,
Expand description
Computes the relevance score of a full-text search query against some expressions.
let relevance: Expression = text_search_relevance(&[Column::from("name"), Column::from("ingredients")], "chicken").into();
let query = Select::from_table("recipes").so_that(relevance.greater_than(0.1));
let (sql, params) = Postgres::build(query)?;
assert_eq!(
"SELECT \"recipes\".* FROM \"recipes\" WHERE \
ts_rank(to_tsvector(concat_ws(' ', \"name\",\"ingredients\")), to_tsquery($1)) > $2", sql
);
assert_eq!(params, vec![Value::from("chicken"), Value::from(0.1)]);