[Groonga-commit] droonga/droonga-engine at 108c89e [master] groonga: Support "filter" option for the select command

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Apr 28 16:36:53 JST 2014


YUKI Hiroshi	2014-04-28 16:36:53 +0900 (Mon, 28 Apr 2014)

  New Revision: 108c89edefd86cd2f1d18b1f746fd4b8c7f98721
  https://github.com/droonga/droonga-engine/commit/108c89edefd86cd2f1d18b1f746fd4b8c7f98721

  Message:
    groonga: Support "filter" option for the select command

  Modified files:
    lib/droonga/plugins/groonga/select.rb

  Modified: lib/droonga/plugins/groonga/select.rb (+19 -1)
===================================================================
--- lib/droonga/plugins/groonga/select.rb    2014-04-28 14:28:53 +0900 (de69973)
+++ lib/droonga/plugins/groonga/select.rb    2014-04-28 16:36:53 +0900 (0709567)
@@ -26,6 +26,7 @@ module Droonga
             match_columns = select_request["match_columns"]
             match_to = match_columns ? match_columns.split(/ *\|\| */) : []
             query = select_request["query"]
+            filter = select_request["filter"]
             output_columns = select_request["output_columns"] || ""
             attributes = output_columns.split(/, */)
             offset = (select_request["offset"] || "0").to_i
@@ -50,16 +51,33 @@ module Droonga
                 }
               }
             }
+
+            conditions = []
             if query
-              condition = {
+              conditions << {
                 "query"  => query,
                 "matchTo"=> match_to,
                 "defaultOperator"=> "&&",
                 "allowPragma"=> false,
                 "allowColumn"=> true,
               }
+            end
+
+            if filter
+              conditions << filter
+            end
+
+            case conditions.size
+            when 1
+              condition = conditions.first
+            when 2
+              condition = ["&&"] + conditions
+            end
+
+            if condition
               search_request["queries"][result_name]["condition"] = condition
             end
+
             search_request
           end
         end
-------------- next part --------------
HTML����������������������������...
Download 



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