Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 太阳黑子Solr:如何通过热门领域提升_Ruby On Rails_Solr_Sunspot - Fatal编程技术网

Ruby on rails 太阳黑子Solr:如何通过热门领域提升

Ruby on rails 太阳黑子Solr:如何通过热门领域提升,ruby-on-rails,solr,sunspot,Ruby On Rails,Solr,Sunspot,我在Solr中添加了一个“流行度”字段作为外部字段 “/solr/configsets/sunspot/conf/schema.xml” 通过在搜索参数中添加:boost解决了上述问题,如下所示: Item.solr_search do fulltext self.q do phrase_fields full_title: 16.0 # pf: full_title_text^16.0 phrase_slop 1 boost_fields ean:

我在Solr中添加了一个“流行度”字段作为外部字段

“/solr/configsets/sunspot/conf/schema.xml”


通过在搜索参数中添加:boost解决了上述问题,如下所示:

Item.solr_search do
  fulltext self.q do
    phrase_fields full_title:    16.0 # pf: full_title_text^16.0
    phrase_slop 1

    boost_fields ean:            8.0  # qf: ean_text^8.0
    boost_fields author_names:   2.0  # qf: author_names_text^2.0
    boost_fields publisher_name: 2.0  # qf: publisher_name_text^2.0
  end

  adjust_solr_params do |params|
    params[:boost] = "popularity_score"
  end
end
结束

<?xml version="1.0" encoding="ISO-8859-1"?>

<response>
   <lst name="responseHeader">
      <int name="status">0</int>
      <int name="QTime">21</int>
   </lst>
   <result name="response" numFound="7626" start="0" maxScore="21.75">
      <doc>
         <str name="id">Item 9788770781701</str>
         <float name="score">21.75</float>
      </doc>
      <doc>
         <str name="id">Item 9781449661373</str>
         <float name="score">19.0</float>
      </doc>
      <!-- ... -->
   </result>
</response>
class Item < ActiveRecord::Base
  searchable include: [:authors, :publisher, :order_temporary_stock] do
    text :ean
    text :full_title
    text :author_names
    text :publisher_name

    # ...
  end
end
Item.solr_search do
  fulltext self.q do
    phrase_fields full_title:    16.0 # pf: full_title_text^16.0
    phrase_slop 1

    boost_fields ean:            8.0  # qf: ean_text^8.0
    boost_fields author_names:   2.0  # qf: author_names_text^2.0
    boost_fields publisher_name: 2.0  # qf: publisher_name_text^2.0

    # boost(popularity) 
  end

end
Item.solr_search do
  fulltext self.q do
    phrase_fields full_title:    16.0 # pf: full_title_text^16.0
    phrase_slop 1

    boost_fields ean:            8.0  # qf: ean_text^8.0
    boost_fields author_names:   2.0  # qf: author_names_text^2.0
    boost_fields publisher_name: 2.0  # qf: publisher_name_text^2.0
  end

  adjust_solr_params do |params|
    params[:boost] = "popularity_score"
  end
end