Answer the question
In order to leave comments, you need to log in
How to find partial matches of query string in DB for PostgreSQL full text search?
Task: when searching for the type "alpha beta gamma ... omega", get results with a partial match (i.e. only one word was found, or several words from the query) and rank all this, taking into account the number of words found and their proximity. More matches - higher rank. Words closer to each other - higher rank.
Answer the question
In order to leave comments, you need to log in
Those. make your own preparser, which will then send a request to a normal parser that will truncate word forms.
Then it needs to be ranked. We have OR, and I don't really understand how the weights will be distributed
select json_flat_content , ts_rank_cd(json_flat_tsv, 'jzvmw | julva | qxqvh | name | value') r
from my_fulltext_index i
where
i.json_flat_tsv @@ to_tsquery('simple', 'jzvmw | julva | qxqvh | name | value')
order by r desc
[{"name": "qtmlx", "value": "jzvmw vajwq julva ipsmwtbhki lhgzr"}, {"name": "fslto", "value": "viykw"}] 0.6
[{"name": "lhnhq", "value": "sxgxh!!daxrh guxux!!kfgtirmgig!!ivqwz"}, {"name": "qxqvh", "value": "qbeli"}] 0.5
[{"name": "cepja", "value": "mrfma"}, {"name": "gwjqa", "value": "csxaf"}] 0.4
[{"name": "val", "value": "TNhmT<KxERm"}] 0.2
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question