View Single Post

   
  #1 (permalink)  
Old 04-12-2008, 06:37 AM
Teodor Sigaev
 
Posts: n/a
Default Proposal: syntax of operation with tsearch's configuration


Hi!

Now we (Oleg and me) are working on moving tsearch into core.

Pls, review suggested syntax. Comments, suggestions, objections will be appreciated.

1) parser operation (pg_ts_parser table)
CREATE PARSER prsname (
START = funcname,
GETTOKEN = funcname,
END = funcname,
LEXTYPES = funcname
[ , HEADLINE = funcname ]
);

DROP PARSER [IF EXISTS] prsname [ CASCADE | RESTRICT ];
ALTER PARSER prsname RENAME TO newprsname;
COMMENT ON PARSER IS text;

2) dictionaries (pg_ts_dict)

CREATE DICTIONARY dictname (
INIT = funcname,
LEXIZE = funcname,
OPT = text,
);

--create new dictionary as already existed but with different
-- options for example
CREATE DICTIONARY dictname [(
[ INIT = funcname ]
[ , LEXIZE = funcname ]
[ , OPT = text ]
)] LIKE template_dictname;

DROP DICTINARY [IF EXISTS] dictname [ CASCADE | RESTRICT ];
ALTER DICTIONARY dictname RENAME TO newdictname;
ALTER DICTIONARY dictname SET OPT=text;
COMMENT ON DICTIONARY IS text;

3) configuration (pg_ts_cfg [,pg_ts_cfgmap])
CREATE TSEARCH CONFIGURATION cfgname (
PARSER = prsname
[, LOCALE = localename]
);

--create new configuration and optionally copies
--map of lexeme's type to dictionaries
CREATE TSEARCH CONFIGURATION cfgname [(
LOCALE = localename
)] LIKE template_cfg [WITH MAP];

DROP TSEARCH CONFIGURATION [IF EXISTS] cfgname [ CASCADE | RESTRICT ];
ALTER TSEARCH CONFIGURATION cfgname RENAME TO newcfgname;
ALTER TSEARCH CONFIGURATION cfgname SET LOCALE=localename;
ALTER TSEARCH CONFIGURATION cfgname SET PARSER=prsname;
COMMENT ON TSEARCH CONFIGURATION IS text;

4) operate mapping lexemes to list of dictionary
CREATE TSEARCH MAPPING ON cfgname FOR lexemetypename USE dictname1[, dictname2
[..] ];
DROP TSEARCH MAPPING [IF EXISTS] ON cfgname FOR lexemetypename;
ALTER TSEARCH MAPPING ON cfgname FOR lexemetypename USE dictname1[, dictname2
[..] ];


Next, tsearch's configuration will be readable by psql backslashed command (F
means fulltext):
\dF - list of configurations
\dF PATTERN - describe configuration with used parser and lexeme's mapping
\dFd - list of dictionaries
\dFd PATTERN - describe dictionary
\dFp - parser's list
\dFp PATETRN - describe parser



--
Teodor Sigaev E-mail: teodor@sigaev.ru
WWW: http://www.sigaev.ru/


--
Teodor Sigaev E-mail: teodor@sigaev.ru
WWW: http://www.sigaev.ru/

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply With Quote