Class: SolrMakr::Core

Inherits:
Object
  • Object
show all
Includes:
SolrRequest
Defined in:
lib/solr_makr/core.rb

Constant Summary collapse

CONF_PATH =
'conf'
CONF_FILES =
%w[schema.xml solrconfig.xml]

Instance Method Summary collapse

Methods included from SolrRequest

#solr_request

Instance Method Details

#conf_dirObject



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

def conf_dir
  instance_dir.join(CONF_PATH)
end

#initialize_configuration!Object



41
42
43
44
45
46
47
48
49
# File 'lib/solr_makr/core.rb', line 41

def initialize_configuration!
  conf_dir.mkpath

  CONF_FILES.each do |conf_file|
    path = conf_dir.join(conf_file)

    path.write(SolrMakr.template(conf_file))
  end
end

#instance_dirPathname

Returns:



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

def instance_dir
  core_directory.join name
end

#register_with_solr!void

This method returns an undefined value.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/solr_makr/core.rb', line 52

def register_with_solr!
  params = {
    action:         'CREATE',
    name:           name,
    persist:        'true',
    instanceDir:    instance_dir.to_s,
    loadOnStartup:  'true',
    config:         'solrconfig.xml',
    schema:         'schema.xml'
  }

  params[:'collection.configName'] = 'core01'

  solr_request solr_cores_url, params: params
end

#reload!Object



68
69
70
71
72
73
74
75
# File 'lib/solr_makr/core.rb', line 68

def reload!
  params = {
    action: 'RELOAD',
    core:   name
  }

  solr_request solr_cores_url, params: params
end

#unload_from_solr!(purge: false) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/solr_makr/core.rb', line 77

def unload_from_solr!(purge: false)
  params = {
    core:           name,
    action:         'UNLOAD',
    deleteIndex:    'true',
    deleteDataDir:  'true'
  }

  if purge
    say "Deleting entire instance dir!!!"
    params[:deleteInstanceDir] = 'true'
  end

  solr_request solr_cores_url, params: params
end