Add short and byte numeric bridges

Description

when indexing a collection of short value using the @IndexedEmbedded + @NumericField + @Field annotation combination, it will return the expected NumericIterableBridge.

though when indexing a short value using the @NumericField + @Field annotation combination no bridge is associated with.

here's my understanding of the issue :

when guessing type in org.hibernate.search.bridge.impl.BridgeFactory::guessNumericFieldBridge, it will return null, and then throw

throw new SearchException( "Unable to guess FieldBridge for " + member.getName() );

since there's no ShortNumericBridge type exists.

i guess the correct implementation of the non-existing ShortNumericBridge would be :

public class ShortNumericFieldBridge extends NumericFieldBridge { public Object get(String name, Document document) { return Short.valueOf(document.getFieldable(name).stringValue()); } }

then add we would need to do is add the new implementation into the static numericField map.

seem a nice addition to me, or is there something i missed somewhere ?

thanks

Activity

Show:

Gunnar Morling January 21, 2015 at 10:10 AM

Sanne Grinovero December 1, 2011 at 5:52 PM

Hi Mathieu,
thanks yes that would be nice to add.

One warning though: the combination of possible terms in a short is so limited that using a NumericField is likely overkill, a traditional conversion in String would perform better: in fact Lucene doesn't support conversion from short either, I'll need to convert it at least to an integer.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Priority

Created December 1, 2011 at 5:03 PM
Updated October 31, 2017 at 12:33 PM
Resolved January 22, 2015 at 6:37 PM