Class: Droonga::Searcher::QuerySearcher

Inherits:
Object
  • Object
show all
Defined in:
lib/droonga/searcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(context, query) ⇒ QuerySearcher



116
117
118
119
120
121
122
# File 'lib/droonga/searcher.rb', line 116

def initialize(context, query)
  @context = context
  @query = query
  @result = nil
  @condition = nil
  @start_time = nil
end

Instance Method Details

#formatObject



132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/droonga/searcher.rb', line 132

def format
  formatted_result = {}
  format_count(formatted_result)
  format_attributes(formatted_result)
  format_records(formatted_result)
  if need_element_output?("startTime")
    formatted_result["startTime"] = @start_time.iso8601
  end
  if need_element_output?("elapsedTime")
    formatted_result["elapsedTime"] = Time.now.to_f - @start_time.to_f
  end
  formatted_result
end

#need_output?Boolean



128
129
130
# File 'lib/droonga/searcher.rb', line 128

def need_output?
  @result and @query.has_key?("output")
end

#search(results) ⇒ Object



124
125
126
# File 'lib/droonga/searcher.rb', line 124

def search(results)
  search_query(results)
end