This is a document for PGroonga 2.X and 3.X. See PGroonga 1.x document when you're using old PGroonga.
%%
operator for varchar[]
This operator is deprecated since 1.2.1. Use &>
operator instead.
%%
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_term_search_ops_v2
: Default for varchar[]
pgroonga_varchar_array_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)
&>
operator: Check whether a term is included in an array of terms