Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
i2bskn committed May 31, 2015
1 parent 07c9a80 commit ede0e23
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/facile_search/inverted_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,8 @@ def search(*queries)
return [] if tokens.size.zero?
obj << redis.hmget(namespace, *tokens).map {|value| deserialize(value) }.inject(&:&)
else
cursor = 0
ids = []
10000.times do # TODO: Adjust max number of loop
cursor, matches = redis.hscan(namespace, cursor, match: "*#{query}*", count: 10000)
ids << matches.map {|_, value| deserialize(value) }
break if cursor.to_i.zero?
end
obj << ids.flatten.uniq
obj << redis.hscan_each(namespace, match: "*#{query}*")
.map {|_, value| deserialize(value) }.flatten.uniq
end
}.inject(&:&)
end
Expand Down

0 comments on commit ede0e23

Please sign in to comment.