[groonga-dev,00841] rroonga での scoreの設定方法

Back to archive index

Shinya Kawaji kawaj****@gmail*****
2012年 5月 9日 (水) 21:45:57 JST


川路です


rroongaで、任意の値を scoreに設定したいのですが、方法は有りますでしょう
か。


具体的にやりたいことは、一つは「ランダムに出力したい」ということで、

http://groonga.org/ja/docs/tutorial/search.html#scorer
にある

  select --table Site --filter "1" --scorer "_score = rand()" \
  --output_columns _id,_key,_score --sortby _score

と同様のことがしたいと思います。例えば

  Groonga["Site"].select{|t| t.score = rand() }.sort(["_score"])

のような記述になるかと思うのですが、

NoMethodError: undefined method `score=' for #<Groonga::RecordExpressionBuilder:0x00000012007410>

となります。


もう一つは「位置情報を元にしたソートを行いたい」ことで、

http://groonga.org/ja/docs/tutorial/search.html#id2
にある

  select --table Site --query "_id:1 OR _id:2" \
  --output_columns _key,location,_score \
  --scorer '_score = geo_distance(location, "128515259x503187188")' \
  --sortby -_score

は

  Groonga["Site"].select{|t|
    t.score = "geo_distance(location, "128515259x503187188")"
  }.sort(["_score"])

のような書き方かと思いましたが、これも上手くいきません。


なにか書き方がありますでしょうか。
もしくは、rroongaでは未実装なのでしょうか。

どうぞよろしくお願いします。




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