Open jrochkind opened 5 years ago
bundle exec solr_wrapper
with no args ends up calling SolrWrapper.instance({})
to get an instance to call #start on. This does pick up your .solr_wrapper.
The rake tasks instead of doing SolrWrapper.instance
, use SolrWrapper.default_instance
. Which does not seem to pick up .solr_config
.
I guess I can write my own local rake tasks that use SolrWrapper.instance({})
instead.
But I'm happy to give back to solr_wrapper if this is a bug or desired improvement? It may be that few users are actually using the rake tasks; if you were, I think you'd want them to pick up your .solr_wrapper, no?
I have confirmed that if I simply change @solr_instance = SolrWrapper.default_instance
in the rake file to @solr_instance = SolrWrapper.instance({})
, it does what I expect.
Putting this in your Rakefile is one workaround:
SolrWrapper.default_instance_options = YAML.load(ERB.new(IO.read("./.solr_wrapper")).result(binding))
It seems like there should be an easier and more obvious, documented and/or default solution.
The logic for default config file paths and ERB processing are locked in Solr::Configuration, and you can not currently do SolrWrapper.default_instance_options = Solr::Configuration.new
, nor does Solr::Configuration
have a #to_h.
Aha, here's a less ugly workaround:
SolrWrapper.default_instance_options = SolrWrapper::Configuration.new.options
(looks like #options is effectively the #to_h I was looking for)
Perhaps the default default_instance_options should actually be SolrWrapper::Configuration.new.options
?
It's worth noting that even if you do SolrWrapper.default_instance_options = SolrWrapper::Configuration.new.options
, the rake tasks will not create a collection/core you've specified in your .solr_wrapper
config file, like bundle exec solr_wrapper
will.
I have a
.solr_wrapper
file that specifies solr version 6.3.0.If I run
bundle exec solr_wrapper
, as expected I get:However, if I use the solr_wrapper rake tasks, (
require 'solr_wrapper/rake_task'
), and runbundle exec solr:start
, it seems to ignore the.solr_wrapper
file, I get:Is this a bug, should the rake task be using the
.solr_wrapper
config file too?If so, I am happy to prepare and submit a PR, feedback welcome.