lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chuck Williams <>
Subject Re: Soccer-themed question: null fields?
Date Sun, 18 Jun 2006 17:23:11 GMT

JMA wrote on 06/17/2006 10:16 PM:
> 1) Is there a way to find a document that has null fields?  
> For example, if I have two fields (FIRST_NAME, LAST_NAME) for World Cup players:
> FIRST_NAME: Agustin	LAST_NAME: Delgado
> FIRST_NAME: Zinha		LAST_NAME: (null or blank)
> FIRST_NAME: Kaka		LAST_NAME: (null or blank)
> ... and so on
> What's the way to find all players that use only their first name?

By far the best way is to store a special token into null fields and
then just match on this.

One less-performant alternative if you have no control over the index is
to enable prefix wildcard queries and then write a query like this:


To enable prefix wildcard queries, you need to regenerate from QueryParser.jj after replacing the wildcard
production (search for OG, as Otis has nicely included the appropriate
production as a comment).

> 2) Is there a way to count field terms?  For example, if instead we have one field...
> NAME: Brian McBride
> NAME: Agustin Delgado
> NAME: Zinha
> NAME: Kaka
> Can I answer the same question by finding all documents where the number of terms
> in the NAME field is 1 and only 1?  Is there a way to do that?

You would need to write your own Query subclass, and I can't think of
any way to achieve this that would not be very slow.  Not recommended.


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

View raw message