rongerZeng
rongerZeng

Reputation: 21

ruby on rails with sunspot: when search query by solr return no result

I use sunspot in rails project to support search service, but when I search a query, in project web page return no result. enter image description here

and when I search by local solr service,it can return correct result. enter image description here

I check project log,I find when search a query,the index field add "text" suffix,why it add a suffix, because of sunspot packaging??? log: SOLR Request (31.2ms) [ path=select parameters={fq: ["type:OpenSourceProject", "-filtration_i:0"], sort: "score desc", q: "rails", fl: "* score", qf: "name_text^4.0 tags_for_search_text^3.0 description_text^0.5 tags_text^1.0 language_text^1.0", defType: "edismax", bf: ["log(composite_score_i)^1000"], start: 0, rows: 10} ] Rendered open_source_projects/_search_bar.html.erb (1.6ms)

the sunspot.yml configurations:

production:
solr:
    hostname: localhost
    port: 8080
    log_level: WARNING
    path: /solr/production1

solr version: 5.2.1 gemfile:

gem 'sunspot_rails', '2.2.0'
gem 'sunspot_solr', '2.2.0'
gem 'will_paginate'
gem 'progress_bar

model search block:

searchable do
    text :name, :stored => false
    text :tags, :stored => false
    text :tags_for_search, :stored => false
    text :language, :stored => false
    text :description, :stored => false

    integer :filtration
    integer :composite_score
    integer :relative_memos_num

end

controller search:

search = OpenSourceProject.search do
    without(:filtration,0)
    all do
      fulltext language do
        fields(:tags)
        fields(:language)
      end
      fulltext search_words do
        #highlight(:name)
        fields(:name)
        fields(:tags_for_search)
        fields(:description)
        fields(:tags)
        fields(:language)
        boost_fields :name => 4.0
        boost_fields :tags_for_search => 3.0
        boost_fields :tags => 1.0
        boost_fields :description => 0.5
        boost_fields :language => 1.0
        boost(function { log(:composite_score)^1000 })
      end            
    end
    if "".eql?(search_words)
      order_by(:composite_score, :desc)
    else
      order_by(:score, :desc)
    end
    paginate :page => params[:page], :per_page => 10
  end
  per_page_option = 10
  @hits = search.hits
  @open_source_projects = search.results
  @projects_count = search.total #get total count of search

it's very weird,is related to solr version? Can somebody please explain why this is happening and how I can fix it.thanks!

Upvotes: 0

Views: 713

Answers (0)

Related Questions