This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
criteria.merge!( :_keywords => { :$in => words } ) | |
search_result = collection.map_reduce(search_map(words), search_reduce, :query => criteria) | |
def search_reduce | |
"function( key , values ){return values[0];}" | |
end | |
def search_map(words) | |
#convert words into Regex OR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
criteria.merge!( :_keywords => { :$in => words } ) | |
search_result = collection.map_reduce(search_map(words), search_reduce, {:query => criteria, :finalize => search_finalize}) | |
def search_reduce | |
"function( key , values ){return { model: values[0]};}" | |
end | |
def search_finalize | |
"function( key , values ){return values.model;}" |