问题标签 [sunspot-rails]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
ruby-on-rails - 未定义的方法“关闭?” 对于 nil:NilClass Ruby on Rails 太阳黑子
我花了超过 24 小时试图弄清楚我在这里做错了什么。你能帮忙吗?这就是我所拥有的。
歌词控制器.rb
歌词.rb(模型)
在我看来,我有一个像这样的搜索表单。
当我尝试搜索时出现错误
LyricsController#index 中的 NoMethodError 未定义方法“已关闭?” 对于 nil:NilClass Rails.root: /Users/sigidis/Ruby/stagesong
应用程序跟踪 | 框架跟踪 | 完整跟踪 app/controllers/lyrics_controller.rb:10:in `index'
这是日志。
开始 GET "/lyrics?utf8=%E2%9C%93&search=Soweto" for 127.0.0.1 at Sat Sep 17 11:37:04 +0200 2011 弃用警告:class_inheritable_attribute 已弃用,请改用 class_attribute 方法。请注意它们的行为略有不同,因此请先参阅 class_attribute 文档。(从 /Users/sigidis/Ruby/stagesong/app/models/lyric.rb:10 调用) 弃用警告:不推荐使用 class_inheritable_attribute,请改用 class_attribute 方法。请注意它们的行为略有不同,因此请先参阅 class_attribute 文档。(从 /Users/sigidis/Ruby/stagesong/app/models/lyric.rb:10 调用)由 LyricsController#index 处理为 HTML 参数:{"utf8"=>"\342\234\223", "search"= >“Soweto”} 在 2 毫秒内完成 500 内部服务器错误
NoMethodError(未定义的方法closed?' for nil:NilClass):
app/controllers/lyrics_controller.rb:10:in
索引'
渲染 /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.9ms) 渲染 /Library/Ruby/Gems/1.8/gems/actionpack-3.1 .0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.7ms) 渲染 /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/diagnostics。救援/布局中的 erb (3.1ms)
我不确定我做错了什么。有人可以帮忙吗。
也试过这个
http://collectiveidea.com/blog/archives/2011/03/08/full-text-searching-with-solr-and-sunspot/
ruby-on-rails - 使用太阳黑子/solr 搜索表单
我第一次使用太阳黑子,我正在尝试设置搜索。全文搜索似乎工作正常。但是,我有一个带有搜索框和用户可以选择的布尔字段上的多个过滤器的表单。不知何故,搜索框工作正常,但 solr 没有将单个布尔值作为附加过滤器。另外,当我不做任何搜索文本而只想通过布尔字段进行搜索时,什么也没有发生。任何帮助,将不胜感激:
这是我的控制器:
我在模型中有字段:
我的观点如下:
ruby-on-rails - Rails Sunspot gem: Usings facets with multiple model site-wide searches
I'm trying to implement a sitewide search through the powerful Sunspot gem for Rails. This involves a search across multiple, very different models at once. What I WANT to do is use the faceting feature to allow the user to filter their search results on each model, or by default view all on the same page, interspersed with each other ordered by the :boost qualifier. Combining the faceting code from the Sunspot Railscast with the multiple model searching code from another Stackoverflow question (a variation upon the 'Multiple Type' code from the Sunspot documentation) gave me a solution that I'd think would work, but doesn't.
The multiple method search succeeds, but the facets always turn up null. My basic approach is to provide a virtual attribute on each model by the same name, :search_class, that is just the model's class name rendered into a string. I then try and use that as a facet. However, in the view logic the results of the facet (@search.facet(:search_class).rows) is always an empty array, including when @search.results returns many different models in the same query, despite each returned instance having a perfectly accessible Instance.search_class attribute.
I'm using Rails 3.1.0 and sunspot-rails 1.2.1.
What should I do to make this faceting code work?
Controller:
Models:
View:
ruby-on-rails - Sunspot Rails - 用户可以更改要搜索的字段吗?
我开始使用 Sunspot 在我的 Rails 3 应用程序中执行搜索,但我遇到了疑问。有没有一种方法可以让用户选择他/她想要搜索的字段。例如,在我的应用程序中,我们有:
在查看默认搜索栏中:
我可以添加一个单选按钮或类似的东西,以便用户可以标记它以便仅按名称、内容或关键字进行搜索?如果是,我该怎么做?
非常感谢。
ruby-on-rails - 如何在测试环境中为 Time 类未定义“解析”,而不是开发或生产?
我在运行测试(Steak + Capybara)时遇到了一个奇怪的问题,该测试请求了我收到错误的某个页面:
undefined method parse for Time:Class
方法调用发生在名为的 Sunspot 文件中type.rb
:
当我在 中运行我的服务器时RAILS_ENV=test
,我得到了同样的错误。当我在开发中运行服务器时,一切都很好。这似乎表明它不仅仅是我的测试框架,而是整个测试环境都在促进这个错误。
到目前为止,我能在网上找到的关于Time.parse
未定义的唯一信息非常无用,大多数人都说添加require 'time'
将解决问题。
我的问题是双重的:
- 这很骇人听闻
- 我已经在不同的地方(在
config/environments/test.rb
测试文件本身等)尝试过它,但它只是不起作用。
如果有人对发生了什么有任何想法,我欢迎他们!
ruby-on-rails - 如何在 Dreamhost 上使用 Capistrano 设置太阳黑子
我已经阅读了之前在 SO 上提出的类似问题的答案,但无法做出正面或反面。我安装了 suspot_rails gem 并按照其他步骤使用 railscast (http://railscasts.com/episodes/278-search-with-sunspot) 上提到的说明在我的本地盒子上设置太阳黑子。我的个人网站 ( http://www.dahotre.com ) 托管在 Dreamhost 上,我需要设置太阳黑子。我一直在使用 Capistrano 通过一个简单的命令将东西部署到生产环境:cap deploy。任何人都可以列出请列出我需要执行的步骤,以使用此设置将 solr 部署到生产环境。我知道我需要为 solr 创建一个在生产中存在的地方,因为 sunspot.yml 文件说:
full-text-search - 如何在数据库中识别和保存关键字并稍后在rails 3.1中检索它
我正在开发一个 Rails 3.1 应用程序,我必须在其中实现以下逻辑。
1) 提供搜索框 2) 用户在搜索框中输入他们的查询 3) 如果查询不存在于数据库中,则用户将查询保存在数据库中 4) 如果找到匹配的查询,则将其检索并显示给用户。
我是搜索业务的新手,需要一些关于如何识别用户在查询中输入的关键字的指导?有没有可以做到这一点的宝石?
我正在使用太阳黑子进行搜索,如何自定义太阳黑子以使在搜索框中输入的文本可搜索?
谢谢,
ruby-on-rails - 太阳黑子和 RSpec 失败。提交似乎不起作用
我已经为 Rails 站点使用 RSpec 运行了一些测试,但是尽管遵循了说明,但事情并没有完全正常运行。
我通过工厂创建了一篇文章,运行 Sunspot.commit 然后检查结果。不过,我似乎总是画一个空白。当我通过控制台或通过网站手动测试它时,它都可以找到。
有任何想法吗?如何输出太阳黑子日志以查看发生了什么?
我的 Gemfile 有以下内容,我正在运行 Rails 3.1.1
非常感谢,格雷姆
ruby-on-rails-3 - 太阳黑子搜索 order_by 错误 - 目标列未排序
我在 Ruby on Rails 3.1 中实现了一个非常基本的 Sunspot solr 搜索。我使用整数列上的 order_by 参数在我的 Idea 模型上调用 search,但结果集没有排序。
controller.rb 中的搜索语句:
在 Idea.rb 中搜索规范:
当我遍历@idea_search_res 结果集并打印出 num_users_joined 时,我得到类似 [4,2,3,1] 的内容。
谢谢
ruby-on-rails-3 - getaddrinfo: Name or service not known with solr sunspot
I'm attempting to run solr and sunspot with rails 3.1, but I keep getting the error
my controller is fairly basic
I'm still not quite sure about what is going on here. do I have to start a separate solr service?
When I run rake sunspot:solr:run, I get a
which is a bit disconcerting, but as the output says, the server is already running, so I think it is working.
Any suggestions on what I may be doing wrong, or how to fix this?