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 696741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:05:41+00:00 2026-05-14T03:05:41+00:00

Following a question posted here about how I can increase the speed on one

  • 0

Following a question posted here about how I can increase the speed on one of my SQL Search methods, I was advised to update my table to make use of Full Text Search. This is what I have now done, using Gist indexes to make searching faster. On some of the “plain” queries I have noticed a marked increase which I am very happy about.

However, I am having difficulty in searching for partial words. For example I have several records that contain the word Squire (454) and I have several records that contain Squirrel (173). Now if I search for Squire it only returns the 454 records but I also want it to return the Squirrel records as well.

My query looks like this

SELECT title 
FROM movies 
WHERE vectors @@ to_tsoquery('squire');

I thought I could do to_tsquery('squire%') but that does not work.
How do I get it to search for partial matches ?

Also, in my database I have records that are movies and others that are just TV Shows. These are differentiated by the “” over the name, so like “Munsters” is a TV Show, whereas The Munsters is the film of the show. What I want to be able to do is search for just the TV Show AND just the movies. Any idea on how I can achieve this ?

Regards
Anthoni

  • 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-05-14T03:05:42+00:00Added an answer on May 14, 2026 at 3:05 am

    Even using LIKE you will not be able to get ‘squirrel’ from squire% because ‘squirrel’ has two ‘r’s. To get Squire and Squirrel you could run the following query:

    SELECT title FROM movies WHERE vectors @@ to_tsquery('squire|squirrel');
    

    To differentiate between movies and tv shows you should add a column to your database. However, there are many ways to skin this cat. You could use a sub-query to force postgres to first find the movies matching ‘squire’ and ‘squirrel’ and then search that subset to find titles that begin with a ‘”‘. It is possible to create indexes for use in LIKE '"%...' searches.

    Without exploring other indexing possibilities you could also run these – mess around with them to find which is fastest:

    SELECT title 
    FROM (
       SELECT * 
       FROM movies 
       WHERE vectors @@ to_tsquery('squire|squirrel')
    ) t
    WHERE title ILIKE '"%';
    

    or

    SELECT title 
    FROM movies 
    WHERE vectors @@ to_tsquery('squire|squirrel') 
      AND title ILIKE '"%';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following on from a question I posted yesterday about GUIs, I have another problem
I have the following question about JPA: Can I save the order of the
In one form or another I encounter the following question often (posed, here, in
This is a follow-up question to the one I posted here (thanks to mario
The following question was asked in one of my interview (few years back) What
I thought about the following question about computer's architecture. Suppose I do in Python
I've got the following question. I've got one class Instellingen that's a field in
Based on the following question: Check if one string is a rotation of other
My question is very similar to the question posted here on stackoverflow but the
(Question also posted here: http://www.google.com/support/forum/p/Android+Market/thread?tid=68dc1f694537c7dc&hl=en ) http://developer.android.com/guide/publishing/publishing.html recommends searching for apps by Developer Name

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.