lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Les Fletcher <>
Subject Re: query syntax question
Date Thu, 10 May 2007 20:29:47 GMT
Would a good solution be to insert a secret string into blank fields 
that represents blank.  That way you could search for:

firstname:(-Xd8fgrSjg) lastname:(-Xd8fgrSjg) some query string


Les Fletcher wrote:

> I like the idea of the filter since I am making heavy use of filters 
> for this particular query, but how would one go about constructing it 
> efficiently at query time?  All I can see is hacking around not being 
> able to use the * as the first character.
> Les
> Erick Erickson wrote:
>> You could create a Lucene Filter that had a bit for each document that
>> had a first or last name and use that at query time to restrict your
>> results appropriately. You could create this at startup time or at
>> query time. See CachingWrapperFilter for a way to cache it.
>> Another approach would be to add a dummy field to each document,
>> something like HASFIRSTORLASTNAME. At index time, when
>> you index a document, if it has a first or last name, put "yes" in the
>> field. Otherwise, put "no".
>> Then, at search time, add an +HASFIRSTORLASTNAME:yes to the
>> query......
>> You could add as many states to this field as you want.
>> Erick
>> On 5/10/07, Les Fletcher <> wrote:
>>> I have a question about empty fields.  I want to run a query that will
>>> search against a few particular fields for the query term but then also
>>> also check to see if a two other fields have any value at all.  i.e., I
>>> want to search for a set records but don't want to return a record if
>>> that record has blank first and last name fields.  Any help would be
>>> greatly appreciated.
>>> Les
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail:
>>> For additional commands, e-mail:
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message