1

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.

5
  • 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, 2012 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. Dec 19, 2012 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, 2012 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.) Dec 19, 2012 at 8:32
  • @dezso +1 for your solution. I didn't think of it that way. Thank you very much.
    – VinhBS
    Dec 19, 2012 at 11:26

1 Answer 1

3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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