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 8037171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:50:50+00:00 2026-06-05T02:50:50+00:00

In my project am trying to display products based on user choice. User can

  • 0

In my project am trying to display products based on user choice. User can check which department(women, men and kids) and category (dress, tops, tees etc) they wish to see. For this am using check box. If user checks(selects) only women departments they all products which belongs to women will be displayed. If user checks(selects) both women department and dress category then the products which belongs to both women department and dress category will be displayed. If user selects both women and men departments and shoes category then all products which belongs to women and men department and shoes category will be displayed. To achieve this am using solr (sunspot gem). My question is can we pass multiple ids for department_id and category_id at the same time.

For example is it possible to

@search_res=ProductDetail.search do
  with :department_id, 1,2,3                  
  with :category_id, 1,2,3,4, etc (may be present or absent)           
end

If it is possible please tell me how to do? Please give me syntax? Please help me.

Update

Thank you Salil for your answer, but department id and category id’s are not static in this case. I will came to only when user selects at runtime. Means category_id and department_id’s are generic. How to achieve this. I want something like this

@search_res=ProductDetail.search do
  with :department_id, params[:deptid]                  
  with :category_id,   params[:catid]         
end

Please help me.

  • 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-05T02:50:52+00:00Added an answer on June 5, 2026 at 2:50 am

    Here it is:

    @search_res=ProductDetail.search do
      all_of do
        with :department_id, [1,2,3]                  
        with :category_id, [nil,1,2,3,4] # I am not sure - but category_id nil should be to denote its absence 
      end
    end
    

    Refer for more info:
    sunspot readme

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

Sidebar

Related Questions

I'm trying to create a Visual Studio Integration Package project which will display data
I'm working on a Pyramid project using Mako templates, and I'm trying to display
I'm trying to put together a new app for a project that will display
Stuck on the first stage of a big project. I am trying to display
In my project I'm trying to display several image files by manipulating the filename
I'm currently trying to display some information (as an overlay) to the user inside
I'm trying to create a web based welcome display for a building entrance. The
I am trying to display a flot generated chart in a jQuery Mobile project.
i am now trying to display my arcgis map from c# silverlight application project
I am trying to display the output of this find - @test = User.joins(:plans

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.