Module: SimpleSolrClient::Core::CoreData

Included in:
SimpleSolrClient::Core
Defined in:
lib/simple_solr_client/core/core_data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#raw_solr_hashObject (readonly)

Returns the value of attribute raw_solr_hash.



2
3
4
# File 'lib/simple_solr_client/core/core_data.rb', line 2

def raw_solr_hash
  @raw_solr_hash
end

Instance Method Details

#config_fileObject



57
58
59
# File 'lib/simple_solr_client/core/core_data.rb', line 57

def config_file
  File.join(instance_dir, 'conf', core_data_hash['config'])
end

#core_data_hashObject

Get the core data for this core This is weird in that while the data is about a specific core, we need to call it at the client_url level; hence all the screwing around with force_top_level_url

It would make sense to cache this until, say, a commit or a reload, but the added complexity isn’t yet worth it.



12
13
14
15
# File 'lib/simple_solr_client/core/core_data.rb', line 12

def core_data_hash
  cdata = get('admin/cores', {:force_top_level_url => true})
  cdata['status'][core]
end

#data_dirObject

The (local to the server) data directory



35
36
37
# File 'lib/simple_solr_client/core/core_data.rb', line 35

def data_dir
  core_data_hash['dataDir']
end

#indexObject



17
18
19
# File 'lib/simple_solr_client/core/core_data.rb', line 17

def index
  core_data_hash['index']
end

#instance_dirObject



53
54
55
# File 'lib/simple_solr_client/core/core_data.rb', line 53

def instance_dir
  core_data_hash['instanceDir']
end

#last_modifiedObject

Time of last modification



22
23
24
# File 'lib/simple_solr_client/core/core_data.rb', line 22

def last_modified
  Time.parse index['lastModified']
end

#number_of_documentsObject Also known as: numDocs, num_docs

Total documents



27
28
29
# File 'lib/simple_solr_client/core/core_data.rb', line 27

def number_of_documents
  index['numDocs']
end

#sizeObject

Get the index size in megabytes



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/simple_solr_client/core/core_data.rb', line 41

def size
  str = index['size']
  num, unit = str.split(/\s+/).compact.map(&:strip)
  num = num.to_f
  case unit
  when "MB"
    num * 1
  when "GB"
    num * 1000
  end
end