Source:
private void addSortFieldDocValues(Document document, PropertyMetadata propertyMetadata, float documentBoost, Object propertyValue) { for ( SortableFieldMetadata sortField : propertyMetadata.getSortableFieldMetadata() ) { DocumentFieldMetadata fieldMetaData = propertyMetadata.getFieldMetadata( sortField.getFieldName() ); if ( fieldMetaData == null ) { continue; } IndexableField field; if ( fieldMetaData.getIndex() == Index.NO && fieldMetaData.getStore() == Store.NO ) { FieldBridge fieldBridge = fieldMetaData.getFieldBridge(); LuceneOptionsImpl luceneOptions = new LuceneOptionsImpl( Index.NOT_ANALYZED, fieldMetaData.getTermVector(), fieldMetaData.getStore(), fieldMetaData.indexNullAs(), fieldMetaData.getBoost() * propertyMetadata.getDynamicBoostStrategy().defineBoost( propertyValue ), documentBoost ); Document dummy = new Document(); fieldBridge.set( "dummy", propertyValue, dummy, luceneOptions ); field = dummy.getField( "dummy" ); } else { field = document.getField( sortField.getFieldName() ); } if ( field != null ) { Number numericValue = field.numericValue(); if ( numericValue != null ) { if ( numericValue instanceof Double ) { document.add( new DoubleDocValuesField( sortField.getFieldName(), (double) numericValue ) ); } else if ( numericValue instanceof Float ) { document.add( new FloatDocValuesField( sortField.getFieldName(), (float) numericValue ) ); } else { document.add( new NumericDocValuesField( sortField.getFieldName(), numericValue.longValue() ) ); } } else { String value = field.stringValue(); AnalyzerReference analyzerReference = fieldMetaData.getAnalyzerReference(); if ( fieldMetaData.getIndex().isAnalyzed() && analyzerReference.is( LuceneAnalyzerReference.class ) ) { Analyzer analyzer = analyzerReference.unwrap( LuceneAnalyzerReference.class ).getAnalyzer(); value = analyzeSortFieldValue( sortField.getFieldName(), field.stringValue(), analyzer ); } if ( value != null ) { document.add( new SortedDocValuesField( sortField.getFieldName(), new BytesRef( value ) ) ); } } } } }

Target:
private void addSortFieldDocValues(Document document, PropertyMetadata propertyMetadata, float documentBoost, Object propertyValue) { for ( SortableFieldMetadata sortField : propertyMetadata.getSortableFieldMetadata() ) { DocumentFieldMetadata fieldMetaData = propertyMetadata.getFieldMetadata( sortField.getFieldName() ); if ( fieldMetaData == null ) { continue; } IndexableField field; if ( fieldMetaData.getIndex() == Index.NO && fieldMetaData.getStore() == Store.NO ) { FieldBridge fieldBridge = fieldMetaData.getFieldBridge(); LuceneOptionsImpl luceneOptions = new LuceneOptionsImpl( Index.NOT_ANALYZED, fieldMetaData.getTermVector(), fieldMetaData.getStore(), fieldMetaData.indexNullAs(), fieldMetaData.getBoost() * propertyMetadata.getDynamicBoostStrategy().defineBoost( propertyValue ), documentBoost ); Document dummy = new Document(); fieldBridge.set( "dummy", propertyValue, dummy, luceneOptions ); field = dummy.getField( "dummy" ); } else { field = document.getField( sortField.getFieldName() ); } if ( field != null ) { Number numericValue = field.numericValue(); if ( numericValue != null ) { if ( numericValue instanceof Double ) { document.add( new DoubleDocValuesField( sortField.getFieldName(), (double) numericValue ) ); } else if ( numericValue instanceof Float ) { document.add( new FloatDocValuesField( sortField.getFieldName(), (float) numericValue ) ); } else { document.add( new NumericDocValuesField( sortField.getFieldName(), numericValue.longValue() ) ); } } else { String value = field.stringValue(); AnalyzerReference analyzerReference = fieldMetaData.getAnalyzerReference(); if ( fieldMetaData.getIndex().isAnalyzed() && analyzerReference.is( LuceneAnalyzerReference.class ) ) { Analyzer analyzer = analyzerReference.unwrap( LuceneAnalyzerReference.class ).getAnalyzer(); value = InternalAnalyzerUtils.analyzeSortableValue( analyzer, sortField.getFieldName(), value ); } if ( value != null ) { document.add( new SortedDocValuesField( sortField.getFieldName(), new BytesRef( value ) ) ); } } } } }