[groonga-dev,04721] Re: PGroonga における検索スコア

Back to archive index
Kouhei Sutou kou****@clear*****
2019年 1月 8日 (火) 19:37:47 JST


須藤です。

In <000201d4a562$16ba6780$442f3680$@mirror.ocn.ne.jp>
  "[groonga-dev,04720] PGroonga における検索スコア" on Sun, 6 Jan 2019 10:49:40 +0900,
  <toshio_uchiy****@mirro*****> wrote:

> ここで、ORDER BY 句では、PostgreSQL の関数を使って検索語
> algorithm の出現回数を計算しています。

出現回数pgroonga_score()で得られるので次のようにしてみてくだ
さい。

with v AS
( SELECT id,  content FROM subtitled WHERE content &@~ 'algorithm'
ORDER BY pgroonga_score(tableoid, ctid) DESC OFFSET 0 LIMIT 100 )
SELECT id, array_to_json( v.content ) FROM v;

>  PGroonga でも、全文検索する文章に依存したスコアリング方法は
> ないでしょうか。ただし、content 列は text 型の配列です。

pgroonga_score()がそれです。

  https://pgroonga.github.io/ja/reference/functions/pgroonga-score.html

スコアリング方法は次のように
pgroonga_full_text_search_condition_with_scorersを使うとカス
タマイズできます。これは3回以上出現してもそれ以上カウントし
ない例です。

  content &@~ ('algorithm', null, 'scorer_tf_at_most($index, 3)', null):pgroonga_full_text_search_condition_with_scorers

参考:

  * https://pgroonga.github.io/ja/reference/operators/query-v2.html
  * http://groonga.org/ja/docs/reference/scorer.html

-- 
須藤 功平 <kou****@clear*****>
株式会社クリアコード <https://www.clear-code.com/>

Groongaベースの全文検索システムを総合サポート:
  http://groonga.org/ja/support/
データ処理ツールの開発:
  https://www.clear-code.com/blog/2018/7/11.html



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