Class: Ferret::Search::Spans::SpanNotQuery
- Defined in:
- lib/ferret/search/spans/span_not_query.rb
Overview
Removes matches which overlap with another SpanQuery.
Defined Under Namespace
Classes: SpanNotEnum
Instance Attribute Summary
Attributes inherited from Query
Instance Method Summary collapse
-
#excl ⇒ Object
Return the SpanQuery whose matches must not overlap those returned.
- #field ⇒ Object
-
#incl ⇒ Object
Return the SpanQuery whose matches are filtered.
-
#initialize(incl, excl) ⇒ SpanNotQuery
constructor
Construct a SpanNotQuery matching spans from
incl
which have no overlap with spans fromexcl
. - #rewrite(reader) ⇒ Object
- #spans(reader) ⇒ Object
- #terms ⇒ Object
- #to_s(field = nil) ⇒ Object
Methods inherited from SpanQuery
Methods inherited from Query
#combine, #create_weight, #extract_terms, #merge_boolean_queries, #similarity, #weight
Constructor Details
#initialize(incl, excl) ⇒ SpanNotQuery
Construct a SpanNotQuery matching spans from incl
which have no overlap with spans from excl
.
6 7 8 9 10 11 12 13 14 |
# File 'lib/ferret/search/spans/span_not_query.rb', line 6 def initialize(incl, excl) super() @incl = incl @excl = excl if incl.field != excl.field raise ArgumentError, "Clauses must have same field." end end |
Instance Method Details
#excl ⇒ Object
Return the SpanQuery whose matches must not overlap those returned.
20 |
# File 'lib/ferret/search/spans/span_not_query.rb', line 20 def excl() @excl end |
#field ⇒ Object
22 |
# File 'lib/ferret/search/spans/span_not_query.rb', line 22 def field() @incl.field() end |
#incl ⇒ Object
Return the SpanQuery whose matches are filtered.
17 |
# File 'lib/ferret/search/spans/span_not_query.rb', line 17 def incl() @incl end |
#rewrite(reader) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/ferret/search/spans/span_not_query.rb', line 107 def rewrite(reader) clone = nil rewritten_incl = @incl.rewrite(reader) if (rewritten_incl != @incl) clone = self.clone() clone.incl = rewritten_incl end rewritten_excl = @excl.rewrite(reader) if (rewritten_excl != @excl) clone = self.clone() if (clone == nil) clone.excl = rewritten_excl end if (clone != nil) return clone # some clauses rewrote else return self # no clauses rewrote end end |
#spans(reader) ⇒ Object
30 31 32 |
# File 'lib/ferret/search/spans/span_not_query.rb', line 30 def spans(reader) return SpanNotEnum.new(self, reader) end |
#terms ⇒ Object
24 |
# File 'lib/ferret/search/spans/span_not_query.rb', line 24 def terms() @incl.terms() end |
#to_s(field = nil) ⇒ Object
26 27 28 |
# File 'lib/ferret/search/spans/span_not_query.rb', line 26 def to_s(field = nil) return "span_not(#{incl.to_s(field)}, #{excl.to_s(field)})" end |