sunspot

Rails & Sunspot facets and filtering

╄→尐↘猪︶ㄣ 提交于 2019-12-04 13:27:46
问题 Pretty much a noobie here, so I appreciate any help someone can give. I'm trying to add faceting to the search on my site through Sunspot. Ryan just released a great Railscast which got me started: http://railscasts.com/episodes/278-search-with-sunspot. I got that working and was able to add additional facets. My problem is that the facets are independent of each other. If I have 3 facets on 3 different attributes, when I select a facet once I already have on selected, I would like to display

Can't reindex with sunspot / solr in rails app - Error: Severe errors in solr configuration

醉酒当歌 提交于 2019-12-04 07:55:30
问题 Ok, so I have a simple rails application and now i'm trying to implement sunspot for search capabilities. However, after I've generated the config file with rails g sunspot_rails:install and after I've started the server and it has made the solr-dir in my rails app-dir and i run bundle exec rake sunspot:solr:reindex I get the following trace: cakism@saraswati:~/railscode/calendar$ bundle exec rake sunspot:solr:reindex --trace ** Invoke sunspot:solr:reindex (first_time) ** Invoke sunspot

Debugging Solr search queries on Sunspot

放肆的年华 提交于 2019-12-04 03:30:42
问题 How can I debug Solr search queries when using the Sunspot gem on Rails? I have some queries that are returning bizarrely high scores, and I'm trying to get to the bottom of why this is happening. It doesn't seem like any debugging information is exposed to Sunspot, so I think that I need to debug through Solr directly. Fortunately, Solr has a handy web interface to search from, but for some reason, any queries I enter there return with 0 results. For example, when I search for the word "test

Can sunspot search inside array?

穿精又带淫゛_ 提交于 2019-12-03 15:53:32
I have the next model with a array field: Class Invitation include Mongoid::Document include Mongoid::Timestamps::Created include Sunspot::Mongo field :recipients, :type => Array attr_accessible :recipients searchable do text :recipients do recipients.map { |recipient| recipient } end end end I have in my controller: def recipients @invitation = Invitation.find(params[:id]) @search = Invitation.search do |s| s.fulltext params[:search] s.with(:recipients, @invitation.recipients) end @recipients = @search.results respond_to do |format| format.html end end This when I reindex not show error but:

400 Bad Request: unknown field 'type'

北慕城南 提交于 2019-12-03 15:06:44
I've set up Solr 3.6.2 on Tomcat as described here . Using the sunspot-rails gem and the embedded solr server I have no problems, but on my staging server I'm getting the response: message ERROR: [doc=Foo 20] unknown field 'type' description The request sent by the client was syntactically incorrect. The request data looks like this: <?xml version="1.0" encoding="UTF-8"?> <add> <doc> <field name="id">Foo 20</field> <field name="type">Foo</field> <field name="type">ActiveRecord::Base</field> <field name="class_name">Foo</field> <field name="name">test</field> </doc> </add> What's causing this?

connection rejected from solr in Rspec

人走茶凉 提交于 2019-12-03 13:22:56
I use the sunspot-rails for search. These is a Rspec looks like: describe "GET search" do before(:all) do system("rake", "sunspot:solr:start") end after(:all) do system("rake", "sunspot:solr:stop") end it "should do some search" do Text.search do ... end end end But it doesn't work. I got a failure: Errno::ECONNREFUSED: Connection refused - connect(2) But if I type rake sunspot:solr:start RAILS_ENV=test by hand in command line, and then run the spec, it passes. What's wrong? Isn't rake sunspot:solr:start RAILS_ENV=test equivalent to system("rake", "sunspot:solr:start") in test mode? (I tried

Querying multiple models with different attributes using Sunspot

怎甘沉沦 提交于 2019-12-03 09:56:51
问题 I'm using Sunspot to index and search several models in a Rails project and I need to limit results based on the models' HABTM associations with a Department model. This is because users may not have permission to see records in all departments so results from those departments shouldn't be returned. Here are the important parts of two of the models: class Message < ActiveRecord::Base has_many :comments, dependent: :destroy has_and_belongs_to_many :departments searchable do text :title, :body

Date range facets with Sunspot in Ruby on Rails

霸气de小男生 提交于 2019-12-03 08:26:38
I am using Sunspot to search for events (parties, concerts, ...) in a Ruby on Rails 3 application. I have managed to set up free text search and facet search on a couple of different category types. Now, I am stuck with my next task. I want to set up facets related to when the event is occuring. I want to have facets describing both relative date/time ranges such as "today", "this weekend", "next weekend" and absolute date/time ranges , such as "Easter Holiday 2011", "New Years Day 2012", ... The datetime ranges are sometimes overlapping each other. I have browsed around in the Sunspot API

Sunspot / Solr / Rails: Model Associations are not updating in the Index

隐身守侯 提交于 2019-12-03 08:18:29
I have a Fieldnote model in my app, which has_many :activities attached to it through a table called :fieldnote_activities. I then define a searchable index this way: searchable :auto_index => true, :auto_remove => true do integer :id integer :user_id, :references => User integer :activity_ids, :multiple => true do activities.map(&:id) end text :observations end And then I have a Search model to store / update searches. The search model thus also has its own associations with activities. I then perform my searches like this: @search = Search.find(params[:id]) @query = Fieldnote.search do

Searching across multiple models using sunspot/solr

隐身守侯 提交于 2019-12-03 08:03:41
I have been able to implement a basic full text search successfully, however any queries involving models from many to many relations don't seem to work for me when i try to use scopes ("with statements"). I know the relevant rows are in the db as my sql statements do return the data. however the sunspot queries don't return any results…i'm sure its probably a newbie goof up on my end…any assistance would be greatly appreciated…so here we go…. My Models class User has_one :registration searchable do text :first_name text :last_name text :email end end class Registration belongs_to :user has