[Groonga-commit] ranguba/groonga-client-rails at 7580b8a [master] Support disabling normalizer

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Dec 22 00:32:54 JST 2016


Kouhei Sutou	2016-12-22 00:32:54 +0900 (Thu, 22 Dec 2016)

  New Revision: 7580b8a26c664251e570e344ec40abb8b169bb6a
  https://github.com/ranguba/groonga-client-rails/commit/7580b8a26c664251e570e344ec40abb8b169bb6a

  Message:
    Support disabling normalizer

  Modified files:
    lib/groonga/client/searcher/schema.rb
    lib/groonga/client/searcher/schema_synchronizer.rb

  Modified: lib/groonga/client/searcher/schema.rb (+4 -0)
===================================================================
--- lib/groonga/client/searcher/schema.rb    2016-12-22 00:24:22 +0900 (b5fff9b)
+++ lib/groonga/client/searcher/schema.rb    2016-12-22 00:32:54 +0900 (a5542b5)
@@ -60,6 +60,10 @@ module Groonga
             @options[:type] || "Text"
           end
 
+          def normalizer
+            @options[:normalizer]
+          end
+
           def text_family_type?
             case type
             when "ShortText", "Text", "LongText"

  Modified: lib/groonga/client/searcher/schema_synchronizer.rb (+11 -3)
===================================================================
--- lib/groonga/client/searcher/schema_synchronizer.rb    2016-12-22 00:24:22 +0900 (fa4114e)
+++ lib/groonga/client/searcher/schema_synchronizer.rb    2016-12-22 00:32:54 +0900 (832078d)
@@ -80,7 +80,7 @@ module Groonga
           }
           parameters[:key_type] = column.type
           if column.text_family_type?
-            parameters[:normalizer] = "NormalizerAuto"
+            parameters[:normalizer] = decide_normalizer(column.normalizer)
           end
           execute(:table_create, parameters)
         end
@@ -114,13 +114,13 @@ module Groonga
           if column.have_full_text_search_index?
             parameters[:key_type] = "ShortText"
             parameters[:default_tokenizer] = "TokenBigram"
-            parameters[:normalizer] = "NormalizerAuto"
+            parameters[:normalizer] = decide_normalizer(column.normalizer)
           elsif column.reference?
             parameters[:key_type] = generate_reference_table_name(column)
           else
             parameters[:key_type] = column.type
             if column.text_family_type?
-              parameters[:normalizer] = "NormalizerAuto"
+              parameters[:normalizer] = decide_normalizer(column.normalizer)
             end
           end
           execute(:table_create, parameters)
@@ -159,6 +159,14 @@ module Groonga
           end
         end
 
+        def decide_normalizer(custom_normalizer)
+          if custom_normalizer == false
+            nil
+          else
+            custom_normalizer || "NormalizerAuto"
+          end
+        end
+
         def execute(name, parameters)
           Client.open do |client|
             response = client.execute(name, parameters)
-------------- next part --------------
HTML����������������������������...
Download 



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