Can I search for a nil value?

76 views
Skip to first unread message

UnConundrum

unread,
May 29, 2012, 1:03:58 PM5/29/12
to Sunspot
Our invoicing system has billings that we convert into bills when they
are approved. Unbilled billings are identified by the absence of a
value in the bill_id field. I need to find those unbilled records.

I tried:

any_of do:
with :bill_id, nil
with :bill_id,""
end

but that didn't work. Can we search for a nil or empty value ?

Tom Cocca

unread,
May 29, 2012, 1:15:18 PM5/29/12
to ruby-s...@googlegroups.com
Hi,

with(:status_id, nil) has worked for me in the past.  Are you sure that you have records with a nil bill_id in your db/solr?

Also, what does your setup block look like?

~ Tom



--
You received this message because you are subscribed to the Google Groups "Sunspot" group.
To post to this group, send email to ruby-s...@googlegroups.com.
To unsubscribe from this group, send email to ruby-sunspot...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ruby-sunspot?hl=en.


UnConundrum

unread,
May 29, 2012, 4:46:43 PM5/29/12
to Sunspot
Yes, there are records in the index with a nil bill_id.

Is there a functional difference between "with(:bill_id, nil)" and
"with :bill_id, nil" ?

I'm not sure what a "setup block" is. If you mean the searchable
block, the provision for status_id is simply: integer :bill_id

Andy Lindeman

unread,
May 29, 2012, 4:49:49 PM5/29/12
to ruby-s...@googlegroups.com
On Tue, May 29, 2012 at 4:46 PM, UnConundrum <uncon...@gmail.com> wrote:
> Yes, there are records in the index with a nil bill_id.
>
> Is there a functional difference between "with(:bill_id, nil)" and
> "with :bill_id, nil" ?

No.

> I'm not sure what a "setup block" is.  If you mean the searchable
> block, the provision for status_id is simply:           integer :bill_id

Looks good to me.

--
Andy Lindeman
http://www.andylindeman.com/
Reply all
Reply to author
Forward
0 new messages