User Tools

Site Tools


podoc:tokenized_ilike_sql_function

Database Function Description of "tokenized_ilike"

Name

tokenized_ilike

Description

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.

Purpose

Searching for keywords.

Schema

-- 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 = =##=
);

History

Used first

Version 2.30

Used last

Still in use

Change history

= 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 = =##=
);
podoc/tokenized_ilike_sql_function.txt · Last modified: 2007/04/23 10:32 by Luud