Escaping special characters in to_tsquery

后端 未结 3 849
栀梦
栀梦 2021-02-12 17:52

How do you espace special characters in string passed to to_tsquery? For instance, this kind of query:

select to_tsquery(\'AT&T\');
3条回答
  •  無奈伤痛
    2021-02-12 18:44

    A simple solution is to create the tsquery as follows:

    select $$'AT&T'$$::tsquery;
    

    You can make more complex queries:

    select $$'AT&T' & Phone | '|Bang!'$$::tsquery;
    

    See the text search docs for more.

提交回复
热议问题