Class: Supernova::Solr::Core

Inherits:
Server
  • Object
show all
Defined in:
lib/supernova/solr/core.rb

Constant Summary collapse

DEFAULT_SOLR_PATH =
"/opt/solr"

Constants inherited from Server

Server::DEFAULT_PARAMS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Server

body_from_docs, commit, core_names, delete_by_query, hash_to_json, index_doc, index_docs, json_to_hash, optimize, select, truncate

Methods included from FunctionalDelegator

included

Constructor Details

#initialize(solr_url, name) ⇒ Core

Returns a new instance of Core.



10
11
12
13
# File 'lib/supernova/solr/core.rb', line 10

def initialize(solr_url, name)
  @solr_url = Supernova::Solr.remove_trailing_slash(solr_url)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/supernova/solr/core.rb', line 7

def name
  @name
end

#solr_urlObject (readonly)

Returns the value of attribute solr_url.



7
8
9
# File 'lib/supernova/solr/core.rb', line 7

def solr_url
  @solr_url
end

Class Method Details

.create(solr_url, core_name, instance_dir = nil, data_dir = nil) ⇒ Object



23
24
25
26
27
# File 'lib/supernova/solr/core.rb', line 23

def create(solr_url, core_name, instance_dir = nil, data_dir = nil)
  instance_dir ||= DEFAULT_SOLR_PATH
  data_dir ||= "#{DEFAULT_SOLR_PATH}/data/#{core_name}"
  admin_action(solr_url, "CREATE", "name=#{core_name}&instanceDir=#{instance_dir}&dataDir=#{data_dir}")
end

.exists?(solr_url, core_name) ⇒ Boolean

Returns:



37
38
39
# File 'lib/supernova/solr/core.rb', line 37

def exists?(solr_url, core_name)
  !status(solr_url, core_name)["status"][core_name].empty?
end

.status(solr_url, core_name) ⇒ Object



33
34
35
# File 'lib/supernova/solr/core.rb', line 33

def status(solr_url, core_name)
  admin_action(solr_url, "STATUS", "core=#{core_name}")
end

.unload(solr_url, core_name) ⇒ Object



29
30
31
# File 'lib/supernova/solr/core.rb', line 29

def unload(solr_url, core_name)
  admin_action(solr_url, "UNLOAD", "core=#{core_name}&deleteIndex=true")
end

Instance Method Details

#urlObject



15
16
17
# File 'lib/supernova/solr/core.rb', line 15

def url
  "#{solr_url}/#{name}"
end