Browse files

cartesian product of terms and fields for mongoid

  • Loading branch information...
1 parent 672e7de commit 6a5ea3c0760656168c7b89f79d6f35185575f340 @jasondew committed Sep 20, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 lib/data_table/mongoid.rb
View
3 lib/data_table/mongoid.rb
@@ -25,7 +25,8 @@ def _where_conditions raw_query, search_fields
{search_fields.first => {"$all" => terms.map {|term| /#{term}/i }}}
end
else
- {"$or" => search_fields.map {|field| {field => /#{query}/i} }}
+ terms = query.split(/\s+/)
+ {"$or" => search_fields.product(terms).map {|field, term| {field => /#{term}/i} }}
end
end

0 comments on commit 6a5ea3c

Please sign in to comment.