postgresql - postgres synonym and prefix results together -
i have synonyms: lake lac loch when fts in postgres 'lake', want words contain 'lake', 'lac' , 'loch' (which have using synonyms either .syn file or .rules file). however, want words start 'lake', 'lakefield'. if use synonyms don't prefix matches, when don't use synonyms prefix matches ... how can both? there way of turning off synonyms make 1 quesry synonyms , 1 ignoring them? tried 'like' , 'position' way slow.
.rules have: lake lac loch loch lake lac lac lake loch
.syn have: lake yyyyy lac yyyyy loch yyyyy
i tried both, same problem. if map synonyms 1 of them in .syn file: lake lake lac lake loch lake
... 'lakefield' not 'lacombe' (and need them work prefix).
i'm using postgresql 9.3.
the query is:
select *, ts_rank_cd(to_tsvector('location', name), to_tsquery('location', 'lac:*'),16) ftsrank profile_name iso_code='en-ca' , to_tsvector('location', name) @@ to_tsquery('location', 'lac:*') , ts_rank_cd(to_tsvector('location', name), to_tsquery('location', 'lac:*'),16) >= 0 order ftsrank desc
the profile
table has name
field want search against.
thanks, zorica
could not use query rewrite feature?
select ts_rewrite('lake'::tsquery, 'lake'::tsquery, 'lake:* | lac | loch'::tsquery) @@ 'lake'::tsvector, --true ts_rewrite('lake'::tsquery, 'lake'::tsquery, 'lake:* | lac | loch'::tsquery) @@ 'loch'::tsvector, --true ts_rewrite('lake'::tsquery, 'lake'::tsquery, 'lake:* | lac | loch'::tsquery) @@ 'lakefield'::tsvector --true
you can keep query re-writes in database tables too.
Comments
Post a Comment