Delete stop words without adding to postgresql

I want to remove stop words from my data, but I do not want to stop words, because exact words are important to me. I used this query.

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

Is it possible to remove stopWords without words in any way?

thank

+4
source share
1 answer

Create your dictionary for text search and configuration:

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;

It works as follows:

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

You can set the parameter default_text_search_configto simple_englishto make it the default text search configuration.

+8
source

Source: https://habr.com/ru/post/1668862/


All Articles