Tag: 太阳黑子轨道

在Solr和太阳黑子中自动完成

我正在使用RoR构建一个网站,我使用太阳黑子和solr搜索引擎。 我需要使用自动完成function,但我不能。 我知道Solr有一个叫做suggester的新东西,但我不知道如何在太阳黑子和rails应用程序中使用它。 我找到了一个名为sunspot_autocomplete的gem,我按照写的内容,但是当我尝试重新索引时,我得到了这个错误: rake aborted! RSolr::Error::Http – 400 Bad Request Error: ERROR:unknown field ‘tags_ac’ 可搜索的模型称为Experience ,我将此块放入其中 searchable do text :tags, :boost => 3 text :title, :boost => 2 text :tips autocomplete :tags, :using => :tags end 最后我发现这个博客听起来不错,但我不明白:( http://www.binrand.com/post/3338898-autocomplete-solr-architecture-rails-3-2-solr-1-4-with-sunspot-solr-gem.html 我需要您的帮助,将自动填充function放在我的应用中。 非常感谢 :) 更新:我终于修复并在搜索框中进行了演示 。

太阳黑子和RSpec失败。 提交似乎没有起作用

我有一些测试用RSpec运行Rails站点,但是尽管遵循了说明,事情本身并不是很好。 我通过工厂创建一篇文章,运行Sunspot.commit,然后检查结果。 我似乎总是画一个空白。 当我通过控制台或通过网站手动测试时,所有工作都可以找到。 有任何想法吗? 如何输出太阳黑子日志以查看发生了什么? 我的Gemfile有以下内容,我正在运行Rails 3.1.1 gem ‘sunspot’, ‘1.2.1’ gem ‘sunspot_rails’ gem ‘sunspot_test’ 非常感谢,格雷姆

使用Sunspot查询具有不同属性的多个模型

我正在使用Sunspot来索引和搜索Rails项目中的几个模型,我需要根据模型的HABTM与Department模型的关联来限制结果。 这是因为用户可能没有权限查看所有部门的记录,因此不应返回这些部门的结果。 以下是两个模型的重要部分: class Message < ActiveRecord::Base has_many :comments, dependent: :destroy has_and_belongs_to_many :departments searchable do text :title, :body text :comments do comments.map(&:body) end date :created_at integer :department_ids, using: :department_ids, references: Department, multiple: true end end class Document < ActiveRecord::Base has_and_belongs_to_many :departments searchable do text :name date :created_at integer :department_ids, using: :department_ids, references: Department, multiple: true […]

太阳黑子轨道:在调用时提供相关模型。结果

假设我想在我的应用中搜索事件。 当我显示结果时,我想显示例如创建事件的人。 有没有办法在某处添加.includes(:user) ,以避免不必要的查询(每个事件一个)? 我在文档中找不到它。 我应该用事件索引用户名吗? 但我必须保持最新的用户信息… 谢谢

如何使用sunspot_rails gem搜索相关文章

我有一个迷你博客应用程序,我希望用户在文章显示页面中查看与他们正在阅读的内容相关的文章。 没有sunspot_railsgem,我会做这样的事情 在我的模型中 def self.related_search(query, join = “AND”) find(:all, :conditions => related_search_conditions(query, join)) end def self.related_search_conditions(query, join) query.split(/\s+/).map do |word| ‘(‘ + %w[name description notes].map { |col| “#{col} LIKE #{sanitize(‘%’ + word.to_s + ‘%’)}” }.join(‘ OR ‘) + ‘)’ end.join(” #{join} “) end 然后在我看来会是这样的 @article.related_search 但我想使用sunspot_rails gem让这种方式变得容易。 任何帮助。 谢谢