postgres文档here将numhword
解析器解释为匹配连字符,字母和数字的解析器。他们为此提供的示例是postgres-beta1
,这很好地匹配。但是,postgres-9-beta1
之类的某些东西不匹配,我似乎找不到可以使用它的默认解析器。 SQL下面。
我最好选择只在空格上解析的东西吗?有没有这样的默认解析器? (似乎test_parser
不再附带9.5 ......)
我想将字母数字标记为连字符。我暂时坚持使用正则表达式,还是有一种直接的方法来创建客户解析器(不会降低到C)?
CREATE TEXT SEARCH DICTIONARY simple_nostem_no_stop (TEMPLATE = pg_catalog.simple);
CREATE TEXT SEARCH CONFIGURATION test_id_search ( COPY = pg_catalog.simple );
alter text search configuration test_id_search
drop mapping for asciihword, asciiword, email, file, float, host, hword, hword_asciipart, hword_numpart, hword_part, int, numhword, numword, sfloat, uint, url, url_path, version, word ;
ALTER TEXT SEARCH CONFIGURATION test_id_search
ALTER MAPPING FOR numhword WITH simple_nostem_no_stop;
\dF+ test_id_search
Text search configuration "public.test_id_search"
Parser: "pg_catalog.default"
Token | Dictionaries
---------+-----------------------
numhword | simple_nostem_no_stop
/* This works as i hoped, per the docs: */
test_db=# select to_tsvector('test_id_search', ' postgresql-beta1 ') ;
to_tsvector
----------------------
'postgresql-beta1':1
(1 row)
/* This doesn't seem to work? */
test_db=# select to_tsvector('test_id_search', ' postgresql-9-beta1 ') ;
to_tsvector
-------------
(1 row)