All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.lumongo.server.index.field.StringFieldIndexer Maven / Gradle / Ivy

There is a newer version: 0.52
Show newest version
package org.lumongo.server.index.field;

import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.TextField;

public class StringFieldIndexer extends FieldIndexer {
	
	private static FieldType notStoredTextField;
	
	static {
		notStoredTextField = new FieldType(TextField.TYPE_NOT_STORED);
		notStoredTextField.freeze();
	}
	
	public static final StringFieldIndexer INSTANCE = new StringFieldIndexer();
	
	protected StringFieldIndexer() {
		
	}
	
	@Override
	protected void handleValue(Document d, String storedFieldName, Object value, String indexedFieldName) throws Exception {
		if (value != null) {
			d.add((new Field(indexedFieldName, value.toString(), notStoredTextField)));
		}
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy