Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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.

share|improve this question
    
perhaps a better description of what you're trying to accomplish and why your data is formatted in such a way will get more attention and perhaps some answers. as it stands, i can't really understand the purpose behind your data or the pattern. –  swasheck Dec 18 '12 at 23:09
    
I suspect you'll have to modify the tsearch2 parser, which isn't a fun job. You want tsearch2 to treat mixed number-and-letter hyphenated words the same as normal hyphenated words. –  Craig Ringer Dec 19 '12 at 1:57
    
@swasheck Like Craig said, I want postgre full-text parser treat number-and-letter hyphenated words the same as normal hyphenated words. E.g., I have a product which name is "Intel Core i7-3820 Processor" and i want this product could be returned when user search 'intel 3820', i.e. its tsvector could be something like "'intel':1, 'core':2, 'i3':3, '3820':4, 'processor': 5". Thank you. –  VinhBS Dec 19 '12 at 7:17
1  
This may be a breain-dead idea, but how about pre-processing product names so that spaces replace hyphens? (Say, you can put it in a separate column.) –  dezso Dec 19 '12 at 8:32
    
@dezso +1 for your solution. I didn't think of it that way. Thank you very much. –  VinhBS Dec 19 '12 at 11:26
add comment

1 Answer

up vote 3 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.