0

I want to add search functionality to an expressjs node application using Postgres as my database. I know how to do the filtering I'll need by date and some other column of finite values, but I don't know how to do a text search on a specific column. Given a string "chair", should my search algorithm return results with text like "my armchair", or "my chair"?

Maybe this question is so simple I'm just overlooking something. Thanks!

1

1 Answer 1

1

Try this:

SELECT * FROM <table> WHERE <colume> ~* '\ychair\y'

Where \y denotes the beginning/end of words

Sign up to request clarification or add additional context in comments.

3 Comments

I didn't get that to work, but SELECT * FROM <table> WHERE <column> ~* 'chair' worked for me, including rows containing something like "chairleg". I don't understand the purpose of [[:<:]] and [[:>:]]
Edited. @Shakeel Could you try \y?
Yeah that didn't work either. But I think it works fine as I noted in my previous comment. Thanks though!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.