須藤様 お世話になります。内山です。 検索語を 'algorithm' とすると ちゃんとした検索結果が返される ようです。 WITH v AS ( SELECT id, video, track, stime, content, theme FROM subtitled WHERE content &@~ ( 'algorithm', null, ARRAY['scorer_tf_at_most($index, 100)'], null ) ::pgroonga_full_text_search_condition_with_scorers ORDER BY pgroonga_score( tableoid, ctid) + vc / ( 3346800846 / 2 ) * 100 DESC OFFSET 0 LIMIT 60) SELECT id, video, track, stime, array_to_json( content ) as c, theme from v 検索語を「アルゴリズム 検索」とすると WITH v AS ( SELECT id, video, track, stime, content, theme FROM subtitled WHERE content &@~ ( 'アルゴリズム 検索', null, ARRAY['scorer_tf_at_most($index, 100)'], null ) ::pgroonga_full_text_search_condition_with_scorers ORDER BY pgroonga_score( tableoid, ctid) + vc / ( 3346800846 / 2 ) * 100 DESC OFFSET 0 LIMIT 60) SELECT id, video, track, stime, array_to_json( content ) as c, theme from v 字幕には、「アルゴリズム」と「検索」の両方が入っていますが、 一つの映像しか検索できません。データと PostgreSQL + PGroonga は同じで SQL を WITH v AS ( SELECT id, video, track, stime, content, theme FROM subtitled WHERE content &@~ 'アルゴリズム 検索' ORDER BY pgroonga_score( tableoid, ctid ) DESC OFFSET 0 LIMIT 60) SELECT id, video, track, stime, array_to_json( content ) as c, theme from v とすると、検索結果は数多く(60だと思う)の映像が検索されます。 もしかして、pgroonga_full_text_search_condition_with_scorers では、PGroonga の クエリー構文「&@~ ’word1 word2'」で、word1 と word2 の AND 検索 を行う。が適用されないのでしょうか。 そうすると、 content &@~ ( 'アルゴリズム', null, ARRAY['scorer_tf_at_most($index, 100)'], null ) ::pgroonga_full_text_search_condition_with_scorers AND content &@~ ( '検索', null, ARRAY['scorer_tf_at_most($index, 100)'], null ) ::pgroonga_full_text_search_condition_with_scorers をプログラムで自作すれば良いでしょうか。ご指導のほどよろしくお願いします。 -----Original Message----- From: groonga-dev <groon****@lists*****> On Behalf Of Kouhei Sutou Sent: Sunday, January 13, 2019 10:12 AM To: groon****@lists***** Subject: [groonga-dev,04724] Re: PGroonga における検索スコア 須藤です。 In <004801d4aadb$784e8ac0$68eba040$@mirror.ocn.ne.jp> "[groonga-dev,04723] Re: PGroonga における検索スコア" on Sun, 13 Jan 2019 10:01:09 +0900, <toshio_uchiy****@mirro*****> wrote: > の和でスコアリングしようとしています。教えていただいた > 構文に似せて書くと > > moovle=# WITH v AS ( SELECT id, content FROM subtitled WHERE content > &@~ ( 'algorithm', null, '{scorer_tf_at_most( $index, 100 )}', null ) > ::pgroonga_full_text_search_condition_with_scorers > ORDER BY pgroonga_score( tableoid, ctid) + vc / ( 3346800846 / 2 ) * > 100 DESC OFFSET 0 LIMIT 60) SELECT id, array_to_json( content ) as c > from v; > ERROR: pgroonga: query-condition: failed to parse scorer: <Lexicon56822456_0.index>[0]: > <scorer_tf_at_most( $index>: Syntax error: <scorer_tf_at_most( > Lexicon56822456_0.index[0]||> > > とエラーになります。 '{...}'ではなくて ARRAY['scorer_tf_at_most($index, 100)'] にするとどうですか?「$index」のあとの「,」が 「scorer_tf_at_most」の引数の区切りではなくてPostgreSQLの配 列の要素の区切りと解釈されているように見えます。 -- 須藤 功平 <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 mailing list groon****@lists***** https://lists.osdn.me/mailman/listinfo/groonga-dev