Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7999907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:38:17+00:00 2026-06-04T15:38:17+00:00

I’ve been enlisted to help on a project and I’m diving back into PostgreSQL

  • 0

I’ve been enlisted to help on a project and I’m diving back into PostgreSQL after not working with it for several years. Lack of use aside, I’ve never run into using tsvector fields before and now find myself facing a bug based on them. I read the documentation on the field type and it’s purpose, but I’m having a hard time digging up documentation on how ‘simple’ differs from ‘english’ as the first parameter to to_tsquery()

Example

> SELECT to_tsvector('mortgag') @@ to_tsquery('simple', 'mortgage')
?column? 
----------
 f
(1 row)

> SELECT to_tsvector('mortgag') @@ to_tsquery('english', 'mortgage')
?column? 
----------
 t
(1 row)

I would think they should both return true, but obviously the first does not – why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:38:19+00:00Added an answer on June 4, 2026 at 3:38 pm

    The FTS utilizes dictionaries to normalize the text:

    12.6. Dictionaries

    Dictionaries are used to eliminate words that should not be considered in a search (stop words), and to normalize words so that different derived forms of the same word will match. A successfully normalized word is called a lexeme.

    So dictionaries are used to throw out things that are too common or meaningless to consider in a search (stop words) and to normalize everything else so city and cities, for example, will match even though they’re different words.

    Let us look at some output from ts_debug and see what’s going on with the dictionaries:

    => select * from ts_debug('english', 'mortgage');
       alias   |   description   |  token   |  dictionaries  |  dictionary  |  lexemes  
    -----------+-----------------+----------+----------------+--------------+-----------
     asciiword | Word, all ASCII | mortgage | {english_stem} | english_stem | {mortgag}
    
    => select * from ts_debug('simple', 'mortgage');
       alias   |   description   |  token   | dictionaries | dictionary |  lexemes   
    -----------+-----------------+----------+--------------+------------+------------
     asciiword | Word, all ASCII | mortgage | {simple}     | simple     | {mortgage}
    

    Notice that simple uses the simple dictionary whereas english uses the english_stem dictionary.

    The simple dictionary:

    operates by converting the input token to lower case and checking it against a file of stop words. If it is found in the file then an empty array is returned, causing the token to be discarded. If not, the lower-cased form of the word is returned as the normalized lexeme.

    The simple dictionary just throws out stop words, downcases, and that’s about it. We can see its simplicity ourselves:

    => select to_tsquery('simple', 'Mortgage'), to_tsquery('simple', 'Mortgages');
     to_tsquery | to_tsquery  
    ------------+-------------
     'mortgage' | 'mortgages'
    

    The simple dictionary is too simple to even handle simple plurals.

    So what is this english_stem dictionary all about? The “stem” suffix is a give away: this dictionary applies a stemming algorithm to words to convert (for example) city and cities to the same thing. From the fine manual:

    12.6.6. Snowball Dictionary

    The Snowball dictionary template is based on a project by Martin Porter, inventor of the popular Porter’s stemming algorithm for the English language. […] Each algorithm understands how to reduce common variant forms of words to a base, or stem, spelling within its language.

    And just below that we see the english_stem dictionary:

    CREATE TEXT SEARCH DICTIONARY english_stem (
        TEMPLATE = snowball,
        Language = english,
        StopWords = english
    );
    

    So the english_stem dictionary stems words and we can see that happen:

    => select to_tsquery('english', 'Mortgage'), to_tsquery('english', 'Mortgages');
     to_tsquery | to_tsquery 
    ------------+------------
     'mortgag'  | 'mortgag'
    

    Executive Summary: 'simple' implies simple minded literal matching, 'english' applies stemming to (hopefully) produce better matching. The stemming turns mortgage into mortgag and that gives you your match.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am currently running into a problem where an element is coming back from
I have a jquery bug and I've been looking for hours now, I can't
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.