This is a document for PGroonga 1.X. See PGroonga 2.x document when you're using recent PGroonga.

&^ operator

Since 1.2.1.

Summary

&^> operator for text[] is deprecated since 1.2.1. Use &^ operator instead.

&^ operator performs prefix search.

Prefix search is useful for implementing input completion.

Syntax

column &^ prefix

column is a column to be searched. It's text type or text[] type.

prefix is a prefix to be found. It's text type.

The operator returns true when the column value starts with prefix.

Operator classes

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

Usage

Here are sample schema and data for examples:

CREATE TABLE tags (
  name text PRIMARY KEY
);

CREATE INDEX pgroonga_tag_name_index ON tags
  USING pgroonga (name pgroonga.text_term_search_ops_v2);
INSERT INTO tags VALUES ('PostgreSQL');
INSERT INTO tags VALUES ('Groonga');
INSERT INTO tags VALUES ('PGroonga');
INSERT INTO tags VALUES ('pglogical');

You can perform prefix search with prefix by &^ operator:

SELECT * FROM tags WHERE name &^ 'pg';
--    name    
-- -----------
--  PGroonga
--  pglogical
-- (2 rows)

See also