Hi,
I'm trying to do the same thing but still have an empty result
In my case:
has "LENGTH(has_countries) < 0", :as => :empty_countries, :type => :boolean
result = Digitalasset.search match_mode: :extended, :with =>
{:empty_countries => true}, page: page, per_page: per_page, :order =>
:updated_at, :sort_mode => :desc
Thanks in advance and sorry for my english.
Il giorno giovedì 13 gennaio 2011 21:28:12 UTC+1, Simon ha scritto:
>
> 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]
> <javascript:>.
> > > To unsubscribe from this group, send email to
> [email protected] <javascript:>.
> > > 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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/thinking-sphinx.
For more options, visit https://groups.google.com/d/optout.