PostgreSQL full text search issue (to_tsquery) -


i'm having issues searching database game name contains stop word. i'm looking exact matches in general, want few "fuzzy" hits possible searching, optimally zero.

e.g. content produced false positives directly, contains sentences like; "the war in afghanistan" + reference "win*" place; or "lifeseed win war"; or "win war taking on galaxy" , on.

this of course not work , gave error:

select id, title, content my_table  tsvector_combined@@ to_tsquery('win war'); 

i had hoped "phraseto_tsquery" woudl work solved of other searches (postgresql 9.6), due stop word in 1 did not:

select id, title, content my_table  tsvector_combined@@ phraseto_tsquery('win war'); 

i tried using tie fighter thing, <1> | <-> gets false positives:

select id, title, content my_table  tsvector_combined@@ to_tsquery('win <-> <-> war'); 

is there hack can here the desired result of having matches returned phrase match? thinking maybe remove stop word, no idea how , not sure how solution in light of maybe searching "world of warcraft" , similar titles has stop words (and in general want exact matches).

thoughts?

to remove or stopwords, create reduced or empty stopword file in share/tsearch_data subdirectory of postgresql software directory. can create new snowball text search dictionary with

create text search dictionary newdict (    template = pg_catalog.snowball,    language = '...',    stopwords = '...' ); 

using new stopword file , create new text search configuration based on that. of course make index larger.

from examples quote, i'd rather choose different approach , use full text search able use index reduce candidates , further filter them second condition this:

select id, title, content my_table  tsvector_combined @@ to_tsquery('win war')   , (title '%win war%' or content '%win war%'); 

Comments