Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9128565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:32:42+00:00 2026-06-17T07:32:42+00:00

This should be simple but I can’t get it to work. I would like

  • 0

This should be simple but I can’t get it to work.

I would like to retrieve all products which are published.

The following code is working, and only published products are returned:

@products = Product.search do
  with(:published, true)
  with(:facet_tag).all_of(facets) unless facets.nil?
  fulltext q do
  end
  facet :facet_tag
  paginate :page => 1, :per_page => 8
end

When I remove the full text part it doesn’t return any results at all.

I would like the following code to return all published products, but the code returns no results at all. @products.results becomes nil.

@products = Product.search do
  with(:published, true)
  with(:facet_tag).all_of(facets) unless facets.nil?
  facet :facet_tag
  paginate :page => 1, :per_page => 8
end

How should I get all published products from sunspot?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:32:43+00:00Added an answer on June 17, 2026 at 7:32 am

    The presented code in the question is working. The problem arose from changes which I done to the solrconfig file. I had added a requestHandler which I called edismax. I was assuming that sunspot was using it since was set to be the default request handler and that full-text search was working.

    Sunspot is instead expecting a request handler which is called dismax and becasue no such request handler was configured it failed to retrieve all document since Solr didn’t understand the : search query.

    Actually this should not be a problem at all since Sunspot aims to be a complete abstraction of Solr and no changes to the solr config files should be needed. Sunspot is not there yet when it comes to a bit more advanced usage of Solr so changes is often needed. Luckly it’s possible to change the solr parameters with the adjust_solr_params function.

    I solve the problem by changing the code to:

    @products = Product.search do   
      with(:published, true)
      with(:facet_tag).all_of(facets) unless facets.nil?
      fulltext q do
      end
      adjust_solr_params do |p|       
        p[:'defType'] = 'edismax'     
      end
      facet :facet_tag
      paginate :page => 1, :per_page => 8
    end
    

    This way I’m asking solr to used the edsimax query parser instead of the dismax query parser.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this should be so simple but I can't get it to work, all I
This should be a simple question, but I can't get it to work :(
This seems like it should be very simple but I can't get it to
This should be really simple but I can't get it to work, how do
This seems like something simple but I can't seem to get it to work.
This seems like it should be simple but I can't work out how to
This should be simple, but i can't get it to work. I want to
This should be simple, but I can't get it to work when the 'trigger'
I feel like this should be simple but i can't work out how to
This should be simple, but I can't get it to work. I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.