You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Patrick <pa...@gmail.com> on 2008/07/02 23:25:23 UTC

Match all documents with non empty field

Hi,

Can't seem to wrap my head around how to go about it.

I want to retrieve all documents where a certain field in not empty.

What would be the best way to do it?

Should I search with a MatchAllDocQuery and a Filter?

Should I go through all terms in the field and create a TermQuery with it?

Many thanks.

Patrick

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Match all documents with non empty field

Posted by Erick Erickson <er...@gmail.com>.
You can certainly use a filter and MatchAllDocs. You can also
index a special value for the field in question (nothere) and
combine MatchAllDocs with a NOT field:nothere or some such.

Best
Erick

On Wed, Jul 2, 2008 at 5:25 PM, Patrick <pa...@gmail.com> wrote:

> Hi,
>
> Can't seem to wrap my head around how to go about it.
>
> I want to retrieve all documents where a certain field in not empty.
>
> What would be the best way to do it?
>
> Should I search with a MatchAllDocQuery and a Filter?
>
> Should I go through all terms in the field and create a TermQuery with it?
>
> Many thanks.
>
> Patrick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: Match all documents with non empty field

Posted by Mark Miller <ma...@gmail.com>.
Daniel Noll wrote:
> Patrick wrote:
>> Hi,
>>
>> Can't seem to wrap my head around how to go about it.
>>
>> I want to retrieve all documents where a certain field in not empty.
>>
>> What would be the best way to do it?
>
> The most trivial way would be to use a PrefixQuery with an empty string.
>
> It won't be efficient unless you wrap it in a QueryFilter to cache the 
> result, but I found it to be "fast enough" even for relatively large 
> document sets.
>
> Daniel
>
>
Also, search the archive...I think there is something you can do like 
*:* NOT [* TO *]

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Match all documents with non empty field

Posted by Daniel Noll <da...@nuix.com>.
Patrick wrote:
> Hi,
> 
> Can't seem to wrap my head around how to go about it.
> 
> I want to retrieve all documents where a certain field in not empty.
> 
> What would be the best way to do it?

The most trivial way would be to use a PrefixQuery with an empty string.

It won't be efficient unless you wrap it in a QueryFilter to cache the 
result, but I found it to be "fast enough" even for relatively large 
document sets.

Daniel


-- 
Daniel Noll

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org