lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Trejkaz <>
Subject Re: Searching for Empty Field
Date Fri, 15 Jul 2011 06:10:03 GMT
On Fri, Jul 15, 2011 at 10:02 AM, Trieu, Jason T
<> wrote:
> Hi all,
> I read postings about searching for empty field with but did not find any cases of successful
search using query language syntax itself(-myField:[* TO *] for example).

We have been using:  -myField:*

You would need to use setAllowLeadingWildcard on the QueryParser and
it wouldn't exactly be fast, but it works for us.

The suggestion to use a magic token is a good idea, though I would put
it in a separate field called "has" or something... so you can do:

    has:title   (same results as title:* but quicker to run)

The crappy thing is that to actually detect if there are any tokens in
the field you need to make a TokenStream which can be used to read the
first token and then rewind again.  I'm not sure if there is such a
thing in Lucene at the moment.  We had to write it ourselves but we
were on a considerably older version at the time.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message