[Groonga-commit] groonga/groonga-document-read-ja at 182949a [master] Remake DDL

Back to archive index

walker null+****@clear*****
Sun Dec 7 17:11:21 JST 2014


walker	2014-12-07 17:11:21 +0900 (Sun, 07 Dec 2014)

  New Revision: 182949a4d5caefb1c6173d7d466d0324898e3343
  https://github.com/groonga/groonga-document-read-ja/commit/182949a4d5caefb1c6173d7d466d0324898e3343

  Merged 8c8a0af: Merge pull request #2 from redfigure/master

  Message:
    Remake DDL

  Modified files:
    data/2014-10-27.grn

  Modified: data/2014-10-27.grn (+192 -35)
===================================================================
--- data/2014-10-27.grn    2014-11-04 12:02:51 +0900 (cf67234)
+++ data/2014-10-27.grn    2014-12-07 17:11:21 +0900 (8f94c93)
@@ -1,53 +1,210 @@
-table_create Blog1 TABLE_HASH_KEY ShortText
-column_create Blog1 message COLUMN_SCALAR ShortText
-column_create Blog1 title COLUMN_SCALAR ShortText
+# 4.1. 基本的な操作
+# 4.1.5. テーブルの作成
 
-table_create GeoIndex TABLE_PAT_KEY WGS84GeoPoint
+table_create --name Site --flags TABLE_HASH_KEY --key_type ShortText
 
-table_create IndexBlog1 TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto
+# 4.1.7. カラムの作成
 
-table_create Site TABLE_HASH_KEY ShortText
-column_create Site location COLUMN_SCALAR WGS84GeoPoint
-column_create Site title COLUMN_SCALAR ShortText
+column_create --table Site --name title --flags COLUMN_SCALAR --type ShortText
 
-table_create SiteCountry TABLE_HASH_KEY ShortText
+# 4.1.8. データのロード
 
-table_create SiteDomain TABLE_HASH_KEY ShortText
+load --table Site
+[
+{"_key":"http://example.org/","title":"This is test record 1!"},
+{"_key":"http://example.net/","title":"test record 2."},
+{"_key":"http://example.com/","title":"test test record three."},
+{"_key":"http://example.net/afr","title":"test record four."},
+{"_key":"http://example.org/aba","title":"test test test record five."},
+{"_key":"http://example.com/rab","title":"test test test test record six."},
+{"_key":"http://example.net/atv","title":"test test test record seven."},
+{"_key":"http://example.org/gat","title":"test test record eight."},
+{"_key":"http://example.com/vdw","title":"test test record nine."}
+]
 
-table_create Tag TABLE_HASH_KEY ShortText
+# 4.1.10. 全文検索用の語彙表の作成
 
-table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto
+table_create --name Terms --flags TABLE_PAT_KEY|KEY_NORMALIZE --key_type ShortText --default_tokenizer TokenBigram
 
-table_create ToyBox TABLE_HASH_KEY ShortText
-column_create ToyBox is_animal COLUMN_SCALAR Bool
-column_create ToyBox location COLUMN_SCALAR WGS84GeoPoint
-column_create ToyBox name COLUMN_SCALAR ShortText
-column_create ToyBox price COLUMN_SCALAR Int8
-column_create ToyBox time COLUMN_SCALAR Time
-column_create ToyBox weight COLUMN_SCALAR Float
+column_create --table Terms --name blog_title --flags COLUMN_INDEX|WITH_POSITION --type Site --source title
 
-table_create User TABLE_HASH_KEY ShortText
-column_create User username COLUMN_SCALAR ShortText
+# 4.3. いろいろなデータの保存
 
-table_create Video TABLE_HASH_KEY UInt32
-column_create Video title COLUMN_SCALAR ShortText
+table_create --name ToyBox --flags TABLE_HASH_KEY --key_type ShortText
 
-column_create Site country COLUMN_SCALAR SiteCountry
-column_create Site domain COLUMN_SCALAR SiteDomain
-column_create Site link COLUMN_SCALAR Site
-column_create Site links COLUMN_VECTOR Site
+# 4.3.2. 真偽値
 
-column_create User friends COLUMN_VECTOR User
+column_create --table ToyBox --name is_animal --flags COLUMN_SCALAR --type Bool
 
-column_create Video tags COLUMN_VECTOR Tag
+load --table ToyBox
+[
+{"_key":"Monkey","is_animal":true},
+{"_key":"Flower","is_animal":false}
+{"_key":"Block"}
+]
 
-column_create GeoIndex index_point COLUMN_INDEX Site location
+# 4.3.3. 数値
 
-column_create IndexBlog1 index_message COLUMN_INDEX|WITH_POSITION Blog1 message
-column_create IndexBlog1 index_title COLUMN_INDEX|WITH_POSITION Blog1 title
+column_create --table ToyBox --name price --flags COLUMN_SCALAR --type Int8
 
-column_create Tag index_tags COLUMN_INDEX Video tags
+column_create --table ToyBox --name weight --flags COLUMN_SCALAR --type Float
 
-column_create Terms blog_title COLUMN_INDEX|WITH_POSITION Site title
+load --table ToyBox
+[
+{"_key":"Monkey","price":15.9},
+{"_key":"Flower","price":200,"weight":0.13},
+{"_key":"Block","weight":25.7}
+]
+
+# 4.3.4. 文字列
+
+column_create --table ToyBox --name name --flags COLUMN_SCALAR --type ShortText
+
+load --table ToyBox
+[
+{"_key":"Monkey","name":"Grease"},
+{"_key":"Flower","name":"Rose"}
+]
+
+# 4.3.5. 日時
+
+column_create --table ToyBox --name time --flags COLUMN_SCALAR --type Time
+
+load --table ToyBox
+[
+{"_key":"Flower","time":1234567890.1234569999},
+{"_key":"Block","time":-1234567890}
+]
+
+# 4.3.6. 経緯度
+
+column_create --table ToyBox --name location --flags COLUMN_SCALAR --type WGS84GeoPoint
+
+load --table ToyBox
+[
+{"_key":"Monkey","location":"128452975x503157902"},
+{"_key":"Block","location":"35.6813819x139.7660839"}
+]
+
+# 4.3.7. テーブル参照
+
+column_create --table Site --name link --flags COLUMN_SCALAR --type Site
+
+load --table Site
+[
+{"_key":"http://example.org/","link":"http://example.net/"}
+]
+
+# 4.3.8. ベクターカラム
+
+column_create --table Site --name links --flags COLUMN_VECTOR --type Site
+
+load --table Site
+[
+{"_key":"http://example.org/","links":["http://example.net/","http://example.org/","http://example.com/"]}
+]
+
+# 4.4. さまざまな検索条件
+# 4.4.3. 位置情報を用いた絞込・ソート
+
+column_create --table Site --name location --flags COLUMN_SCALAR --type WGS84GeoPoint
+
+load --table Site
+[
+{"_key":"http://example.org/","location":"128452975x503157902"}
+{"_key":"http://example.net/","location":"128487316x502920929"},
+]
+
+# 4.5. ドリルダウン
+
+table_create --name SiteDomain --flags TABLE_HASH_KEY --key_type ShortText
+table_create --name SiteCountry --flags TABLE_HASH_KEY --key_type ShortText
+
+column_create --table Site --name domain --flags COLUMN_SCALAR --type SiteDomain
+column_create --table Site --name country --flags COLUMN_SCALAR --type SiteCountry
+
+load --table Site
+[
+{"_key":"http://example.org/","domain":".org","country":"japan"},
+{"_key":"http://example.net/","domain":".net","country":"brazil"},
+{"_key":"http://example.com/","domain":".com","country":"japan"},
+{"_key":"http://example.net/afr","domain":".net","country":"usa"},
+{"_key":"http://example.org/aba","domain":".org","country":"korea"},
+{"_key":"http://example.com/rab","domain":".com","country":"china"},
+{"_key":"http://example.net/atv","domain":".net","country":"china"},
+{"_key":"http://example.org/gat","domain":".org","country":"usa"},
+{"_key":"http://example.com/vdw","domain":".com","country":"japan"}
+]
+
+# 4.6. タグ検索・参照関係の逆引き
+# 4.6.1. タグ検索
+
+table_create --name Video --flags TABLE_HASH_KEY --key_type UInt32
+table_create --name Tag --flags TABLE_HASH_KEY --key_type ShortText
+
+column_create --table Video --name title --flags COLUMN_SCALAR --type ShortText
+column_create --table Video --name tags --flags COLUMN_VECTOR --type Tag
+column_create --table Tag --name index_tags --flags COLUMN_INDEX --type Video --source tags
+
+load --table Video
+[
+{"_key":1,"title":"Soccer 2010","tags":["Sports","Soccer"]},
+{"_key":2,"title":"Zenigata Kinjirou","tags":["Variety","Money"]},
+{"_key":3,"title":"groonga Demo","tags":["IT","Server","groonga"]},
+{"_key":4,"title":"Moero!! Ultra Baseball","tags":["Sports","Baseball"]},
+{"_key":5,"title":"Hex Gone!","tags":["Variety","Quiz"]},
+{"_key":6,"title":"Pikonyan 1","tags":["Animation","Pikonyan"]},
+{"_key":7,"title":"Draw 8 Month","tags":["Animation","Raccoon"]},
+{"_key":8,"title":"K.O.","tags":["Animation","Music"]}
+]
+
+# 4.6.2. 参照関係の逆引き
+
+table_create --name User --flags TABLE_HASH_KEY --key_type ShortText
+
+column_create --table User --name username --flags COLUMN_SCALAR --type ShortText
+column_create --table User --name friends --flags COLUMN_VECTOR --type User
+column_create --table User --name index_friends --flags COLUMN_INDEX --type User --source friends
+
+load --table User
+[
+{"_key":"ken","username":"健作","friends":["taro","jiro","tomo","moritapo"]}
+{"_key":"moritapo","username":"森田","friends":["ken","tomo"]}
+{"_key":"taro","username":"ぐるんが太郎","friends":["jiro","tomo"]}
+{"_key":"jiro","username":"ぐるんが次郎","friends":["taro","tomo"]}
+{"_key":"tomo","username":"トモちゃん","friends":["ken","hana"]}
+{"_key":"hana","username":"花子","friends":["ken","taro","jiro","moritapo","tomo"]}
+]
+
+# 4.6.3. インデックス付きジオサーチ
+
+table_create --name GeoIndex --flags TABLE_PAT_KEY --key_type WGS84GeoPoint
+
+column_create --table GeoIndex --name index_point --type Site --flags COLUMN_INDEX --source location
+
+load --table Site
+[
+ {"_key":"http://example.org/","location":"128452975x503157902"},
+ {"_key":"http://example.net/","location":"128487316x502920929"}
+]
+
+# 4.7. match_columnsパラメータ
+# 4.7.1.1. カラムごとにインデックスを付与する場合
+
+table_create --name Blog1 --flags TABLE_HASH_KEY --key_type ShortText
+
+column_create --table Blog1 --name title --flags COLUMN_SCALAR --type ShortText
+column_create --table Blog1 --name message --flags COLUMN_SCALAR --type ShortText
+
+table_create --name IndexBlog1 --flags TABLE_PAT_KEY|KEY_NORMALIZE --key_type ShortText --default_tokenizer TokenBigram
+
+column_create --table IndexBlog1 --name index_title --flags COLUMN_INDEX|WITH_POSITION --type Blog1 --source title
+column_create --table IndexBlog1 --name index_message --flags COLUMN_INDEX|WITH_POSITION --type Blog1 --source message
+
+load --table Blog1
+[
+{"_key":"grn1","title":"groonga test","message":"groonga message"},
+{"_key":"grn2","title":"baseball result","message":"rakutan eggs 4 - 4 groonga moritars"},
+{"_key":"grn3","title":"groonga message","message":"none"}
+]
 
-column_create User index_friends COLUMN_INDEX User friends
-------------- next part --------------
HTML����������������������������...
下載 



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