
org.hibernate.search.cfg.FacetMapping Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of infinispan-embedded-query
Show all versions of infinispan-embedded-query
Infinispan Embedded Query All-in-One module
The 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.cfg;
import java.lang.annotation.ElementType;
import java.util.HashMap;
import java.util.Map;
import org.hibernate.search.annotations.FacetEncodingType;
/**
* Configures a faceting field. Equivalent to {@code @Facet}.
*
* @author Yoann Rodiere
*/
public class FacetMapping {
private final String fieldName;
private final PropertyDescriptor property;
private final EntityDescriptor entity;
private final SearchMapping mapping;
private final Map facet = new HashMap();
public FacetMapping(String fieldName, PropertyDescriptor property, EntityDescriptor entity, SearchMapping mapping) {
this.fieldName = fieldName;
this.property = property;
this.entity = entity;
this.mapping = mapping;
facet.put( "forField", fieldName );
property.addFacet( facet );
}
public FacetMapping name(String fieldName) {
facet.put( "name", fieldName );
return this;
}
public FacetMapping encoding(FacetEncodingType encoding) {
facet.put( "encoding", encoding );
return this;
}
public FieldMapping field() {
return new FieldMapping( property, entity, mapping );
}
public NumericFieldMapping numericField() {
return new NumericFieldMapping( fieldName, property, entity, mapping );
}
public PropertyMapping property(String name, ElementType type) {
return new PropertyMapping( name, type, entity, mapping );
}
public EntityMapping entity(Class> entityType) {
return new EntityMapping( entityType, mapping );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy