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

  • SEARCH
  • Home
  • 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 716029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:15:13+00:00 2026-05-14T05:15:13+00:00

Is it possible to index through an association with Sunspot? For example, if a

  • 0

Is it possible to index through an association with Sunspot?

For example, if a Customer has_many Contacts, I want a ‘searchable’ block on my Customer model that indexes the Contact#first_name and Contact#last_name columns for use in searches on Customer.

acts_as_solr has an :include option for this. I’ve simply been combining the associated column names into a text field on Customer like shown below, but this doesn’t seem very flexible.

searchable do
text :organization_name, :default_boost => 2
text :billing_address1, :default_boost => 2
text :contact_names do
  contacts.map { |contact| contact.to_s }
end

Any suggestions?

  • 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-05-14T05:15:13+00:00Added an answer on May 14, 2026 at 5:15 am

    That’s exactly how to do it. Solr is essentially document-oriented, so any data that comes from associations in your database is flattened down into your document. An :include option is just mild sugar which ends up doing the same thing that you do here.

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

Sidebar

Related Questions

Is there a possible htaccess directive that can transparently forward request from index.php to
Is it possible to find the foreach index? in a for loop as follows:
I am wondering if it is possible to extract the index position in a
Wondering if it would ever be useful to index every possible state of an
Possible duplicates: UDP Response or Receiving a response through UDP I've been writing a
Is it possible to pass mouse clicks through an overlaying element: <div style=background: url('img/rain.png');
I currently have a model that the user can upload a thumbnail to the
Possible Duplicate: Div Z-Index issue with Flash movie Okay, is there a way to
I currently have a simple app that includes user authentication through devise and a
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should

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.