0

I've tried different approaches to get solr to work, in particular, these rake sunspot:reindex rake aborted! RSolr::Error::Http - 404 Not Found, but I've ended up with this yet:

 $ bundle exec rake sunspot:reindex
=> Solr server started

rake aborted!
RSolr::Error::Http: RSolr::Error::Http - 404 Not Found
Error:     Not Found

URI: http://127.0.0.1:8983/solr/default/update?wt=ruby
Request Headers: {"Content-Type"=>"text/xml"}
Request Data: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><delete><query>type:ActsAsTaggableOn\\:\\:Tag</query></delete>"

How to fix it?

1 Answers1

0

You need to create the index. Here are the docs on indexing and how to create your index. Here's a much quicker but less thorough introduction.

As you're using sunspot, you probably want to read their docs first. Essentially you need to add a searchable block to your objects to index. After you've added that block, the objects will index on next save, or you can call the rake task you mentioned above.

Here's the example they give for a Post object:

class Post < ActiveRecord::Base
  searchable do
    text :title, :body
    text :comments do
      comments.map { |comment| comment.body }
    end

    boolean :featured
    integer :blog_id
    integer :author_id
    integer :category_ids, :multiple => true
    double  :average_rating
    time    :published_at
    time    :expired_at

    string  :sort_title do
      title.downcase.gsub(/^(an?|the)/, '')
    end
  end
end
Alex Lynham
  • 1,318
  • 2
  • 11
  • 29
  • the 2nd links describes how to do that with a "jar" file. but how can I use it? I'm on Rails, not in java. –  Sep 23 '16 at 13:22
  • I've added "searchable" to my model, the goal now is to start solr and set it up. –  Sep 23 '16 at 13:22