mswiszcz
mswiszcz

Reputation: 1006

Using solr and sunspot in development Rails

I'm trying to configure sunspot in my rails application, but I want it to work with installed solr-tomcat, because I'm using vagrant to manage development machine.

I've installed solr-tomcat using apt-get, according to first 2 steps from this tutorial: https://www.digitalocean.com/community/tutorials/how-to-install-solr-on-ubuntu-14-04

and I've added gem sunspot_rails to gemfile, also successfuly run rails generate sunspot_rails:install and configured my config/sunspot.xml accordingly:

production:
  solr:
    hostname: localhost
    port: 8080
    log_level: WARNING
    path: /solr/production

development:
  solr:
    hostname: localhost
    port: 8080
    log_level: INFO
    pid_dir: '/var/run'
  disabled: false

test:
  solr:
    hostname: localhost
    port: 8081
    log_level: WARNING
    path: /solr/test

Since I'm using vagrant, I want it to work out of the box, for any other developer that may join the project, and that's the main reason why I'm not installing gem sunspot_solr

I have a feeling that I'm missing something, but I don't know why.

When I try to rake sunspot:solr:reindex it throws HTTP Status 404 - /usr/share/solr/development/update - The requested resource is not available.

** Invoke sunspot:solr:reindex (first_time)
** Invoke sunspot:reindex (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute sunspot:reindex
Skipping progress bar: for progress reporting, add gem 'progress_bar' to your Gemfile
rake aborted!
RSolr::Error::Http: RSolr::Error::Http - 404 Not Found
Error: <html><head><title>Apache Tomcat/6.0.39 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - /solr/default/update</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>/solr/default/update</u></p><p><b>description</b> <u>The requested resource is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.39</h3></body></html>

Request Data: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><delete><query>type:User</query></delete>"

note: User is a model in my application

Solr is working, as I can visit localhost:8080/solr/admin without any problems

Upvotes: 0

Views: 1277

Answers (1)

mswiszcz
mswiszcz

Reputation: 1006

I've installed solr manualy, since in repo is outdated version anyway, using this tutorial https://www.digitalocean.com/community/tutorials/how-to-install-solr-on-ubuntu-14-04.

Then added to gemfile gem sunspot_solr, bundled and did rake sunspot:solr:start to generate solr/conf/schema.xml which I've copied after to opt/solr/solr/{APP_NAME}

and configured my config/sunspot.yml like that

development:
  solr:
    hostname: localhost
    port: 8983
    log_level: INFO
    path: /solr/{APP_NAME}
    solr_home: solr
  disabled: false

and it's working properly!

Full notes about the process I've saved as a gist, feel free to use it ;)

Upvotes: 1

Related Questions