Tag: solr

在生产环境中设置带有导轨的太阳黑子solr

我尝试了各种链接,但我似乎无法找到一个很好的资源来创建一个在生产中使用rails的运行solr实例。 据我所知,你必须设置solr服务器进行生产。 我已尝试使用tomcat设置solr但我似乎无法将其链接到rails应用程序。 那里有什么好的资源可供我使用吗? 谢谢

无法将印象派模型添加到Solr

为了跟踪独特的观点,我添加了印象派gem 。 由于流量较高, 展示次数表会以更快的速度增长。 当我想要显示连续几周/几个月之间的比较时,这将导致问题。 所以我想到将impression’s模型与solr联系起来。 为了实现这一点,我首先在app/models/impression.rb文件夹下创建了一个名为impression的 app/models/impression.rb 。 class Impression [ :updated_at] do text :message, :boost=> 2.0 text :referrer text :ip_address integer :user_id time :created_at time :updated_at string :message string :view_name string :ip_address string :impressionable_type string :controller_name string :action_name string :session_hash string :request_hash integer :id integer :impressionable_id end end 然后我查看了一些实施印象派的博客文章,然后进行了重新索引。 bundle exec rake sunspot:reindex[,Impression] […]

如何使用太阳黑子在Rails中调整枚举?

我正在尝试使用Sunspot(Rails Solr gem)来使用我在模型中声明的枚举来调整结果范围。 我模型的相关部分如下所示: searchable do text :tag_list boolean :approved integer :perspective time :created_at end enum perspective: [ :not_applicable, :front, :side_front, :side, :side_back, :back, :above, :below ] 我控制器中的搜索块如下所示: def index //skip scoping if perspective is nil params[:perspective] ||= [] @search = Upload.search do with :approved, true with :perspective, params[:perspective] fulltext params[:tag] fulltext params[:search] do minimum_match […]

Sunspot Solr搜索Rails活动记录’LIKE’搜索

嗨我一直在我的应用程序中使用正常的rails活动记录LIKE搜索,我开始使用太阳黑子solr搜索。 我希望它尽可能接近轨道LIKE搜索。 wine.rb #sunspot stuff searchable :auto_index => true, :auto_remove => true do text :name end #sunspot stuff 的solr / CONF / schema.xml中 application_controller.rb search_string = “will input some values here” query = “%” + search_string + “%” solr_search = Wine.search do fulltext search_string end @solr_search_results = solr_search.results.sort_by{|e| e[:id]} @rails_search_results = Wine.find(:all, :conditions => [‘wines.name […]

使用Sunspot / Solr的团体?

使用太阳黑子时我在按组搜索时遇到问题。 这是一个例子: # == Schema Information # # Table name: movies # # id :integer(4) not null, primary key # title :string(255) class Movie < ActiveRecord::Base has_and_belongs_to_many :actors searchable do text :title integer :ages, multiple: true do actors.map(&:age) end text :names, multiple: true do actors.map(&:name) end end end # == Schema Information # # Table […]

可以在数组内搜索太阳黑子吗?

我有一个带有数组字段的下一个模型: 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 我在我的控制器中: 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 这当我重新索引不显示错误但是: […]

solr或sphinx? 哪个更好?

可能重复: 选择一个独立的全文搜索服务器:Sphinx还是SOLR? 我将使用它在我的ruby on rails app上进行全文搜索。 这是最好的选择。 solr用java来做这个工作。 或ruby中的sphix?

太阳黑子`LIKE`查询

我正在使用sunspot 。 如何运行LIKE查询( LIKE %q% )? 我想做这样的事情: @search = Sunspot.search(User) do |q| q.text_fields { with(:company_name).like(params[:q]) } end.results 代替: @search = Sunspot.search(User) do |q| q.text_fields { with(:company_name).starting_with(params[:q]) } end.results 这部分对我有用。 回顾sunspot代码,我找到了这段代码: class StartingWith < Base private def to_solr_conditional "#{solr_value(@value)}*" end end 它基本上生成以下太阳黑子搜索哈希: Sunspot.search(User) do |q| q.text_fields { with(:company_name).starting_with(“sta”)} } end => Sunspot::Search:{:q=>”*:*”, :fq=>[“type:User”, “company_name_text:sta*”]} 如果没有更简单的方法来实现LIKE %query% […]

在Rails中使用Sunspot和Solr拒绝连接

我遇到一个问题,当我尝试使用sunspot_rails执行搜索时出现ECONNREFUSED错误。 gem(sunspot_rails和sunspot_solr)似乎都安装得很好。 我正在运行1.3.3版本,我的服务器运行正常。 我发现了另一篇关于此的post,但post只建议启动太阳黑子solr服务器。 我肯定已经这样做了,但错误仍然存​​在。 我认为问题是由于服务器所在的端口。 当我查看RAILS_ENV=development rake sunspot:solr:run ,它显示服务器正在端口8983上运行。 我也尝试过命令RAILS_ENV=production rake sunspot:solr:run以相同的效果RAILS_ENV=production rake sunspot:solr:run 。 如果我检查sunspot.yml配置文件,它会显示以下内容: production: solr: hostname: localhost port: 8983 log_level: WARNING development: solr: hostname: localhost port: 8982 log_level: INFO test: solr: hostname: localhost port: 8981 log_level: WARNING 请注意,它应该在端口8982进行开发,但无论我做什么,它似乎都会继续在端口8983上重新启动服务器。 知道如何发生这种情况吗? 谢谢! 更新:我发现了一个潜在的原因。 在我的项目文件夹中,文件/solr/conf/scripts.conf包含以下内容: solr_port=8983 。 无论Rails环境处于活动状态,这似乎意味着硬编码端口。

使用Sunspot从Solr索引中排除草稿

我有一个名为Article的索引模型,我不希望solr索引未发表的文章。 class Article < ActiveRecord::Base searchable do text :title text :body end end 如何指定不是#published的文章? 不应该编入索引?