Class: IndexedSearch::Match::Exact

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

Overview

Does a simple exact match.

Note this uses database string equality matching in some places, and ruby string equality in others, which does not always mean exactly the same thing especially with certain unicode characters. But our term normalization in IndexedSearch::Query.split_into_words should make it a non-issue.

Instance Method Summary collapse

Methods inherited from Base

#find, find_attributes, #initialize, match_against_term?, #results, #term_matches, #term_non_matches

Constructor Details

This class inherits a constructor from IndexedSearch::Match::Base

Instance Method Details

#scopeObject



16
17
18
# File 'lib/indexed_search/match/exact.rb', line 16

def scope
  @scope.where(self.class.matcher_attribute => term_matches.to_a)
end

#term_mapObject

ideally exact matches ideally shouldn’t need this complexity, just other types do… since ‘exact’ match terms exactly equal their matches (duh), but it’s just too complicated to make a difference.…



23
24
25
# File 'lib/indexed_search/match/exact.rb', line 23

def term_map
  @term_map ||= {}.tap { |map| term_matches.each { |term| map[term] = [term] } }
end