Use of tsvector in array

Started by Huang, Suyaalmost 12 years ago2 messagesgeneral
Jump to latest
#1Huang, Suya
Suya.Huang@au.experian.com

Hi,

We have the requirement of using the data type tsvector [], however, I didn't find out how to:

* Use array operator together with tsquery operator

o I have to unnest the array and then do query like "ts@@ to_tsquery('ipod')"

* Create GIN index on tsvector[]

o ERROR: data type tsvector[] has no default operator class for access method "gin"

Not sure if anyone ever has this experience could share?

Thanks,
Suya

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: Huang, Suya (#1)
Re: Use of tsvector in array

Huang, Suya wrote

Hi,

We have the requirement of using the data type tsvector [], however, I
didn't find out how to:

* Use array operator together with tsquery operator

o I have to unnest the array and then do query like "ts@@
to_tsquery('ipod')"

You will have to create some kind of custom operator. The easiest would be
to effectively duplicate the @@ operator but reverse the order of the
operands. Then you could do:

to_tsquery('ipod') @@^ ANY(tsvector_array)

Unfortunately the ANY must be applied to the right-hand type.

* Create GIN index on tsvector[]

o ERROR: data type tsvector[] has no default operator class for access
method "gin"

Not sure if anyone ever has this experience could share?

No clue but at a high level ISTM that tsvector[] is in many ways
functionally similar to "tsvector || tsvector" ... even if only for indexing
purposes

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Use-of-tsvector-in-array-tp5811210p5811215.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general