Answer the question
In order to leave comments, you need to log in
Search by means of sql?
It is necessary to organize a search for some information in the database.
Now used ilike
for such things. But it just looks for occurrences in the string and returns only those that have it.
I recently learned about full-text search . Looks cool, discards endings, searches for sentences, you can get rank
.
But I ran into the problem that here it is necessary to know the exact beginning of the word, otherwise the search stops working.
In general, there is a strange thing:
-- TRUE
select to_tsvector('russian', 'съешь ещё этих мягких французских булок, да выпей чаю') @@ plainto_tsquery('russian', 'чай')
-- FALSE
select to_tsvector('russian', 'съешь ещё этих мягких французских булок, да выпей чаю') @@ plainto_tsquery('russian', 'булка')
-- FALSE
select to_tsvector('russian', 'съешь ещё этих мягких французских булок, да выпей чаю') @@ plainto_tsquery('russian', 'франц')
Answer the question
In order to leave comments, you need to log in
plainto_tsquery('russian', 'french*')
in general, study the docks, opportunities will open
Use trigrams, they can be used to make an inaccurate search. Here is an article on habré
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question