T
T
toly192021-09-20 20:38:27
PostgreSQL
toly19, 2021-09-20 20:38:27

How to do extra word search in postgresql?

Good afternoon!
The table has 2 entries:

id, some_name
1, привет мир
2, привет замечательный мир

How can I make a search on the string hello wonderful world to return both lines 1 and 2?
Now the request looks like this:
select * from my_data where to_tsvector(some_name) @@ to_tsquery('привет замечательный мир');

And accordingly I receive selection only 2 lines. What can be done to make the first row also included in the selection?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
rPman, 2021-09-20
@rPman

replace the word that is not important with the symbol % and the condition should be where field like 'xxx % yyy'

G
galaxy, 2021-09-20
@galaxy

Well, probably like this:

select * from my_data  where to_tsvector(some_name) @@ to_tsquery('привет | замечательный | мир');

tsquery supports the &, |, !, <->and bracket grouping.
https://www.postgresql.org/docs/current/datatype-t...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question