Clever. Thanks for the help! Simon
On Jan 13, 2:33 am, Pat Allan <[email protected]> wrote: > Hi Simon > > Sphinx has no concept of searching for empty fields. I think a better option > would be to add an attribute indicating whether the specific column is blank: > > has "LENGTH(body) < 0", :as => :empty_body, :type => :boolean > > That should work for MySQL - for PostgreSQL, I think the function is > char_length. > > And then in searches, you can do the following: > > Article.search :with => {:empty_body => true} > > Add another attribute for the title as well, and then you can use that filter. > > Hope this helps. > > -- > Pat > > On 11/01/2011, at 1:10 PM, Simon wrote: > > > Hi there, > > > I am trying to search for empty strings, and am getting back no > > results. I am indexing two values, title and body, in my define_index > > block. I am then trying to something along the lines of > > Article.search :conditions => {:body => ""} but I get back no > > results. I know there are indexed entries with blank bodies, so I > > feel I must be missing something here. > > > If this is possible and I get it going, I would also like to be able > > to search for Articles with both blank bodies and titles. Can I just > > add both fields into the conditions hash? Will this get treated as an > > AND condition? > > > Thanks, > > > Simon > > > -- > > 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.
