This is a document for PGroonga 1.X. See PGroonga 2.x document when you're using recent PGroonga.
&>
operatorSince 1.2.1.
&>
operator checks whether a term is included in an array of terms.
column &> term
column
is a column to be searched. It's varchar[]
type.
term
is a term to be found. It's varchar
type.
You need to specify one of the following operator classes to use this operator:
pgroonga.varchar_array_ops
: Default for varchar[]
pgroonga.varchar_array_term_search_ops
: For varchar[]
Here are sample schema and data for examples:
CREATE TABLE memos (
id integer,
tags varchar(255)[]
);
CREATE INDEX pgroonga_tags_index ON memos USING pgroonga (tags);
INSERT INTO memos VALUES (1, ARRAY['PostgreSQ']);
INSERT INTO memos VALUES (2, ARRAY['Groonga']);
INSERT INTO memos VALUES (3, ARRAY['PGroonga', 'PostgreSQL', 'Groonga']);
INSERT INTO memos VALUES (4, ARRAY['Groonga']);
You can find records that contain 'Groonga'
term in an array of terms by &>
operator:
SELECT * FROM memos WHERE tags &> 'Groonga';
-- id | tags
-- ----+-------------------------------
-- 2 | {Groonga}
-- 3 | {PGroonga,PostgreSQL,Groonga}
-- 4 | {Groonga}
-- (3 rows)