Hi Damon

To be honest, I’m not quite sure what the problem is - everything you’ve 
described thus far looks correct to me.

Perhaps one thing it’s worth trying is using an IF statement in your attribute 
definition, because MySQL’s boolean columns (boolean in Rails’ context, anyway) 
are integer values of 0 and 1, and that’s the same in Sphinx, so perhaps it’s 
worth returning an integer instead:

  has “IF(welcome_call_made IS NULL, 1, 0)”, :as => :need_welcome_call, :type 
=> :boolean

An alternative, though not as obvious when searching, is to have the column as 
a timestamp attribute, and NULL values will be stored as 0:

  has welcome_call_made

  Account.search :with => {:need_welcome_call => 0}

Hope this helps,

— 
Pat

> On 20 Feb 2016, at 4:29 AM, Damon Hill <[email protected]> wrote:
> 
> I have researched and read many posts on this and I thought I had found the 
> solution, but to no avail. 
> 
> I have several fields or attributes that can be null. A null value signifies 
> we need to perform some action on these entities, such as 
> "welcome_call_needed". Once the call is made, a timestamp for when the call 
> was made is added to the attribute. 
> 
> Here is my latest attempt at finding those attributes with null values. 
> 
> In my Account index file I have :
> 
> ThinkingSphinx::Index.define(:account,
>     :with => :active_record,
>     :delta => ThinkingSphinx::Deltas::DelayedDelta)  do
>   
>      ............
> 
>      has "welcome_call_made IS NULL", :as => :need_welcome_call, :type => 
> :boolean
> 
>      ............
> 
> end 
> 
> MySQL query as follows in the console: 
> 
> mysql> select count(*) from accounts WHERE welcome_call_made is NULL;
> +----------+
> | count(*) |
> +----------+
> |     3989 |
> +----------+
> 1 row in set (0.00 sec)
> 
> 
> The query from the Rails 3.2.8 Console produces:
> 
> irb(main):005:0> accounts = Account.search :with => { :need_welcome_call => 
> true }
> => []
> 
> I am using Thinking Sphinx 3.1.4 and Ruby 1.9.3-p547 along with Rails 3.2.8 
> and MySQL 5.6. I am certain I am missing something very elementary. Sphinx is 
> phenomenal and if I can get passed this last small hurdle it will have 
> greatly improved the performance/response time in our app.
> 
> Thanks again for the assistance and the code.
> 
> Damon 
> 
> 
> -- 
> 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] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/thinking-sphinx 
> <https://groups.google.com/group/thinking-sphinx>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.


-- 
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.

Reply via email to