Method: Elasticated::Repository::ResumableSearch#start

Defined in:
lib/elasticated/repository/resumable_search.rb

#startObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/elasticated/repository/resumable_search.rb', line 13

def start
  # aggregations
  aggregation_results = if aggregated
    body = query.build_for_aggregations
    response = client.search body, opts
    parse_and_prepare_results response, query
  end
  # search
  body = query.build_for_search
  response = client.search body, opts.merge(scroll: scroll_expiration_time, size: scroll_page_size)
  results = parse_and_prepare_results response
  results.append aggregation_results if aggregation_results
  self.scroll_id = results.scroll_id
  mark_completed! if results.documents.count < scroll_page_size
  results
end