Match all documents with non empty field

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Match all documents with non empty field

Patrek
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Match all documents with non empty field

Erick Erickson
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 <[hidden email]> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Match all documents with non empty field

Daniel Noll-3-2
In reply to this post by Patrek
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Match all documents with non empty field

Mark Miller-3
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: [hidden email]
For additional commands, e-mail: [hidden email]