[Groonga-commit] pgroonga/pgroonga.github.io at c85fda6 [master] match-jsonb-v2: add more information

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Jun 6 16:23:24 JST 2017


Kouhei Sutou	2017-06-06 16:23:24 +0900 (Tue, 06 Jun 2017)

  New Revision: c85fda646dafac45e4515e1696c7c9f3d09ddea5
  https://github.com/pgroonga/pgroonga.github.io/commit/c85fda646dafac45e4515e1696c7c9f3d09ddea5

  Message:
    match-jsonb-v2: add more information

  Added files:
    reference/operators/match-jsonb-v2.md
  Modified files:
    reference/index.md
    reference/operators/query-jsonb-v2.md

  Modified: reference/index.md (+1 -1)
===================================================================
--- reference/index.md    2017-06-06 16:07:16 +0900 (11f8fd8)
+++ reference/index.md    2017-06-06 16:23:24 +0900 (82b5803)
@@ -138,7 +138,7 @@ Supported types: `boolean`, `smallint`, `integer`, `bigint`, `real`, `double pre
 
 #### `pgroonga.jsonb_ops` operator class (default) {#jsonb-ops}
 
-* [`&@` operator][match-jsonb-v2]: Full text search against all text data in `jsonb` by a keyword
+  * [`&@` operator][match-jsonb-v2]: Full text search against all text data in `jsonb` by a keyword
 
   * [`&?` operator][query-jsonb-v2]: Full text search against all text data in `jsonb` by easy to use query language
 

  Added: reference/operators/match-jsonb-v2.md (+108 -0) 100644
===================================================================
--- /dev/null
+++ reference/operators/match-jsonb-v2.md    2017-06-06 16:23:24 +0900 (ca4e1d2)
@@ -0,0 +1,108 @@
+---
+title: "&@ operator for jsonb type"
+upper_level: ../
+---
+
+# `&@` operator for `jsonb` type
+
+Since 1.2.1.
+
+## Summary
+
+`&@` operator performs full text search against all texts in `jsonb` by one keyword.
+
+## Syntax
+
+```sql
+column &@ keyword
+```
+
+`column` is a column to be searched. It's `jsonb` type.
+
+`keyword` is a keyword for full text search. It's `text` type.
+
+## Operator classes
+
+You need to specify one of the following operator classes to use this operator:
+
+  * `pgroonga.jsonb_ops`: Default for `jsonb`.
+
+  * `pgroonga.jsonb_ops_v2`: For `jsonb`.
+
+## Usage
+
+Here are sample schema and data for examples:
+
+```sql
+CREATE TABLE logs (
+  record jsonb
+);
+
+CREATE INDEX pgroonga_logs_index ON logs USING pgroonga (record);
+
+INSERT INTO logs
+     VALUES ('{
+                "message": "Server is started.",
+                "host":    "www.example.com",
+                "tags": [
+                  "web",
+                  "example.com"
+                ]
+              }');
+INSERT INTO logs
+     VALUES ('{
+                "message": "GET /",
+                "host":    "www.example.com",
+                "code":    200,
+                "tags": [
+                  "web",
+                  "example.com"
+                ]
+              }');
+INSERT INTO logs
+     VALUES ('{
+                "message": "Send to <info �� example.com>.",
+                "host":    "mail.example.net",
+                "tags": [
+                  "mail",
+                  "example.net"
+                ]
+              }');
+```
+
+You can perform full text search with one keyword by `&@`:
+
+(It uses [`jsonb_pretty()` function][jsonb-pretty] provided since PostgreSQL 9.5 for readability.)
+
+```sql
+SELECT jsonb_pretty(record) FROM logs WHERE record &@ 'server';
+--             jsonb_pretty             
+-- -------------------------------------
+--  {                                  +
+--      "host": "www.example.com",     +
+--      "tags": [                      +
+--          "web",                     +
+--          "example.com"              +
+--      ],                             +
+--      "message": "Server is started."+
+--  }
+-- (1 row)
+```
+
+## See also
+
+  * [`jsonb` support][jsonb]
+
+  * [`&?` operator][query-jsonb-v2]: Full text search against all text data in `jsonb` by easy to use query language
+
+  * [`` &` `` operator][script-jsonb-v2]: Advanced search by ECMAScript like query language
+
+  * [`@>` operator][contain-jsonb]: Search by a `jsonb` data
+
+[jsonb]:../jsonb.html
+
+[match-jsonb-v2]:match-jsonb-v2.html
+[script-jsonb-v2]:script-jsonb-v2.html
+[contain-jsonb]:contain-jsonb.html
+
+[jsonb-pretty]:{{ site.postgresql_doc_base_url.en }}/functions-json.html#FUNCTIONS-JSON-PROCESSING-TABLE

  Modified: reference/operators/query-jsonb-v2.md (+19 -5)
===================================================================
--- reference/operators/query-jsonb-v2.md    2017-06-06 16:07:16 +0900 (1fc7a0c)
+++ reference/operators/query-jsonb-v2.md    2017-06-06 16:23:24 +0900 (f5f32a6)
@@ -3,11 +3,13 @@ title: "&? operator for jsonb type"
 upper_level: ../
 ---
 
-# `$?` operator for `jsonb` type
+# `&?` operator for `jsonb` type
+
+Since 1.2.1.
 
 ## Summary
 
-`$?` operator performs full text search against all texts in `jsonb` with query.
+`&?` operator performs full text search against all texts in `jsonb` 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.
 
@@ -21,7 +23,15 @@ column &? query
 
 `query` is a query for full text search. It's `text` type.
 
-[Groonga's query syntax](http://groonga.org/docs/reference/grn_expr/query_syntax.html) is used in `query`.
+[Groonga's query syntax][groonga-query-syntax] is used in `query`.
+
+## Operator classes
+
+You need to specify one of the following operator classes to use this operator:
+
+  * `pgroonga.jsonb_ops`: Default for `jsonb`.
+
+  * `pgroonga.jsonb_ops_v2`: For `jsonb`.
 
 ## Usage
 
@@ -66,7 +76,7 @@ INSERT INTO logs
 
 You can perform full text search with multiple keywords by `&?` operator like `KEYWORD1 KEYWORD2`. You can also do OR search by `KEYWORD1 OR KEYWORD2`:
 
-(It uses [`jsonb_pretty()` function]({{ site.postgresql_doc_base_url.en }}/functions-json.html#FUNCTIONS-JSON-PROCESSING-TABLE) provided since PostgreSQL 9.5 for readability.)
+(It uses [`jsonb_pretty()` function][jsonb-pretty] provided since PostgreSQL 9.5 for readability.)
 
 ```sql
 SELECT jsonb_pretty(record) FROM logs WHERE record &? 'server OR mail';
@@ -93,7 +103,7 @@ SELECT jsonb_pretty(record) FROM logs WHERE record &? 'server OR mail';
 
 ## See also
 
-  * [`jsonb` support](../jsonb.html)
+  * [`jsonb` support][jsonb]
 
   * [`&@` operator][match-jsonb-v2]: Full text search against all text data in `jsonb` by a keyword
 
@@ -101,6 +111,10 @@ SELECT jsonb_pretty(record) FROM logs WHERE record &? 'server OR mail';
 
   * [`@>` operator][contain-jsonb]: Search by a `jsonb` data
 
+[jsonb]
+
 [match-jsonb-v2]:match-jsonb-v2.html
 [script-jsonb-v2]:script-jsonb-v2.html
 [contain-jsonb]:contain-jsonb.html
+
+[jsonb-pretty]:{{ site.postgresql_doc_base_url.en }}/functions-json.html#FUNCTIONS-JSON-PROCESSING-TABLE
-------------- next part --------------
HTML����������������������������...
下載 



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