简体   繁体   中英

How to return search results with Sunspot and Solr in rails app?

I am having some trouble with Sunspot and Solr. When I pass a parameter, I'm getting no results. I've included in the comments at 2 points in the code.

I've confirmed that there is also data in the Review table in my db and that the string does occur in the records.

Any advice on how to return the search results?

    puts "search query is #{params[:search]}"   //returns search query 
    if params[:search]
        @search = Review.search do
            fulltext params[:search]
        end
        puts "search results are #{@search.results}"   //returns []
        @reviews_search_results = @search.results
    end

Get the search result using

@result = @search.results

Take a look at this railscasts tutorial

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM