This is a document for PGroonga 1.X. See PGroonga 2.x document when you're using recent 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.

Operator classes

You need to specify one of the following operator classes to use this operator:


Here are sample schema and data for examples:

  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)

See also