[Groonga-commit] ranguba/groonga-client-rails at 6018fa4 [master] Set match_columns by default

Back to archive index

Kouhei Sutou null+****@clear*****
Sun Mar 27 15:02:35 JST 2016


Kouhei Sutou	2016-03-27 15:02:35 +0900 (Sun, 27 Mar 2016)

  New Revision: 6018fa4dd1a1cd37546878b391d7a9204e710b7f
  https://github.com/ranguba/groonga-client-rails/commit/6018fa4dd1a1cd37546878b391d7a9204e710b7f

  Message:
    Set match_columns by default

  Modified files:
    lib/groonga/client/searcher.rb
    test/fixtures/rails4-mongoid/test/searchers/posts_searcher_test.rb

  Modified: lib/groonga/client/searcher.rb (+9 -1)
===================================================================
--- lib/groonga/client/searcher.rb    2016-03-27 15:02:05 +0900 (7e090a2)
+++ lib/groonga/client/searcher.rb    2016-03-27 15:02:35 +0900 (7f097c1)
@@ -139,7 +139,15 @@ module Groonga
       end
 
       def search
-        TableRequest.new(self.class.schema.table)
+        schema = self.class.schema
+        full_text_searchable_column_names = []
+        schema.columns.each do |name, column|
+          if column.have_full_text_search_index?
+            full_text_searchable_column_names << name
+          end
+        end
+        TableRequest.new(schema.table).
+          match_columns(full_text_searchable_column_names)
       end
 
       private

  Modified: test/fixtures/rails4-mongoid/test/searchers/posts_searcher_test.rb (+8 -0)
===================================================================
--- test/fixtures/rails4-mongoid/test/searchers/posts_searcher_test.rb    2016-03-27 15:02:05 +0900 (a6c09d1)
+++ test/fixtures/rails4-mongoid/test/searchers/posts_searcher_test.rb    2016-03-27 15:02:35 +0900 (9b6df87)
@@ -13,4 +13,12 @@ class PostsSearcherTest < ActionController::TestCase
     assert_equal(["Hello World"],
                  result_set.records.collect {|record| record["body"]})
   end
+
+  test "should be searchable without match_columns" do
+    create(:post, body: "Hello World")
+    create(:post, body: "Hello Rails")
+    result_set =****@searc*****("World").result_set
+    assert_equal(["Hello World"],
+                 result_set.records.collect {|record| record["body"]})
+  end
 end
-------------- next part --------------
HTML����������������������������...
下载 



More information about the Groonga-commit mailing list
Back to archive index