pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to do phrase search?
2+ messages / 2 participants
[nested] [flat]

* How to do phrase search?
@ 2020-07-10 18:22 Anto Aravinth <anto.aravinth.cse@gmail.com>
  2020-07-11 07:20 ` Re: How to do phrase search? Ivan E. Panchenko <i.panchenko@postgrespro.ru>
  0 siblings, 1 reply; 2+ messages in thread

From: Anto Aravinth @ 2020-07-10 18:22 UTC (permalink / raw)
  To: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>

Hello,

I have the following table:

so2, which has following column details:

​

id, title, posts, body (tsvector).

And I created the index on the following:

"so2_pkey" PRIMARY KEY, btree (id)

"body" gin (body)

​

And I wanted to query on my tsvector with the string: `Is it possible to
toggle the visibility of an element`. I tried the following query:

​

SELECT id, ts_rank(body, keywords) AS rank

FROM so2,

to_tsquery('Is & it & possible & to & toggle & the & visibility & of & an &
element')

keywords

WHERE keywords @@ body ORDER BY rank DESC;

​

This give the result in which the "element" string count is large in
number, however there is a record which exactly matches the search string,
that comes as third in my result. So logically it just checked in my query
which word count occurs the most across my body column, which I don't want.

​

Can I say somehow to postgresql, that I want the pharse search rather than
the text spilt up weight in the document. Is it possible to do?

Edit: I tried with `ts_rank_cd\` as well. Same result.

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: How to do phrase search?
  2020-07-10 18:22 How to do phrase search? Anto Aravinth <anto.aravinth.cse@gmail.com>
@ 2020-07-11 07:20 ` Ivan E. Panchenko <i.panchenko@postgrespro.ru>
  0 siblings, 0 replies; 2+ messages in thread

From: Ivan E. Panchenko @ 2020-07-11 07:20 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Hello,

On 10.07.2020 21:22, Anto Aravinth wrote:
> Hello,
>
> I have the following table:
>
> so2, which has following column details:
>
> ​
>
> |id, title, posts, body (tsvector). |
>
> And I created the index on the following:
>
> |"so2_pkey" PRIMARY KEY, btree (id)|
>
> |"body" gin (body)|
>
> ​
>
> And I wanted to query on my tsvector with the string: `Is it possible 
> to toggle the visibility of an element`. I tried the following query:
>
If you want phrase search, use the phraseto_tsquery function, like

    phraseto_tsquery( 'Is it possible to toggle the visibility of an 
element')

or

    phraseto_tsquery( 'my_ts_config', 'Is it possible to toggle the 
visibility of an element')

> ​
>
> |SELECT id, ts_rank(body, keywords) AS rank|
>
> |FROM so2,|
>
> |to_tsquery('Is & it & possible & to & toggle & the & visibility & of 
> & an & element')|
>
> |keywords|
>
> |WHERE keywords @@ body ORDER BY rank DESC;|
>
> ​
>
> This give the result in which the "element" string count is large in 
> number, however there is a record which exactly matches the search 
> string, that comes as third in my result. So logically it just checked 
> in my query which word count occurs the most across my body column, 
> which I don't want.
>
> ​
>
> Can I say somehow to postgresql, that I want the pharse search rather 
> than the text spilt up weight in the document. Is it possible to do?
>
> Edit: I tried with `|ts_rank_cd\|` as well. Same result.
>

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2020-07-11 07:20 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-07-10 18:22 How to do phrase search? Anto Aravinth <anto.aravinth.cse@gmail.com>
2020-07-11 07:20 ` Ivan E. Panchenko <i.panchenko@postgrespro.ru>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox