.. -*- rst -*- .. highlightlang:: none .. groonga-include : drilldown.txt .. groonga-command .. database: tutorial ã¿ã°æ¤ç´¢ã»åç §é¢ä¿ã®éå¼ã ========================== æ¬ãã¥ã¼ããªã¢ã«ã§ãgroongaã¯ã«ã©ã å¤ã¨ãã¦ä»ã®ãã¼ãã«ã¸ã®åç §ã®é åãæã¤ãã¨ãã§ãããã¨ãç´¹ä»ãããã¾ãããå®ã¯ããã¼ãã«ã¸ã®åç §ã®é åãã¼ã¿ãç¨ãããã¨ã«ãã£ã¦ãããããã¿ã°æ¤ç´¢ãè¡ããã¨ãå¯è½ã¨ãªãã¾ãã ã¿ã°æ¤ç´¢ã¯groongaã®è»¢ç½®ã¤ã³ããã¯ã¹ã¨ãããã¼ã¿æ§é ãç¨ãã¦é«éã«è¡ããã¾ãã ã¿ã°æ¤ç´¢ -------- åç»å ±æãµã¤ãã®æ¤ç´¢ã¨ã³ã¸ã³ãä½ããã¨ãæ³å®ãã¾ãã1ã¤ã®åç»ã«ã¯ããã®åç»ã®ç¹å¾´ã表ããè¤æ°ã®èªå¥ãä»ä¸ããã¦ãã¾ãããããèªå¥ãä»ä¸ããã¦ããåç»ã®ä¸è¦§ãåå¾ãããæ¤ç´¢ãè¡ãããã¨ãã¾ãã å®éã«ãåç»æ å ±ã®ãã¼ãã«ãä½æããæ¤ç´¢ããã¦ã¿ã¾ãããã åç»ã®æ å ±ãä¿åãããVideoãã¼ãã«ãä½æãã¾ããVideoãã¼ãã«ã§ã¯ãåç»ã®ã¿ã¤ãã«ãtitleã«ã©ã ã«ãåç»ã®ã¿ã°æ å ±ãtagsã«ã©ã ã«Tagãã¼ãã«åã§è¤æ°æ ¼ç´ãã¦ãã¾ãã ã¿ã°ã®æ å ±ãä¿åãããTagãã¼ãã«ãä½æãã¾ããTagãã¼ãã«ã§ã¯ãã¿ã°æååã主ãã¼ã«æ ¼ç´ããVideoãã¼ãã«ã®tagsã«ã©ã ã«å¯¾ããã¤ã³ããã¯ã¹ãindex_tagsã«ã©ã ã«æ ¼ç´ãã¦ãã¾ãã .. groonga-command .. include:: ../example/tutorial/index-1.log .. 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"]} .. ] ã¤ã³ããã¯ã¹ã«ã©ã ãä½æããã¨ãå ¨ææ¤ç´¢ãé«éã«è¡ããããã«ãªãã¾ããã¤ã³ããã¯ã¹ã«ã©ã ã¯ã対象ã®ã«ã©ã ã«ä¿åããããã¼ã¿ã«æ´æ°ããã£ãã¨ããèªåçã«æ´æ°ããã¾ãã ãããèªå¥ãä»ä¸ããã¦ããåç»ã®ä¸è¦§ãåå¾ãããæ¤ç´¢ãè¡ãã¾ãããã .. groonga-command .. include:: ../example/tutorial/index-2.log .. select --table Video --query tags:@Variety --output_columns _key,title .. select --table Video --query tags:@Sports --output_columns _key,title .. select --table Video --query tags:@Animation --output_columns _key,title ãã®ããã«ããVarietyãããSportsãããAnimationãã®ãããªã¿ã°ã§æ¤ç´¢ãè¡ããã¨ãã§ãã¾ããã åç §é¢ä¿ã®éå¼ã ---------------- groongaã¯ãã¼ãã«éã®åç §é¢ä¿ã®éå¼ããé«éã«è¡ãããã®ã¤ã³ããã¯ã¹ãä»ä¸ãããã¨ãã§ãã¾ããã¿ã°æ¤ç´¢ã¯ããã®1ä¾ã«ããã¾ããã ä¾ãã°ãã½ã¼ã·ã£ã«ãããã¯ã¼ãã³ã°ãµã¤ãã«ãããå人é¢ä¿ãéå¼ãæ¤ç´¢ãããã¨ãã§ãã¾ãã 以ä¸ã®ä¾ã§ã¯ãã¦ã¼ã¶ã¼æ å ±ãæ ¼ç´ããUserãã¼ãã«ãä½æããã¦ã¼ã¶ã¼åãæ ¼ç´ããusernameã«ã©ã ãã¦ã¼ã¶ã¼ã®å人ä¸è¦§ãé åã§æ ¼ç´ããfriendsã«ã©ã ã¨ãã®ã¤ã³ããã¯ã¹ã®index_friendsã«ã©ã ã追å ãã¦ãã¾ãã .. groonga-command .. include:: ../example/tutorial/index-3.log .. 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"]} .. ] æå®ããã¦ã¼ã¶ã¼ãå人ãªã¹ãã«å ¥ãã¦ããã¦ã¼ã¶ã¼ã®ä¸è¦§ã表示ãã¦ã¿ã¾ãããã .. groonga-command .. include:: ../example/tutorial/index-4.log .. select --table User --query friends:@tomo --output_columns _key,username .. select --table User --query friends:@jiro --output_columns _key,username ããã«ãããªã«ãã¦ã³ã使ã£ã¦ãå人ãªã¹ãã«å ¥ã£ã¦ããæ°ã®ä¸è¦§ã表示ãã¦ã¿ã¾ãããã .. groonga-command .. include:: ../example/tutorial/index-5.log .. select --table User --limit 0 --drilldown friends ãã®ããã«ããã¼ãã«ã®åç §é¢ä¿ãéã«ãã©ãæ¤ç´¢ãã§ãã¾ããã ã¤ã³ããã¯ã¹ä»ãã¸ãªãµã¼ã -------------------------- ä½ç½®æ å ±ã®ã«ã©ã ã«å¯¾ãã¦ãã¤ã³ããã¯ã¹ãä»ä¸ãããã¨ãåºæ¥ã¾ãã大éã®ä½ç½®æ å ±ã¬ã³ã¼ããæ¤ç´¢ããå ´åã«ãæ¤ç´¢é度ãéããªãã¾ãã .. groonga-command .. include:: ../example/tutorial/index-6.log .. 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"} .. ] .. select --table Site --filter 'geo_in_circle(location, "128515259x503187188", 5000)' --output_columns _key,location åæ§ã«ãä½ç½®æ å ±ã¬ã³ã¼ããç¨ãã¦ã½ã¼ãããå ´åã«ãã½ã¼ãé度ãéããªãã¾ãã .. groonga-command .. include:: ../example/tutorial/index-7.log .. select --table Site --filter 'geo_in_circle(location, "128515259x503187188", 50000)' --output_columns _key,location,_score --sortby '-geo_distance(location, "128515259x503187188")' --scorer '_score = geo_distance(location, "128515259x503187188")'