Method: EScleaner#docs

Defined in:
lib/elasticsearch-data-cleaner.rb

#docs(index) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/elasticsearch-data-cleaner.rb', line 71

def docs(index)
  # Returns number of documents for index
  resp = @connection.get "#{index}/_stats/docs"
  r = (parse_response resp.body)['_all']['primaries']['docs']['count']
  if r
    if r < 10
      $logger.warn("index #{index} has #{r} docs")
    end
    return r
  else
    raise "could not get count of docs for index #{index}"
  end
end