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

org.hibernate.search.spatial.impl.SpatialNumericDocValueField Maven / Gradle / Ivy

There is a newer version: 5.11.12.Final
Show newest version
/*
 * Hibernate Search, full-text search for your domain model
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later
 * See the lgpl.txt file in the root directory or .
 */
package org.hibernate.search.spatial.impl;

import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.index.DocValuesType;
import org.apache.lucene.index.IndexOptions;

/**
 * This class is equivalent to {@code DoubleDocValuesField} except that we set the property indexed to false explicitly.
 *
 * @see org.apache.lucene.document.DoubleDocValuesField
 * @author Davide D'Alto
 */
public class SpatialNumericDocValueField extends Field {

	public static final FieldType TYPE = createSpatialFieldType();

	private static FieldType createSpatialFieldType() {
		FieldType type = new FieldType();
		type.setIndexOptions( IndexOptions.NONE );
		type.setDocValuesType( DocValuesType.NUMERIC );
		type.freeze();
		return type;
	}

	public SpatialNumericDocValueField(String name, Double value) {
		super( name, TYPE );
		fieldsData = Double.doubleToRawLongBits( value );
	}

	@Override
	public void setDoubleValue(double value) {
		super.setLongValue( Double.doubleToRawLongBits( value ) );
	}

	@Override
	public void setLongValue(long value) {
		throw new IllegalArgumentException( "cannot change value type from Double to Long" );
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy