module ElasticRecord::Index::Search

Public Instance Methods

build_scroll_enumerator(search: nil, scroll_id: nil, batch_size: 100, keep_alive: ElasticRecord::Config.scroll_keep_alive) click to toggle source
# File lib/elastic_record/index/search.rb, line 83
def build_scroll_enumerator(search: nil, scroll_id: nil, batch_size: 100, keep_alive: ElasticRecord::Config.scroll_keep_alive)
  ScrollEnumerator.new(self, search: search, scroll_id: scroll_id, batch_size: batch_size, keep_alive: keep_alive)
end
delete_scroll(scroll_id) click to toggle source
# File lib/elastic_record/index/search.rb, line 98
def delete_scroll(scroll_id)
  connection.json_delete('/_search/scroll', { scroll_id: scroll_id })
end
explain(id, elastic_query) click to toggle source
# File lib/elastic_record/index/search.rb, line 79
def explain(id, elastic_query)
  get "_explain", elastic_query
end
record_exists?(id) click to toggle source
# File lib/elastic_record/index/search.rb, line 62
def record_exists?(id)
  get(id)['found']
end
scroll(scroll_id, scroll_keep_alive) click to toggle source
# File lib/elastic_record/index/search.rb, line 87
def scroll(scroll_id, scroll_keep_alive)
  options = {scroll_id: scroll_id, scroll: scroll_keep_alive}
  connection.json_get("/_search/scroll?#{options.to_query}")
rescue ElasticRecord::ConnectionError => e
  case e.status_code
  when '400' then raise ElasticRecord::InvalidScrollError, e.message
  when '404' then raise ElasticRecord::ExpiredScrollError, e.message
  else raise e
  end
end