Kouhei Sutou
null+****@clear*****
Tue Feb 23 09:27:21 JST 2016
Kouhei Sutou 2016-02-23 09:27:21 +0900 (Tue, 23 Feb 2016) New Revision: 55f18a987317112866b30cf6245c0171af60f7be https://github.com/groonga/heroku-sample-rroonga-blog/commit/55f18a987317112866b30cf6245c0171af60f7be Message: Use TokenMecab Modified files: groonga/init.rb lib/post_searcher.rb Modified: groonga/init.rb (+9 -0) =================================================================== --- groonga/init.rb 2016-02-23 01:01:02 +0900 (ca2113e) +++ groonga/init.rb 2016-02-23 09:27:21 +0900 (89cacff) @@ -28,6 +28,15 @@ Groonga::Schema.define do |schema| table.index('Posts.content') end + schema.create_table('Words', + type: :patricia_trie, + key_type: :short_text, + normalizer: 'NormalizerAuto', + default_tokenizer: 'TokenMecab') do |table| + table.index('Posts.title') + table.index('Posts.content') + end + schema.create_table('Times', type: :patricia_trie, key_type: :time) do |table| Modified: lib/post_searcher.rb (+4 -1) =================================================================== --- lib/post_searcher.rb 2016-02-23 01:01:02 +0900 (e3353df) +++ lib/post_searcher.rb 2016-02-23 09:27:21 +0900 (8396362) @@ -7,7 +7,10 @@ class PostSearcher def search matched_posts =****@posts***** do |record| match_target = record.match_target do |match_record| - (match_record.title * 5) | (match_record.content) + (match_record.index('Words.Posts_title') * 10) | + (match_record.index('Terms.Posts_title') * 8) | + (match_record.index('Words.Posts_content') * 3) | + (match_record.index('Terms.Posts_content')) end words.collect do |word| match_target =~ word -------------- next part -------------- HTML����������������������������... Télécharger