インデックスの構築 | Lucene PHP
http://framework.zend.com/manual/ja/zend.search.lucene.overview.html
Zend_Search_Lucene_Field の型 フィールド型 保存 インデックス化 トークン化 バイナリ Keyword Yes Yes No No UnIndexed Yes No No No Binary Yes No No Yes Text Yes Yes Yes No UnStored No Yes Yes No
使い方によって保存方法を選べますね。自分の場合は、検索だけでデータは、別に保存するので検索して独自のIDだけ取得出来れば大丈夫なので。
$indexFile = '/tmp/myIndex'; $index = null; if( !is_dir($indexFile) ){ $index = Zend_Search_Lucene::create($indexFile); }else{ $index = Zend_Search_Lucene::open($indexFile); } // add to index $doc = new Zend_Search_Lucene_Document(); // for datastore key $doc->addField(Zend_Search_Lucene_Field::UnIndexed('myid','abcd1235467890')); // search index $doc->addField(Zend_Search_Lucene_Field::UnStored('contents','逆境無頼カイジ 破戒録篇','utf-8')); // add index $index->addDocument($doc); $doc2 = new Zend_Search_Lucene_Document(); $doc2->addField(Zend_Search_Lucene_Field::UnIndexed('myid','xyzd1235467890')); $doc2->addField(Zend_Search_Lucene_Field::UnStored('contents','Nayutawave Recordsよりリリースする少女時代の公式ペ>ージ。リリース情報やニュース、視聴・試聴コンテンツをご覧いただけます。','utf-8')); $index->addDocument($doc2); // たまに最適化 $index->optimize();
これを実行すると以下のようなファイルが生成されます。
$ tree -L 3 /tmp/myIndex /tmp/myIndex/ |-- _1.cfs |-- _1.sti |-- optimization.lock.file |-- read-lock-processing.lock.file |-- read.lock.file |-- segments.gen |-- segments_d `-- write.lock.file