在 postgresql 中删除停用词而不阻止

remove stop words without stemming in postgresql

我想从我的数据中删除停用词,但我不想阻止这些词,因为确切的词对我很重要。 我使用了这个查询。

SELECT to_tsvector('english',colName)from tblName order by lower asc;

有什么方法可以在不阻止单词的情况下删除停用词吗?

谢谢

创建您自己的文本搜索字典和配置:

CREATE TEXT SEARCH DICTIONARY simple_english
   (TEMPLATE = pg_catalog.simple, STOPWORDS = english);

CREATE TEXT SEARCH CONFIGURATION simple_english
   (copy = english);
ALTER TEXT SEARCH CONFIGURATION simple_english
   ALTER MAPPING FOR asciihword, asciiword, hword, hword_asciipart, hword_part, word
   WITH simple_english;

它是这样工作的:

SELECT to_tsvector('simple_english', 'many an ox eats the houses');
┌─────────────────────────────────────┐
│             to_tsvector             │
├─────────────────────────────────────┤
│ 'eats':4 'houses':5 'many':1 'ox':3 │
└─────────────────────────────────────┘
(1 row)

您可以将参数 default_text_search_config 设置为 simple_english,使其成为您的默认文本搜索配置。