Class: Hayfork::QueryObject
- Inherits:
-
Object
- Object
- Hayfork::QueryObject
- Defined in:
- lib/hayfork/query_object.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#phrases ⇒ Object
readonly
Returns the value of attribute phrases.
Instance Method Summary collapse
- #against(set) ⇒ Object
-
#initialize(phrases) ⇒ QueryObject
constructor
A new instance of QueryObject.
Constructor Details
#initialize(phrases) ⇒ QueryObject
Returns a new instance of QueryObject.
5 6 7 |
# File 'lib/hayfork/query_object.rb', line 5 def initialize(phrases) @phrases = phrases end |
Instance Attribute Details
#phrases ⇒ Object (readonly)
Returns the value of attribute phrases.
3 4 5 |
# File 'lib/hayfork/query_object.rb', line 3 def phrases @phrases end |
Instance Method Details
#against(set) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/hayfork/query_object.rb', line 9 def against(set) return set.none if phrases.none? return phrases.first.apply(set) if phrases.one? # The haystack may contain more than one hit per result. # # A composite query may match more than one hit for a result. # For example, it may match both a hymn's author and its tune. # # If we search more than one phrase, we want to find all of # the hits that match *_any_* of the search phrases but only # return hits for results that match *_all_* of the phrases. filter_hits_by_any_phrase(filter_results_that_match_all_phrases(set)) end |