[groonga-dev,00347] [ANN] rroonga 0.9.5

Back to archive index

Kouhei Sutou kou****@clear*****
2010年 7月 29日 (木) 14:53:22 JST


須藤です。

今日は肉の日ですね。

groongaをRubyから使うためのライブラリrroonga 0.9.5をリリース
しました。先ほどリリースされたgroonga 0.7.4に対応しています!

ラングバプロジェクト:
  http://groonga.rubyforge.org/

インストール:

  % sudo gem install rroonga

インストール(Windows。バイナリ入り):
  > gem install rroonga

tar.gz:
  http://rubyforge.org/frs/download.php/71840/rroonga-0.9.5.tgz

ハイライト:

今回のリリースからページネーション用の機能が加わりました。

例えば、以下のようにすると、descriptionに"Ruby"を含むエント
リのうち、スコアの高い順に並べて201件から300件目を取得するこ
とができます。

  result = table.select do |record|
    record.description =~ "Ruby"
  end
  entries = result.paginate([["_score", :descending]],
                            :page => 2,
                            :size => 100)

entriesにはGroonga::Paginationモジュールがextendされているの
で、entries.first_page?などのメソッドを使うことができます。
DataMapperのそれと同じ機能を備えているはずです。

ちょっとアダプタを書いてやるとwill_paginateとも使えるような
気がします。

ページネーションはるりまサーチ(*1)でも使っているので、使い方
はるりまサーチのソース(*2)も参考にしてください。

(*1) http://rurema.clear-code.com/
(*2) http://github.com/kou/rurema-search

変更点:

  http://groonga.rubyforge.org/rroonga/NEWS_ja_rdoc.html

  * groonga 0.7.4対応。
  * Groonga::Table#selectの改良:
    * 重み付きマッチ対応:
      sourceカラムとtitleカラムにマッチするが、
      titleカラムの方がスコアが大きくなる例:
        table.select do |record|
          (record.title * 10 | record.source) =~ "query"
        end

   * 配列で複数条件のand表現に対応:
     以下は同じ条件になる:
       table.select do |record|
         conditions = []
         conditions << record.title =~ "query"
         conditions << record.updated_at > Time.parse("2010-07-29T21:14:29+09:00")
         conditions
       end

       table.select do |record|
         (record.title =~ "query") &
           (record.updated_at > Time.parse("2010-07-29T21:14:29+09:00"))
       end

  * 利用しているgroongaのバージョン取得対応: Groonga::VERSION
  * Groonga::Table#support_sub_records?追加
  * ページネーション対応: Groonga::Table#paginate, Groonga::Pagination

-- 
須藤 功平 <kou****@clear*****>
株式会社クリアコード <http://www.clear-code.com/> (03-6231-7270)

Mozilla Firefox/Thunderbirdサポート:
  http://www.clear-code.com/services/mozilla/menu.html
迷惑メール対策:
  http://www.clear-code.com/software/milter-manager.html
テスティングフレームワーク:
  http://www.clear-code.com/software/cutter.html
  http://www.clear-code.com/software/uxu.html




groonga-dev メーリングリストの案内
Back to archive index