[Groonga-commit] pgroonga/pgroonga.github.io at 8f36767 [master] Add documents for operators of v2 operator classes

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Apr 18 15:56:55 JST 2016


Kouhei Sutou	2016-04-18 15:56:55 +0900 (Mon, 18 Apr 2016)

  New Revision: 8f367676f96f9369d4e0e0ef73a2e7d7c6fa7be4
  https://github.com/pgroonga/pgroonga.github.io/commit/8f367676f96f9369d4e0e0ef73a2e7d7c6fa7be4

  Message:
    Add documents for operators of v2 operator classes

  Added files:
    reference/operators/match-contain-v2.md
    reference/operators/match-v2.md
    reference/operators/prefix-rk-search-v2.md
    reference/operators/prefix-search-v2.md
    reference/operators/query-contain-v2.md
    reference/operators/script-v2.md
    reference/operators/similar-search-v2.md
  Copied files:
    reference/operators/query-v2.md
      (from reference/operators/query.md)
  Modified files:
    reference/index.md
    reference/operators/query.md

  Modified: reference/index.md (+30 -0)
===================================================================
--- reference/index.md    2016-04-18 14:16:56 +0900 (f972e42)
+++ reference/index.md    2016-04-18 15:56:55 +0900 (a516a9a)
@@ -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)

  Added: reference/operators/match-contain-v2.md (+64 -0) 100644
===================================================================
--- /dev/null
+++ reference/operators/match-contain-v2.md    2016-04-18 15:56:55 +0900 (4d6cc91)
@@ -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)

  Added: reference/operators/match-v2.md (+63 -0) 100644
===================================================================
--- /dev/null
+++ reference/operators/match-v2.md    2016-04-18 15:56:55 +0900 (9c95bea)
@@ -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)

  Added: reference/operators/prefix-rk-search-v2.md (+90 -0) 100644
===================================================================
--- /dev/null
+++ reference/operators/prefix-rk-search-v2.md    2016-04-18 15:56:55 +0900 (e8c14a2)
@@ -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)

  Added: reference/operators/prefix-search-v2.md (+61 -0) 100644
===================================================================
--- /dev/null
+++ reference/operators/prefix-search-v2.md    2016-04-18 15:56:55 +0900 (d5d0e14)
@@ -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)

  Added: reference/operators/query-contain-v2.md (+70 -0) 100644
===================================================================
--- /dev/null
+++ reference/operators/query-contain-v2.md    2016-04-18 15:56:55 +0900 (586f336)
@@ -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)

  Copied: reference/operators/query-v2.md (+13 -12) 69%
===================================================================
--- reference/operators/query.md    2016-04-18 14:16:56 +0900 (386ec2b)
+++ reference/operators/query-v2.md    2016-04-18 15:56:55 +0900 (a122c23)
@@ -1,18 +1,22 @@
 ---
-title: "@@ operator for non jsonb types"
+title: "&? operator for non jsonb types"
 layout: en
 ---
 
-# `@@` operator for non `jsonb` types
+# `&?` operator for non `jsonb` types
 
 ## Summary
 
-`@@` operator performs full text search with query. Its 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.
+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 with query.
+
+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 @@ query
+column &? query
 ```
 
 `column` is a column to be searched.
@@ -31,7 +35,8 @@ CREATE TABLE memos (
   content text
 );
 
-CREATE INDEX pgroonga_content_index ON memos USING pgroonga (content);
+CREATE INDEX pgroonga_content_index ON memos
+  USING pgroonga (content pgroonga.text_full_text_search_ops_v2);
 ```
 
 ```sql
@@ -41,10 +46,10 @@ INSERT INTO memos VALUES (3, 'PGroonga is a PostgreSQL extension that uses Groon
 INSERT INTO memos VALUES (4, 'There is groonga command.');
 ```
 
-You can perform full text search with multiple keywords by `@@` operator like `KEYWORD1 KEYWORD2`. You can also do OR search by `KEYWORD1 OR KEYWORD2`:
+You can perform full text search with multiple keywords by `&?` operator like `KEYWORD1 KEYWORD2`. You can also do OR search by `KEYWORD1 OR KEYWORD2`:
 
 ```sql
-SELECT * FROM memos WHERE content @@ 'PGroonga OR PostgreSQL';
+SELECT * FROM memos WHERE content &? 'PGroonga OR PostgreSQL';
 --  id |                            content                             
 -- ----+----------------------------------------------------------------
 --   3 | PGroonga is a PostgreSQL extension that uses Groonga as index.
@@ -58,12 +63,8 @@ Note that you can't use syntax that starts with `COLUMN_NAME:` like `COLUMN_NAME
 
 You can't use `COLUMN_NAME:^VALUE` for prefix search. You need to use `VALUE*` for prefix search.
 
-## Sequential scan
-
-TODO: Describe about `SET search_path = "$user",public,pgroonga,pg_catalog;`.
-
 ## See also
 
-  * [`%%` operator](match.html)
+  * [`&@` operator](match-v2.html)
 
   * [Groonga's query syntax](http://groonga.org/docs/reference/grn_expr/query_syntax.html)

  Modified: reference/operators/query.md (+5 -1)
===================================================================
--- reference/operators/query.md    2016-04-18 14:16:56 +0900 (386ec2b)
+++ reference/operators/query.md    2016-04-18 15:56:55 +0900 (15ece67)
@@ -7,7 +7,11 @@ layout: en
 
 ## Summary
 
-`@@` operator performs full text search with query. Its 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.
+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 with query.
+
+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
 

  Added: reference/operators/script-v2.md (+66 -0) 100644
===================================================================
--- /dev/null
+++ reference/operators/script-v2.md    2016-04-18 15:56:55 +0900 (1ff61bd)
@@ -0,0 +1,66 @@
+---
+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 searches records with search condition written in [script syntax](http://groonga.org/docs/reference/grn_expr/script_syntax.html). Script syntax is a powerful syntax. You can use many operations such as full text search, prefix search, range search and so on.
+
+## Syntax
+
+```sql
+column &` script
+```
+
+`column` is a column to be searched.
+
+`script` is a script that specifies search conditions. It's `text` type.
+
+Syntax in `script` is [script syntax](http://groonga.org/docs/reference/grn_expr/script_syntax.html).
+
+## 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 (id, 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 specify complex conditions by `` &` `` operator:
+
+```sql
+SELECT * FROM memos WHERE content &` 'id >= 2 && (content @ "engine" || content @ "rdbms")';
+--  id |                                content                                 
+-- ----+------------------------------------------------------------------------
+--   2 | Groonga is a fast full text search engine that supports all languages.
+-- (1 row)
+```
+
+The specified script `'id >= 2 && (content @ "engine" || content @ "rdbms")'` means:
+
+  * `id` must be 2 or more larger (range search)
+  * `content` must contain `"engine"` or `"rdbms"` (full text search)
+
+You can also use [functions](http://groonga.org/docs/reference/function.html) in the script.
+
+## Sequential scan
+
+You can't use this operator with sequential scan.

  Added: reference/operators/similar-search-v2.md (+64 -0) 100644
===================================================================
--- /dev/null
+++ reference/operators/similar-search-v2.md    2016-04-18 15:56:55 +0900 (2995bff)
@@ -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 similar search.
+
+## Syntax
+
+```sql
+column &~? document
+```
+
+`column` is a column to be searched.
+
+`document` is a document for similar search. It's `text` type.
+
+Similar search searches records that have similar content with `document`. If `document` is short content, similar search may return records that is less similar.
+
+## 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 search records that is similar with the specified document by `&~?` operator:
+
+```sql
+SELECT * FROM memos WHERE content &~? 'Mroonga is a MySQL extension taht uses Groonga';
+--  id |                            content                             
+-- ----+----------------------------------------------------------------
+--   3 | PGroonga is a PostgreSQL extension that uses Groonga as index.
+-- (1 row)
+```
+
+## Sequential scan
+
+You can't use similar search with sequential scan. If you use similar search with sequential search, you get the following error:
+
+```sql
+SELECT * FROM memos WHERE content &~? 'Mroonga is a MySQL extension taht uses Groonga';
+-- ERROR:  pgroonga: operator &~? is available only in index scan
+```
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index