Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rake tasks do not respect .solr_wrapper file #127

Open
jrochkind opened this issue Apr 8, 2019 · 5 comments
Open

rake tasks do not respect .solr_wrapper file #127

jrochkind opened this issue Apr 8, 2019 · 5 comments

Comments

@jrochkind
Copy link
Contributor

I have a .solr_wrapper file that specifies solr version 6.3.0.

If I run bundle exec solr_wrapper, as expected I get:

Starting Solr 6.3.0 on port 8983 ..

However, if I use the solr_wrapper rake tasks, (require 'solr_wrapper/rake_task'), and run bundle exec solr:start, it seems to ignore the .solr_wrapper file, I get:

Starting solr at http://127.0.0.1:8983/solr/
solr-8.0.0.zip: |================                               | 70% ( ETA: 00:00:06 )

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.

@jrochkind
Copy link
Contributor Author

jrochkind commented Apr 8, 2019

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.

@jrochkind
Copy link
Contributor Author

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.

@jrochkind
Copy link
Contributor Author

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)

@jrochkind
Copy link
Contributor Author

Perhaps the default default_instance_options should actually be SolrWrapper::Configuration.new.options?

@jrochkind
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant