Created
March 19, 2016 11:15
-
-
Save LinZap/b5ee6f1ddd91ba8cae92 to your computer and use it in GitHub Desktop.
PTT search_engine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION search_engine(_words varchar) | |
RETURNS table (oid int) AS | |
$BODY$ | |
declare _words_len int;_arrwords varchar[]; | |
begin | |
select regexp_split_to_array(_words,'[ ,-.~\+]+') into _arrwords; | |
select array_length(_arrwords,1) into _words_len; | |
return query | |
select d.oid from token t,dupindex d,vd_ptt_post p | |
where t.words in (select unnest(_arrwords)) | |
and d.tid=t.tid and p.oid=d.oid | |
group by d.oid having count(*)=_words_len; | |
end; | |
$BODY$ | |
LANGUAGE plpgsql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment