我想使用more_like_this
搜索我的文章,我的控制器代码如下所示。还查看了at this post,并使用ry /solr/select
参数尝试了mlt=on
,但它也不起作用:
article = Article.find(params[:id])
@search = Sunspot.more_like_this(article) do
fields :title
minimum_term_frequency 1
adjust_solr_params do |params|
params["mlt.match.include"] = true
params["mlt"] = 'on' # doesn't work
params["mlt"] = true # doesn't work
end
end
请求处理程序也在我的solrconfg.xml
<requestHandler class="solr.MoreLikeThisHandler" name="/mlt">
<lst name="defaults">
<str name="mlt.mintf">1</str>
<str name="mlt.mindf">2</str>
</lst>
</requestHandler>
日志:
RSolr::Error::Http (RSolr::Error::Http - 404 Not Found
Error: <html><head><title>Apache Tomcat/6.0.39 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - /solr/mlt</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>/solr/mlt</u></p><p><b>description</b> <u>The requested resource is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.39</h3></body></html>
URI: http://localhost:8888/solr/mlt?wt=ruby
Request Headers: {"Content-Type"=>"application/x-www-form-urlencoded; charset=UTF-8"}
Request Data: "fq=type%3AArticle&mlt.mintf=1&q=id%3AArticle%5C+2144&mlt.fl=title_textv&start=0&rows=30&mlt.match.include=true"
Backtrace: /home/chuhai/shared/bundle/ruby/2.2.0/gems/rsolr-1.0.12/lib/rsolr/client.rb:284:in `adapt_response'
/home/chuhai/shared/bundle/ruby/2.2.0/gems/rsolr-1.0.12/lib/rsolr/client.rb:190:in `execute'
/home/chuhai/shared/bundle/ruby/2.2.0/gems/rsolr-1.0.12/lib/rsolr/client.rb:176:in `send_and_receive'
/home/chuhai/shared/bundle/ruby/2.2.0/gems/sunspot_rails-2.2.0/lib/sunspot/rails/solr_instrumentation.rb:16:in `block in send_and_receive_with_as_instrumentation'
/home/chuhai/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/notifications.rb:164:in `block in instrument'
/home/chuhai/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/chuhai/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/notifications.rb:164:in `instrument'
/home/chuhai/shared/bundle/ruby/2.2.0/gems/sunspot_rails-2.2.0/lib/sunspot/rails/solr_instrumentation.rb:15:in `send_and_receive_with_as_instrumentation'
(eval):2:in `post'
/home/chuhai/shared/bundle/ruby/2.2.0/gems/sunspot-2.2.0/lib/sunspot/search/abstract_search.rb:49:in `execute'
/home/chuhai/shared/bundle/ruby/2.2.0/gems/sunspot-2.2.0/lib/sunspot/search/more_like_this_search.rb:16:in `execute'):
app/controllers/api/v1/articles_controller.rb:9:in `search'
lib/cors.rb:7:in `call'
lib/cors.rb:7:in `call'