1

What is the difference between the search in search and replace, (the replace function) and full text search (tsvector) in Postgres? Or, put another way, can tsvector be used in search and replace (and would there be any advantage in doing so)?

UPDATE

There must be something about trying to formulate a question that helps clarify it in your own mind. Yes, there is ts_rewrite. The docs say: "In essence this operation is a tsquery-specific version of substring replacement".

2nd Update

Ok, now I do have a question. In the docs examples, the replacement comes after the original string, even if the part being replaced was at the front of the original string:

ts_rewrite('a & b'::tsquery, 'a'::tsquery, 'foo|bar'::tsquery)
'b' & ( 'foo' | 'bar' )

So instead of foo | bar taking a's position, it follows b's position, which almost always changes the meaning of the text and might make it nonsense. Are there options to control this?

0

Your Answer

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