Browse files

Adapted loader to add filterable fields to redis

  • Loading branch information...
1 parent 5a2a38e commit f9a60ea360c8b7ca63ea4e379b8741ecf0347d2c @rixth rixth committed May 10, 2011
Showing with 6 additions and 0 deletions.
  1. +6 −0 lib/soulmate/loader.rb
View
6 lib/soulmate/loader.rb
@@ -24,6 +24,7 @@ def load(items)
id = item["id"]
term = item["term"]
score = item["score"]
+ filters = item["filterable"] || {}
if id and term
# store the raw data in a separate key to reduce memory usage
@@ -33,6 +34,11 @@ def load(items)
Soulmate.redis.sadd(base, p) # remember this prefix in a master set
Soulmate.redis.zadd("#{base}:#{p}", score, id) # store the id of this term in the index
end
+
+ filters.each_pair do |index, value|
+ value = normalize(value).gsub(/ /, '')
+ Soulmate.redis.sadd("#{base}:#{p}:filters:#{index}:#{value}", id)
+ end
items_loaded += 1
end
puts "added #{i} entries" if i % 100 == 0 and i != 0

0 comments on commit f9a60ea

Please sign in to comment.