![JAR search and dependency download from the Maven repository](/logo.png)
org.hibernate.search.bridge.String2FieldBridgeAdaptor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-annotations
Show all versions of hibernate-annotations
Annotations metadata for Hibernate
//$Id: $
package org.hibernate.search.bridge;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.hibernate.util.StringHelper;
/**
* Bridge to use a StringBridge as a FieldBridge
*
* @author Emmanuel Bernard
*/
public class String2FieldBridgeAdaptor implements FieldBridge {
private StringBridge stringBridge;
public String2FieldBridgeAdaptor(StringBridge stringBridge) {
this.stringBridge = stringBridge;
}
public void set(String name, Object value, Document document, Field.Store store, Field.Index index, Float boost) {
String indexedString = stringBridge.objectToString( value );
//Do not add fields on empty strings, seems a sensible default in most situations
if ( StringHelper.isNotEmpty( indexedString ) ) {
Field field = new Field( name, indexedString, store, index );
if ( boost != null ) field.setBoost( boost );
document.add( field );
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy