Navigation Menu

Skip to content

Commit

Permalink
groonga: Support "filter" option for the select command
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 28, 2014
1 parent 8acdd7a commit 108c89e
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/droonga/plugins/groonga/select.rb
Expand Up @@ -26,6 +26,7 @@ def convert(select_request)
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
Expand All @@ -50,16 +51,33 @@ def convert(select_request)
}
}
}

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
Expand Down

0 comments on commit 108c89e

Please sign in to comment.