Class: RSI::TermQuery
Instance Attribute Summary collapse
-
#field ⇒ Object
Returns the value of attribute field.
-
#term ⇒ Object
Returns the value of attribute term.
Instance Method Summary collapse
- #evaluate(locator) ⇒ Object
-
#initialize(field, term) ⇒ TermQuery
constructor
A new instance of TermQuery.
- #to_s ⇒ Object
Methods inherited from Query
Methods included from Loggable
Constructor Details
#initialize(field, term) ⇒ TermQuery
Returns a new instance of TermQuery.
60 61 62 63 |
# File 'lib/rsi/query.rb', line 60 def initialize( field, term ) @field = field @term = term end |
Instance Attribute Details
#field ⇒ Object
Returns the value of attribute field.
59 60 61 |
# File 'lib/rsi/query.rb', line 59 def field @field end |
#term ⇒ Object
Returns the value of attribute term.
59 60 61 |
# File 'lib/rsi/query.rb', line 59 def term @term end |
Instance Method Details
#evaluate(locator) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/rsi/query.rb', line 64 def evaluate( locator ) logger.debug( "Getting dict for #@field" ) dict = locator.get_dict_for_field( @field ) # get all docids containing @field:@term -> [] # return set unless dict.has_term?( term ) logger.debug( "Dict has no such term #{term}" ) return [] else ret = [] termid = dict.get_termid_for( term ) logger.debug( "Getting entries for #{term}(#{termid})" ) dict.get_entry_list( termid ).each do |termentry| logger.debug( termentry.to_s ) ret << termentry.docid end return ret.uniq end end |
#to_s ⇒ Object
83 84 85 |
# File 'lib/rsi/query.rb', line 83 def to_s return "#@field='#@term'" end |