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 "MATL (Mats Lindberg)" <ma...@nnit.com> on 2004/10/06 22:27:21 UTC

how to find field that has any value

Hello
 
i have a probably simple question for some of you.
 
Since lucene does not allow a query to start with a wild card (* or ?)
how would i find all documents in lets say field test that has something
in that field, or is not empty.
 
my first thought would be to do something like this.
 
test:________                (cause the value ______ isn't very likely
to be present)
 
 
test:*                            (would be the correct way, i guess,
but lucene doesn't allow that)
 
 
does anyone have a greater idea.
 
Best regards,
Mats Lindberg

RE: how to find field that has any value

Posted by Aviran <am...@infosciences.com>.
You can try to use a range query something like test:[null TO
"zzzzzzzzzzzzzzzz"]
Please note that you might get TooManyBooleanClause Exception, if you have
too many of them.

The other thing you can use is with the operator NOT. For all the Empty
fields you can fill them with a string lest say "empty" and then query for
-test:empty

Aviran

-----Original Message-----
From: MATL (Mats Lindberg) [mailto:matl@nnit.com] 
Sent: Wednesday, October 06, 2004 16:27 PM
To: Lucene Users List
Subject: how to find field that has any value


Hello
 
i have a probably simple question for some of you.
 
Since lucene does not allow a query to start with a wild card (* or ?) how
would i find all documents in lets say field test that has something in that
field, or is not empty.
 
my first thought would be to do something like this.
 
test:________                (cause the value ______ isn't very likely
to be present)
 
 
test:*                            (would be the correct way, i guess,
but lucene doesn't allow that)
 
 
does anyone have a greater idea.
 
Best regards,
Mats Lindberg



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