Function quaint::ast::text_search

source ·
pub fn text_search<'a, T>(exprs: &[T]) -> Function<'a>where
    T: Into<Expression<'a>> + Clone,
Expand description

Performs a full-text search. Use it in combination with the .matches() comparable.

let search: Expression = text_search(&[Column::from("name"), Column::from("ingredients")]).into();
let query = Select::from_table("recipes").so_that(search.matches("chicken"));
let (sql, params) = Postgres::build(query)?;

assert_eq!(
   "SELECT \"recipes\".* FROM \"recipes\" \
    WHERE to_tsvector(concat_ws(' ', \"name\",\"ingredients\")) @@ to_tsquery($1)", sql
);

assert_eq!(params, vec![Value::from("chicken")]);