1
votes

I want to execute a full text search(FTS) on a table. The problem is that the tsvector removes the underscore in words(like: person_id becomes person and id). Where can i configure that it will kee the underscore?

Ty in advance guys

1

1 Answers

0
votes

I'm afraid you're going to have to write your own parser (or tweak the existing one, in any case). If you take a look at ts_debug's output then you'll see that it treats the underscore as a space.

=> SELECT ts_debug('person_id');
                                 ts_debug                                  
---------------------------------------------------------------------------
 (asciiword,"Word, all ASCII",person,{english_stem},english_stem,{person})
 (blank,"Space symbols",_,{},,)
 (asciiword,"Word, all ASCII",id,{english_stem},english_stem,{id})
(3 rows)

This is happening before it gets fed into the dictionary for language-specific treatment.

So - you'll need to break out your text editor, find the parser in the source code and convince it that the underscore should be treated like e.g. a hyphen or some such). Shouldn't be too bad if you've done any C before.