Class: IndexedSearch::Match::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/indexed_search/match/result.rb

Overview

each matcher class generates one (or more) of these to describe its results.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(matcher, term_map, rank_multiplier, term_multiplier, limit_reduction_factor, type_reduction_factor, matchidx = 0) ⇒ Result

Returns a new instance of Result.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/indexed_search/match/result.rb', line 8

def initialize(matcher, term_map, rank_multiplier, term_multiplier, limit_reduction_factor, type_reduction_factor, matchidx=0)
  self.matcher = matcher
  self.term_map = term_map
  self.rank_multiplier = rank_multiplier
  self.term_multiplier = term_multiplier
  self.limit_reduction_factor = limit_reduction_factor
  self.type_reduction_factor = type_reduction_factor
  self.matchidx = matchidx
  self.list_map = Hash.new { |hash,key| hash[key] = [] }
  self.reduced_by_limit_reduction_factor = false
  self.ignored_because_already_used = []
end

Instance Attribute Details

#ignored_because_already_usedObject

populated by result list class



29
30
31
# File 'lib/indexed_search/match/result.rb', line 29

def ignored_because_already_used
  @ignored_because_already_used
end

#limit_reduction_factorObject

Returns the value of attribute limit_reduction_factor.



7
8
9
# File 'lib/indexed_search/match/result.rb', line 7

def limit_reduction_factor
  @limit_reduction_factor
end

#list_mapObject

populated by result list class



29
30
31
# File 'lib/indexed_search/match/result.rb', line 29

def list_map
  @list_map
end

#matcherObject

Returns the value of attribute matcher.



7
8
9
# File 'lib/indexed_search/match/result.rb', line 7

def matcher
  @matcher
end

#matchidxObject

Returns the value of attribute matchidx.



7
8
9
# File 'lib/indexed_search/match/result.rb', line 7

def matchidx
  @matchidx
end

#rank_multiplierObject

Returns the value of attribute rank_multiplier.



7
8
9
# File 'lib/indexed_search/match/result.rb', line 7

def rank_multiplier
  @rank_multiplier
end

#reduced_by_limit_reduction_factorObject

populated by result list class



29
30
31
# File 'lib/indexed_search/match/result.rb', line 29

def reduced_by_limit_reduction_factor
  @reduced_by_limit_reduction_factor
end

#term_mapObject

Returns the value of attribute term_map.



7
8
9
# File 'lib/indexed_search/match/result.rb', line 7

def term_map
  @term_map
end

#term_multiplierObject

Returns the value of attribute term_multiplier.



7
8
9
# File 'lib/indexed_search/match/result.rb', line 7

def term_multiplier
  @term_multiplier
end

#type_reduction_factorObject

Returns the value of attribute type_reduction_factor.



7
8
9
# File 'lib/indexed_search/match/result.rb', line 7

def type_reduction_factor
  @type_reduction_factor
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/indexed_search/match/result.rb', line 24

def empty?
  find.empty?
end

#findObject



20
21
22
23
# File 'lib/indexed_search/match/result.rb', line 20

def find
  # TODO: I don't think this select should be necessary for everything, right?
  @find ||= matcher.find.select { |id, count, rank, *matches| term_map.has_key?(matches[matchidx]) }
end

#list_map_wordsObject



31
32
33
# File 'lib/indexed_search/match/result.rb', line 31

def list_map_words
  list_map.values.flatten.uniq
end