Skip to content

Commit

Permalink
1.8.7 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
tyok committed Aug 3, 2011
1 parent d251f5c commit a4b1c31
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/mongoid_fulltext.rb
Expand Up @@ -108,7 +108,7 @@ def fulltext_search(query_string, options={})
query.update(Hash[options.map { |key,value| [ 'filter_values.%s' % key, { '$all' => [ value ].flatten } ] }])
count = coll.find(query).count
{:ngram => ngram, :count => count, :query => query}
end.sort_by!{ |record| record[:count] }
end.sort!{ |record1, record2| record1[:count] <=> record2[:count] }

# Using the queries we just constructed and the n-gram frequency counts we
# just computed, pull in about *:max_candidate_set_size* candidates by
Expand All @@ -128,7 +128,7 @@ def fulltext_search(query_string, options={})
ngram_score = ngrams[doc[:ngram][0]]
Hash[coll.find(doc[:query], query_options).map do |candidate|
[candidate['document_id'],
{clazz: candidate['class'], score: candidate['score'] * ngram_score}]
{:clazz => candidate['class'], :score => candidate['score'] * ngram_score}]
end]
end.compact

Expand All @@ -144,12 +144,12 @@ def fulltext_search(query_string, options={})
scores = candidates.map do |candidate_id, data|
{:id => candidate_id,
:clazz => data[:clazz],
:score => data[:score] + candidates_list.map{ |others| (others.delete(candidate_id) || {score: 0})[:score] }.sum
:score => data[:score] + candidates_list.map{ |others| (others.delete(candidate_id) || {:score => 0})[:score] }.sum
}
end
all_scores.concat(scores)
end
all_scores.sort_by!{ |document| -document[:score] }
all_scores.sort!{ |document1, document2| -document1[:score] <=> -document2[:score] }

instantiate_mapreduce_results(all_scores[0..max_results-1], { :return_scores => return_scores })
end
Expand Down
2 changes: 1 addition & 1 deletion spec/models/partitioned_artist.rb
Expand Up @@ -3,7 +3,7 @@ class PartitionedArtist
include Mongoid::FullTextSearch

field :full_name
field :exhibitions, type: Array, default: []
field :exhibitions, :type => Array, :default => []

fulltext_search_in :full_name,
:index_name => 'mongoid_fulltext.partitioned_artists',
Expand Down

0 comments on commit a4b1c31

Please sign in to comment.