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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:09:38+00:00 2026-06-14T20:09:38+00:00

I see no reason why this shouldn’t work, but I get no results. A

  • 0

I see no reason why this shouldn’t work, but I get no results. A Contact has many OrganizationContacts. And OrganizationContact has a boolean field primary. I’ve added a filter on this field as shown below.

class Contact < ActiveRecord::Base

  has_many :organization_contacts, :dependent => :destroy

  define_index do
    has organization_contacts(:primary), :as => :primary_contacts

    set_property :delta => true
  end
end

In a debugging session I can see that I do indeed have a Contact with an OrganizationContact that is listed as primary:

(rdb:1) p Contact.first.organization_contacts.first.primary
true

But if I do a ThinkingSphinx search using that filter, I get nothing:

(rdb:1) p Contact.search :with => { :primary_contacts => true }
[]

Can anyone explain?

  • 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-14T20:09:38+00:00Added an answer on June 14, 2026 at 8:09 pm

    Crickets chirp. Alas, we came up with a work around.

    class Contact < ActiveRecord::Base
    
      has_many :primary_organization_contacts, :class_name => "OrganizationContact", :foreign_key => "contact_id", :conditions => { :primary => true }
      has_many :organization_contacts, :dependent => :destroy
    
      define_index do
        has primary_organization_contacts(:id), :as => :primary_organization_contacts
    
        set_property :delta => true
      end
    end
    

    Searching for them is the interesting part. If I want records with no primary organization contacts:

    Contact.search :with { :primary_organization_contacts => 0 }
    

    If I want records with at least one primary organization contact:

    Contact.search :without { :primary_organization_contacts => 0 }
    

    It makes me feel dirty and confused but it does the job.

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

Sidebar

Related Questions

I see no reason why this shouldn't work in all browsers, here is my
I'm at a loss, I can't see the reason something as simple as this
Is there any conceivable reason why I would see different results using unicode string
For some reason my bind events won't work. You can see my code here:
My application built with Google App Engine has this page that displays search results
Can you see any reason why this would display 0 %ConnectDirectExe% -f%ConnectDirectCredentials% < %CurrentCDConfigFile%
I encountered ConcurrentModificationException and by looking at it I can't see the reason why
I am having problems using the update method of scala.collection.immutable.HashMap.I don't see the reason
What does IEquatable<T> buy you, exactly? The only reason I can see it being
Is there a good reason why this program compiles under GCC even with the

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.