Tag: 太阳黑子

Solr Sunspot minimum_match

我是新手使用Solr Sunspot for Rails。 我正在尝试使用 所以很自然并非所有的代币都能匹配。 我无法弄清楚如何在我的搜索http://outoftime.github.com/sunspot/docs/index.html中使用minimum_matchfunction。 任何帮助将不胜感激。 我试过,我得到0结果: Articles.search do fulltext params[:q] do :minimum_match => 1 end end

solr sunspot – 搜索belongs_to association

我有一个属于多个其他表的结构模型。 class Fabric 5 text :description text :composition do composition.name end text :collection do collection.name end text :style do style.name end text :origin do origin.name end text :texture do texture.name end text :supplier do supplier.name end end end 我已经设置了所有反向关联(Has_many)等。但是我似乎无法通过全文搜索来查询所有这些关联表的名称字段。 任何帮助将不胜感激。 @search = Fabric.search do fulltext params[:search] end @fabrics = @search.results 罗斯

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

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

如何从模型回调中捕获在不同线程上引发的rsolr Sunspotexception?

即使我可以捕获从@ post.save引发的exception并记录错误并打印线程 begin if @post.save rescue Exception => ex # rescue Errno::ECONNREFUSED => ex Thread.list.each {|t| pt} Rails.logger.error “ERROR: Could not save blog post! Is the Solr server up and running? Exception: #{ex}” 它仍然在网页上出错,并且不会在堆栈跟踪中显示我的任何代码。 solr Sunspot模型回调在一个单独的线程上运行。 rsolr (1.0.9) lib/rsolr/connection.rb:19:in `rescue in execute’ rsolr (1.0.9) lib/rsolr/connection.rb:14:in `execute’ … sunspot_rails (2.1.0) lib/sunspot/rails/solr_instrumentation.rb:15:in `send_and_receive_with_as_instrumentation’ (eval):2:in `post’ rsolr (1.0.9) […]

如何在rails 4中使用全球化和太阳黑子

如何使用太阳黑子solr索引阿拉伯语配置文件翻译。 我可以使用全球化和太阳黑子,还是应该使用其他方法? 车型/ profile.rb translates :name, :description validates :name validates :description searchable do text :name text :description end

如何用Sunspot突出显示单词?

我想在文本中突出显示已找到的单词,例如,如此处所示。 据我所知,我必须遵循以下步骤: 1)在我的模型中,我必须在我想要突出显示的字段中添加:stored => true选项: searchable do text :title, :stored => true text :description end 2)在我的控制器中,我必须声明我想要突出显示的字段: def search @search = Article.search do keywords params[:search] do highlight :title end end end 3)在视图中我不知道该怎么做,我试过这个: – @search.each_hit_with_result do |hit, result| %p= link_to raw(hit_title(hit)), article_path(result) 这是做方法hit_title : def hit_title(hit) if highlight = hit.highlight(:title) highlight.format { |word| “#{word}” } else h(hit.result.title) […]

使用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 这当我重新索引不显示错误但是: […]

在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的文章? 不应该编入索引?