tokenized_ilike
This function searches for exact matches of 'keyword' in 'string'.
The input 'string' is tokenized by a space, and each token is comapred to the 'keyword'. True is returned if the token fully matches the keyword. If the 'keyword' did not match any of the tokens of 'string' false is returned.
This function is case insensitive.
There is an alternative second version that has an integer as first argument.
Searching for keywords.
-- This function is exactly like tokenized_like, but it is case insensitive CREATE FUNCTION tokenized_ilike(VARCHAR, VARCHAR) RETURNS bool AS ' declare string alias for $1; keyword alias for $2; begin return tokenized_like(lower(string), lower(keyword)); end; ' LANGUAGE 'plpgsql';
-- we define operators for each of our functions so that we can easily integrate -- them into the current PO search queries CREATE operator =##= ( leftarg = VARCHAR, rightarg = VARCHAR, PROCEDURE = tokenized_ilike, commutator = =##= );
-- This function is exactly like tokenized_ilike, but its first argument is integer CREATE FUNCTION tokenized_ilike(INTEGER, VARCHAR) RETURNS bool AS ' declare identifier alias for $1; keyword alias for $2; begin return tokenized_ilike(text(identifier), keyword); end; ' LANGUAGE 'plpgsql';
-- we define operators for each of our functions so that we can easily integrate -- them into the current PO search queries CREATE operator =##= ( leftarg = INTEGER, rightarg = VARCHAR, PROCEDURE = tokenized_ilike, commutator = =##= );
Version 2.30
Still in use
= Version 2.30 =
-- This function is exactly like tokenized_like, but it is case insesnitive CREATE FUNCTION tokenized_ilike(VARCHAR, VARCHAR) RETURNS bool AS ' declare string alias for $1; keyword alias for $2; begin return tokenized_like(lower(string), lower(keyword)); end; ' LANGUAGE 'plpgsql';
-- we define operators for each of our functions so that we can easily integrate -- them into the curret PO search queries CREATE operator =##= ( leftarg = VARCHAR, rightarg = VARCHAR, PROCEDURE = tokenized_ilike, commutator = =##= );
-- This function is exactly like tokenized_ilike, but its first argument is integer CREATE FUNCTION tokenized_ilike(INTEGER, VARCHAR) RETURNS bool AS ' declare identifier alias for $1; keyword alias for $2; begin return tokenized_ilike(text(identifier), keyword); end; ' LANGUAGE 'plpgsql';
-- we define operators for each of our functions so that we can easily integrate -- them into the curret PO search queries CREATE operator =##= ( leftarg = INTEGER, rightarg = VARCHAR, PROCEDURE = tokenized_ilike, commutator = =##= );