MySQL全文検索エンジンmroongaのインストール UTF-8以外でも利用可能
さくらVPS Cent OS6 MySQL 5.1.67 でのイントール
MySQLをyumでインストールして起動したまま
rpm で一気にインストール
# rpm -ivh http://packages.groonga.org/centos/groonga-release-1.1.0-1.noarch.rpm
# yum install -y mysql-mroonga
# yum install -y groonga-tokenizer-mecab
# yum install -y install groonga-normalizer-mysql
MySQLにログイン ennginesを確認
mysql> show engines;
+------------+---------+------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+------------+---------+------------------------------------------------------------+--------------+------+------------+
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance | NO | NO | NO |
| InnoDB | YES | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
+------------+---------+------------------------------------------------------------+--------------+------+------------+
5 rows in set (0.00 sec)
mroongaがまだないのでプラグインをインストール
mysql> INSTALL PLUGIN mroonga SONAME 'ha_mroonga.so';
確認
mysql> show engines;
+------------+---------+------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+------------+---------+------------------------------------------------------------+--------------+------+------------+
| mroonga | YES | CJK-ready fulltext search, column store | NO | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance | NO | NO | NO |
| InnoDB | YES | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
+------------+---------+------------------------------------------------------------+--------------+------+------------+
6 rows in set (0.00 sec)
コマンド、もしくはphpMyAdmmin の「操作」でテーブルのストレートエンジンを 「mroonga」 に指定。
動作確認
# mysql -uroot -p
mysql> create database sennatest;
mysql> create table articles(
-> id int unsigned not null auto_increment primary key,
-> body text,
-> fulltext(body)
-> );
mysql> insert into articles values (null,"郵貯民営化は重要な問題だと思う "), (null,"スローライフを志向するiPodの強み - CNET Japan"), (null,"HTML, CSS, Photoshopを同時に学べるサンプル付きデザイン記事:Goodpic"), (null,"jazzanovaの日記 - 現在顧問弁護士に相談中であり、対応についても検討中"), (null,"mixi非公式ニュースサイト - mixiの問題人物Kusakabe氏、強制退会に?"), (null,"むだづかいにっき♂:ネット上で議論を仕掛ける事について"), (null,"はてな perl ハッカーの方々にお聞きします。近頃ますます良い感じなperlですが、どのような開発環境で開発していますでしょうか。"), (null,"シナトラ千代子 - 投げ銭が飛び交うなかでダイアリーに立てこもる、という意味。"), (null,"Going My Way: Skypeの会話をPodcast用に録音する場合の設定方法"), (null,"Kusakabeさんがmixiの一部?を賑わしている。彼にmixi強制退会が言い渡されたのだ。"), (null,"Ringo's Weblog: googleと競合しない方法2 "), (null,"Moleskin Diary - 投げ銭よりたれ銭"), (null,"第38回 海外メディアが伝えた小泉・郵政解散劇の評判 - nikkeibp.jp - 立花隆の「メディア ソシオ-ポリティクス」"), (null,"ほその日記 - フォームが変更された事を知る"), (null,"総選挙はてなと公職選挙法:北海道に住む国家公務員日記 "), (null,"はてな、政党を株式に見立てて総選挙結果を予測 - CNET Japan");
mysql> select * from articles where match (body) against ('mixi');
+----+---------------------------------------------------------------------------------------------------------------+
| id | body |
+----+---------------------------------------------------------------------------------------------------------------+
| 5 | mixi非公式ニュースサイト - mixiの問題人物Kusakabe氏、強制退会に? |
| 10 | Kusakabeさんがmixiの一部?を賑わしている。彼にmixi強制退会が言い渡されたのだ。 |
+----+---------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
全文検索ができることを確認
//UIImage:imgがRectより大きい場合リサイズする
-(id)resizeImage:(UIImage*)img Rect:(CGRect)Rect
{
if (( img.size.height > Rect.size.height) || ( img.size.width > Rect.size.width)) {
NSLog(@"%f : %f",img.size.width,img.size.height);
float asp = (float)img.size.width / (float)img.size.height;
CGRect r = CGRectMake(0,0,0,0);
if ( img.size.width > img.size.height) {
r.size.width = Rect.size.width;
r.size.height = r.size.width / asp;
}
else {
r.size.height = Rect.size.height;
r.size.width = r.size.height * asp;
}
UIGraphicsBeginImageContext(r.size);
[img drawInRect:CGRectMake(0,0,r.size.width,r.size.height)];
img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
return img;
}
-(id)resizeImage:(UIImage*)img Rect:(CGRect)Rect
{
if (( img.size.height > Rect.size.height) || ( img.size.width > Rect.size.width)) {
NSLog(@"%f : %f",img.size.width,img.size.height);
float asp = (float)img.size.width / (float)img.size.height;
CGRect r = CGRectMake(0,0,0,0);
if ( img.size.width > img.size.height) {
r.size.width = Rect.size.width;
r.size.height = r.size.width / asp;
}
else {
r.size.height = Rect.size.height;
r.size.width = r.size.height * asp;
}
UIGraphicsBeginImageContext(r.size);
[img drawInRect:CGRectMake(0,0,r.size.width,r.size.height)];
img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
return img;
}
ヴォラーレ株式会社が運営するiosアプリの紹介サイト「Appliv」「日刊Appliv」にiPhoneアプリ 顔文字L が掲載されました!
顔文字L
http://nikkan.app-liv.jp/archives/13879
DESKPLATE
http://app-liv.jp/558292326/
Appliv http://app-liv.jp/
日刊Appliv http://nikkan.app-liv.jp/
顔文字L
http://nikkan.app-liv.jp/archives/13879
DESKPLATE
http://app-liv.jp/558292326/
Appliv http://app-liv.jp/
日刊Appliv http://nikkan.app-liv.jp/
ファイル作成時に xibを使わないようにすればいい
こうすればソース内から完全にコントロールできる
こうすればソース内から完全にコントロールできる

