From 168aecdeccb32dc910431e527330931599e1a810 Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Mon, 9 May 2011 23:11:25 -0700 Subject: [PATCH] Assimilate aliases if provided in to the terms used to create the indexes --- lib/soulmate/loader.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/soulmate/loader.rb b/lib/soulmate/loader.rb index bf03dd4..6bf8396 100644 --- a/lib/soulmate/loader.rb +++ b/lib/soulmate/loader.rb @@ -29,9 +29,11 @@ def load(items) # store the raw data in a separate key to reduce memory usage Soulmate.redis.hset(database, id, JSON.dump(item)) - prefixes_for_phrase(term).each do |p| - 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 + ([term] + (item["aliases"] || [])).each do |term| + prefixes_for_phrase(term).each do |p| + 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 end items_loaded += 1 end