lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrzej Bialecki>
Subject Re: arrays of values in a field
Date Wed, 28 Jan 2004 10:37:41 GMT
Erik Hatcher wrote:
> On Jan 27, 2004, at 2:27 PM, Gabe wrote:
>> If I have a group of documents and I want to filter on
>> a category, it is fairly straightforward. I just
>> create a Field that contains the category and filter
>> on it.
>> However, what if I want the field "category" to have
>> multiple possible values? Is there a known best way to
>> filter on that?
>> I imagine it is possible to "hack" it by, say,
>> creating a field with value:
>> |category1|category2|category3| etc.
>> And then query "|category1|"
>> I was wondering if there was a better way.
> Simply add multiple (probably Keyword) fields with the same name.  
> Lucene supports this nicely.

There are other tricks you can use here, too... In one of my projects I 
had a need to store a list of weighted keywords. No problem storing 
multiple tokens under the same field name, as Erik explained above. 
However, in Lucene you can only apply a single boost value to a field. I 
ended up encoding the keywords like "10.0 keyword" and then writing an 
analyzer which skips the initial numbers when processing this particular 
field (which was stored, indexed and tokenized).

Best regards,
Andrzej Bialecki

Software Architect, System Integration Specialist
CEN/ISSS EC Workshop, ECIMF project chair
EU FP6 E-Commerce Expert/Evaluator
FreeBSD developer (

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

View raw message