matching all documents in which a field is defined

6 views
Skip to first unread message

Ed Phillips

unread,
Mar 29, 2011, 7:50:24 PM3/29/11
to ruby-s...@googlegroups.com
Hello,

I have a rather simple question. The answer was not immediately obvious after
looking at the docs and a cursory search of the mailing list archives,
hence the question.

Solr provides some ways of querying for all documents in which a field
is present such as "field_name:[* TO *]", or for all documents such as the
"*:*" query.

What are the Sunspot practices and/or idioms for such queries?

Thank you.


Matthew A. Brown

unread,
Mar 30, 2011, 4:28:13 PM3/30/11
to ruby-s...@googlegroups.com, Ed Phillips
Hey Ed,

Mildly unintuitive, perhaps, but just do:

without(:field_name, nil)

Mat

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

Matthew A. Brown

unread,
Mar 30, 2011, 6:26:50 PM3/30/11
to ruby-s...@googlegroups.com

Hi Ed,

It's perhaps mildly unintuitive, but you can just do:

    without(:field_name, nil)

Since Sunspot interprets nil in a filter as "has no indexed value".

Mat

Ed Phillips

unread,
Mar 30, 2011, 6:37:02 PM3/30/11
to Matthew A. Brown, ruby-s...@googlegroups.com
Thank you. I did not try that yet! Unintuitive, perhaps, but terse
enough.

Cheers,

Ed

Reply all
Reply to author
Forward
0 new messages