Any idea? On Jan 13, 11:48 am, rtacconi <[email protected]> wrote: > this is my index in Project model: > > define_index do > indexes name > indexes summary > indexes description > indexes phone > indexes email > indexes website > indexes climate_zone > indexes city > indexes address > indexes state > indexes post_code > indexes country > indexes project_type > > has created_at > has show, :type => :boolean > has paid, :type => :boolean > has lat, lng > has "COUNT(DISTINCT courses.id) > 0", :as => :has_courses, :type > => :boolean > # join courses > > indexes posts.created_at, :as => :posts, :sortable => true > set_property :delta => true > end > > And I have this inside the Project model too: > > has_many :courses > > With 'join courses' commented I do not get the segmentationfault > error > On Jan 4, 1:07 am, "Pat Allan" <[email protected]> wrote: > > > > > > > > > Sphinx has no concept of the number of values (no COUNT() function), so > > you'll need to create an attribute for that purpose: > > > has "COUNT(DISTINCT courses.id) > 0", :as => :has_courses, :type => > > :boolean > > join courses # if you're not referring to the association elsewhere > > > And then your search would be: > > > Project.search :with => {:paid => true, :has_courses => true} > > > Cheers > > > -- > > Pat > > > On 04/01/2012, at 5:52 AM,rtacconiwrote: > > > > Hi, > > > > I have a project model which has a filter: > > > > has paid, :type => :boolean > > > > If paid checkbox is flagged, sphinx searches for paying projects. the > > > problem is that some projects have not any course: > > > > project.courses.count # returns 0 > > > > I there a way to search for paying projects having at least one > > > course? > > > > paid => true and projects.courses.count > 0 > > > > at the moment I have paid sent in the conditions > > > > A solution could be to add a field set to true if its courses are more > > > than zero, but it is a redundant information > > > > -- > > > You received this message because you are subscribed to the Google Groups > > > "Thinking Sphinx" group. > > > To post to this group, send email to [email protected]. > > > To unsubscribe from this group, send email to > > > [email protected]. > > > For more options, visit this group > > > athttp://groups.google.com/group/thinking-sphinx?hl=en.
-- You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
