Whole word Search in Postgresql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mangal
    New Member
    • Dec 2006
    • 9

    Whole word Search in Postgresql

    Hi all .... Im working on search function for an app and have built a pretty decent thing go except one thing.

    Im using the ~* to match the incoming keywords against several fields, 4 varchar and one text ...... its working BUT Im getting partial words which isnt exactly what I wanted (neat but not right) lets me explain more.

    If im searching on the word cat and using this syntax: ~* 'cat' I get back any whole word "cat" PLUS things like "concat" ...... now how do I tell the db that I ONLY want the whole word cat NOT the letters "cat" within another word.

    If it was simple text fields it would be easier (I think) but the customer wants to be able to search within all sorts of fields for a given term.

    BTW, Im using Postgres 9.x

    ANY AND ALL HELP would be very much appreciated!
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    It would help to see the code but if you're looking for an exact match, you should use the = operator. Not the regular expression operator.

    Comment

    Working...