protected Field createIndexField ( String key , Object value ) { if ( key == null || value == null ) { return null ; } if ( value instanceof Boolean ) { return new IntPoint ( key , ( ( Boolean ) value ) . booleanValue ( ) ? 1 : 0 ) ; } if ( value instanceof Character ) { return new StringField ( key , value . toString ( ) , Store . NO ) ; } if ( value instanceof Byte || value instanceof Short || value instanceof Integer || value instanceof Long ) { Number v = ( Number ) value ; return new LongPoint ( key , v . longValue ( ) ) ; } if ( value instanceof Float || value instanceof Double ) { Number v = ( Number ) value ; return new DoublePoint ( key , v . doubleValue ( ) ) ; } if ( value instanceof Date ) { return new StringField ( key , DateFormatUtils . toString ( ( Date ) value , DATETIME_FORMAT ) , Store . NO ) ; } if ( value instanceof String ) { String v = value . toString ( ) . trim ( ) ; return v . indexOf ( ' ' ) >= 0 ? new TextField ( key , v , Store . NO ) : new StringField ( key , v , Store . NO ) ; } return null ; }
Create index field for a document s field value .