Skip to content

Commit

Permalink
Add documents for operators of v2 operator classes
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Apr 18, 2016
1 parent 74b553c commit 8f36767
Show file tree
Hide file tree
Showing 10 changed files with 583 additions and 1 deletion.
30 changes: 30 additions & 0 deletions reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,36 @@ PGroonga defines functions, operators, operator classes and so on into `pgroonga

* [`@~` operator](operators/regular-expression.html)

### v2 operators

PGroonga 1.Y.Z provides `pgroonga.XXX_v2` operator classes. They don't provide backward compatibility until PGroonga 2.0.0. But they include many improvements aggressively when new versions are released.

If you use them, you need to use [incompatible case steps](../upgrade/#incompatible-case) to upgrade PGroonga.

* `pgroonga.text_full_text_search_ops_v2` operator class

* `LIKE` operator

* `ILIKE` operator

* [`&@` operator](operators/match-v2.html)

* [`&?` operator](operators/query-v2.html) for non `jsonb` types

* [`&~?` operator](operators/similar-search-v2.html)

* [`` &` `` operator](operators/script-v2.html)

* [`&@>` operator](operators/match-contain-v2.html)

* [`&?>` operator](operators/query-contain-v2.html) for non `jsonb` types

* `pgroonga.text_term_search_ops_v2` operator class

* [`&^` operator](operators/prefix-search-v2.html)

* [`&^~` operator](operators/prefix-rk-search-v2.html)

## Functions

* [`pgroonga.score` function](functions/pgroonga-score.html)
Expand Down
64 changes: 64 additions & 0 deletions reference/operators/match-contain-v2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
title: "&@> operator"
layout: en
---

# `&@>` operator

## Summary

This operator uses v2 operator class. It doesn't provide backward compatibility until PGroonga 2.0.0. Use it carefully.

`&@>` operator performs full text search by array of keywords. If one or more keywords are found, the record is matched.

## Syntax

```sql
column &@> keywords
```

`column` is a column to be searched.

`keywords` is an array of keyword for full text search. It's `text[]` type.

The operator returns `true` when one or more keyword in `keywords` are included in `column`.

## Usage

Here are sample schema and data for examples:

```sql
CREATE TABLE memos (
id integer,
content text
);

CREATE INDEX pgroonga_content_index ON memos
USING pgroonga (content pgroonga.text_full_text_search_ops_v2);
```

```sql
INSERT INTO memos VALUES (1, 'PostgreSQL is a relational database management system.');
INSERT INTO memos VALUES (2, 'Groonga is a fast full text search engine that supports all languages.');
INSERT INTO memos VALUES (3, 'PGroonga is a PostgreSQL extension that uses Groonga as index.');
INSERT INTO memos VALUES (4, 'There is groonga command.');
```

You can perform full text search with keywords by `&@>` operator:

```sql
SELECT * FROM memos WHERE content &@> ARRAY['engine', 'database'];
-- id | content
-- ----+------------------------------------------------------------------------
-- 1 | PostgreSQL is a relational database management system.
-- 2 | Groonga is a fast full text search engine that supports all languages.
-- (2 rows)
```

`column &@> ARRAY['KEYWORD1', 'KEYWORD2']` equals to `column &? 'KEYWORD1 OR KEYWORD2'`.

## See also

* [`&@` operator](match-v2.html)

* [`&?` operator](query-v2.html)
63 changes: 63 additions & 0 deletions reference/operators/match-v2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
title: "&@ operator"
layout: en
---

# `&@` operator

## Summary

This operator uses v2 operator class. It doesn't provide backward compatibility until PGroonga 2.0.0. Use it carefully.

`&@` operator performs full text search by one keyword.

## Syntax

```sql
column &@ keyword
```

`column` is a column to be searched.

`keyword` is a keyword for full text search. It's `text` type.

## Usage

Here are sample schema and data for examples:

```sql
CREATE TABLE memos (
id integer,
content text
);

CREATE INDEX pgroonga_content_index ON memos
USING pgroonga (content pgroonga.text_full_text_search_ops_v2);
```

```sql
INSERT INTO memos VALUES (1, 'PostgreSQL is a relational database management system.');
INSERT INTO memos VALUES (2, 'Groonga is a fast full text search engine that supports all languages.');
INSERT INTO memos VALUES (3, 'PGroonga is a PostgreSQL extension that uses Groonga as index.');
INSERT INTO memos VALUES (4, 'There is groonga command.');
```

You can perform full text search with one keyword by `&@` operator:

```sql
SELECT * FROM memos WHERE content &@ 'engine';
-- id | content
-- ----+------------------------------------------------------------------------
-- 2 | Groonga is a fast full text search engine that supports all languages.
-- (1 row)
```

If you want to perform full text search with multiple keywords or AND/OR search, use [`&?` operator](query-v2.html).

If you want to perform full text search with multiple keywords OR search, use [`&@>` operator](match-contain-v2.html).

## See also

* [`&?` operator](query-v2.html)

* [`&@>` operator](match-contain-v2.html)
90 changes: 90 additions & 0 deletions reference/operators/prefix-rk-search-v2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
title: "&^~ operator"
layout: en
---

# `&^~` operator

## Summary

This operator uses v2 operator class. It doesn't provide backward compatibility until PGroonga 2.0.0. Use it carefully.

`&^~` operator performs [prefix RK search](http://groonga.org/docs/reference/operations/prefix_rk_search.html). R is for [Romaji](https://en.wikipedia.org/wiki/Romanization_of_Japanese). K is for [Katakana](https://en.wikipedia.org/wiki/Katakana).

Prefix RK search is useful for Japanese.

Prefix RK search is useful for implementing input completion.

## Syntax

```sql
column &^~ prefix
```

`column` is a column to be searched.

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

`column` values must be in Katakana. `prefix` must be in Romaji, Hiragana or Katakana.

The operator returns `true` when the `column` value has `prefix`.

## Usage

Here are sample schema and data for examples:

```sql
CREATE TABLE tag_readings (
name text,
katakana text,
PRIMARY KEY (name, katakana)
);

CREATE INDEX pgroonga_tag_reading_katakana_index ON tag_readings
USING pgroonga (katakana pgroonga.text_term_search_ops_v2);
```

```sql
INSERT INTO tag_readings VALUES ('PostgreSQL', 'ポストグレスキューエル');
INSERT INTO tag_readings VALUES ('PostgreSQL', 'ポスグレ');
INSERT INTO tag_readings VALUES ('Groonga', 'グルンガ');
INSERT INTO tag_readings VALUES ('PGroonga', 'ピージールンガ');
INSERT INTO tag_readings VALUES ('pglogical', 'ピージーロジカル');
```

You can perform prefix RK search with prefix in Romaji by `&^~` operator:

```sql
SELECT * FROM tag_readings WHERE katakana &^~ 'pi-ji-';
-- name | katakana
-- -----------+------------------
-- PGroonga | ピージールンガ
-- pglogical | ピージーロジカル
-- (2 rows)
```

You can also use Hiragana for prefix:

```sql
SELECT * FROM tag_readings WHERE katakana &^~ 'ぴーじー';
-- name | katakana
-- -----------+------------------
-- PGroonga | ピージールンガ
-- pglogical | ピージーロジカル
-- (2 rows)
```

You can also use Katakana for prefix:

```sql
SELECT * FROM tag_readings WHERE katakana &^~ 'ピージー';
-- name | katakana
-- -----------+------------------
-- PGroonga | ピージールンガ
-- pglogical | ピージーロジカル
-- (2 rows)
```

## See also

* [`&^` operator](prefix-search-v2.html)
61 changes: 61 additions & 0 deletions reference/operators/prefix-search-v2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
title: "&^ operator"
layout: en
---

# `&^` operator

## Summary

This operator uses v2 operator class. It doesn't provide backward compatibility until PGroonga 2.0.0. Use it carefully.

`&^` operator performs prefix search.

Prefix search is useful for implementing input completion.

## Syntax

```sql
column &^ prefix
```

`column` is a column to be searched.

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

The operator returns `true` when the `column` value has `prefix`.

## Usage

Here are sample schema and data for examples:

```sql
CREATE TABLE tags (
name text PRIMARY KEY
);

CREATE INDEX pgroonga_tag_name_index ON tags
USING pgroonga (name pgroonga.text_term_search_ops_v2);
```

```sql
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:

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

## See also

* [`&^?` operator](prefix-rk-search-v2.html)
70 changes: 70 additions & 0 deletions reference/operators/query-contain-v2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
title: "&?> operator for non jsonb types"
layout: en
---

# `&?>` operator for non jsonb types

## Summary

This operator uses v2 operator class. It doesn't provide backward compatibility until PGroonga 2.0.0. Use it carefully.

`&?>` operator performs full text search by array of queries. If one or more queries are matched, the record is matched.

Query's syntax is similar to syntax that is used in Web search engine. For example, you can use OR search by `KEYWORD1 OR KEYWORD2` in query.

## Syntax

```sql
column &?> queries
```

`column` is a column to be searched.

`queries` is an array of query for full text search. It's `text[]` type.

The operator returns `true` when one or more query in `queries` are matched against `column`.

## Usage

Here are sample schema and data for examples:

```sql
CREATE TABLE memos (
id integer,
content text
);

CREATE INDEX pgroonga_content_index ON memos
USING pgroonga (content pgroonga.text_full_text_search_ops_v2);
```

```sql
INSERT INTO memos VALUES (1, 'PostgreSQL is a relational database management system.');
INSERT INTO memos VALUES (2, 'Groonga is a fast full text search engine that supports all languages.');
INSERT INTO memos VALUES (3, 'PGroonga is a PostgreSQL extension that uses Groonga as index.');
INSERT INTO memos VALUES (4, 'There is groonga command.');
```

You can perform full text search with queries by `&?>` operator:

```sql
SELECT * FROM memos WHERE content &?> ARRAY['Groonga engine', 'PostgreSQL -PGroonga'];
-- id | content
-- ----+------------------------------------------------------------------------
-- 1 | PostgreSQL is a relational database management system.
-- 2 | Groonga is a fast full text search engine that supports all languages.
-- (2 rows)
```

`Groonga engine` query matches against a record that its `id` is `2`.

`PostgreSQL -PGroonga` query matches against a record that its `id` is `1`.

## See also

* [`&?` operator](query-v2.html)

* [Groonga's query syntax](http://groonga.org/docs/reference/grn_expr/query_syntax.html)

* [`&@>` operator](match-contain-v2.html)

0 comments on commit 8f36767

Please sign in to comment.