为什么postgresql只识别全文搜索中的数字?

时间:2016-12-16 19:23:37

标签: postgresql dictionary full-text-search

我在postgresql中学习全文搜索,我需要用FTS制作英文字典。我做了字典mydict_en。我用我的字典和其他案例用简单的字典计算单词。

CREATE TEXT SEARCH DICTIONARY mydict_en (
   TEMPLATE = ispell,
   DictFile = english,
   AffFile = english,
   StopWords = english
);


CREATE TEXT SEARCH CONFIGURATION public.mydict_en (PARSER = default);


ALTER TEXT SEARCH CONFIGURATION mydict_en ADD MAPPING 
   FOR email, url, url_path, host, file, version,
   sfloat, float, int, uint,
   numword, hword_numpart, numhword
WITH simple;


ALTER TEXT SEARCH CONFIGURATION mydict_en ADD MAPPING 
   FOR word, hword_part, hword
WITH mydict_en;

我的测试表(我添加FTS字段):

CREATE TABLE matches
(
  id Serial NOT NULL,
  opponents Varchar(1024) NOT NULL,
  metaKeywords Varchar(2048),
  metaDescription Varchar(1024),
  score Varchar(100) NOT NULL,
  primary key (id)
);


ALTER TABLE matches ADD COLUMN fts tsvector;

当我向此表插入数据时,例如:

INSERT INTO matches (opponents, metaKeywords, metaDescription, score)
VALUES ('heat - thunder', 'nba, ball', 'Heat plays at home.', '99 - 85');

我根据优先级更新我的fts字段:

UPDATE matches SET fts = 
 setweight( coalesce( to_tsvector('mydict_en', opponents),''),'A') ||
 setweight( coalesce( to_tsvector('mydict_en', metaKeywords),''),'B') ||
 setweight( coalesce( to_tsvector('mydict_en', metaDescription),''),'C') ||
 setweight( coalesce( to_tsvector('mydict_en', score),''),'D');

我的fts包含这条记录:

'85':2 '99':1

为什么它只包含数字,哪些是单词?

0 个答案:

没有答案