lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrien Grand <>
Subject Re: IntField question
Date Wed, 10 Apr 2013 09:45:00 GMT

On Wed, Apr 10, 2013 at 9:34 AM, Wei Wang <> wrote:
> IntField inherits from Field class a function called setByteValue().
> However, if we call it, it gives an error message:
> java.lang.IllegalArgumentException: cannot change value type from Integer
> to Byte
> 1. If this not allowed for IntField, and there is no ByteField, how will
> function setByteValue() be used?

The rule is that if your Field instances wrap an object whose type is
XXX, you should only use the setXXXValue setter. Other setters will
throw an exception instead of performing automatic type conversions in
order to detect programming errors. This is why setByteValue threw an
exception on your IntField.

> 2. Will IntField automatically detect value range is small and use less
> space? I understand DocValuesField can save space by using variable length
> codec, but not sure about IntField.

They are very different:
 - A DocValues field stores one value per document ID.
 - An indexed field only stores distinct values, and associate with
every dictinct value the list of document IDs that contain this value
(this is called a postings list).

Indexed values are not compressed but the postings lists are, and the
compression ratio is better when postings lists are dense (with the
current default postings format at least). This makes indexed fields
(such as IntField) use less space when the number of dictinct values
is small.


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

View raw message