Postgresql – Parse hyphenated word to unsigned integer

full-text-searchpostgresql

When tested to_tsvector on 'someword-123' with english full text config, I got the following result:

SELECT to_tsvector('someword-123');

to_tsvector
tsvector
--------------------
"'-123':2 'someword':1"

However, I want to config to get the result like "'123':2 'someword':1" so when user search with 'someword & 123', it could return result.

Is there anyway to do this? Hope someone could help.

Update: For more information, my full text search is applied mostly for product name. For example, I have a product which name is "Intel Core i7-3820 Processor" and I want the result of to_tsvector() for this string could be like "'intel':1, 'core':2, 'i3':3, '3820':4, 'processor': 5" (currently, it's "'intel':1, 'core':2, 'i3':3, '-3820':4, 'processor': 5") so this product can be returned when user search with 'intel 3820'

Thank for your all.

Best Answer

I think it would be better to work around your problem: simply replace hyphens with spaces in the strings to be ts_vectored. If necessary, you can store the unhyphenated values in a separate column and run your searches against it.