From e130440c52809f76ba7347c03b53205d2ec0fe5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Mon, 24 Aug 2020 14:46:41 +0200 Subject: [PATCH] HSEARCH-3282 Remove support for explicit facet encoding in the migration helper And assume the encoding is defined by the field type. --- .../search/test/query/facet/Car.java | 13 ++++--- .../hibernate/search/annotations/Facet.java | 5 --- .../search/annotations/FacetEncodingType.java | 34 ------------------- 3 files changed, 8 insertions(+), 44 deletions(-) delete mode 100644 v5migrationhelper/engine/src/main/java/org/hibernate/search/annotations/FacetEncodingType.java diff --git a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/facet/Car.java b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/facet/Car.java index b8fe1f33dfb..378c713271d 100644 --- a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/facet/Car.java +++ b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/facet/Car.java @@ -14,11 +14,9 @@ import org.hibernate.search.annotations.Analyze; import org.hibernate.search.annotations.Analyzer; import org.hibernate.search.annotations.Facet; -import org.hibernate.search.annotations.FacetEncodingType; import org.hibernate.search.annotations.Facets; import org.hibernate.search.annotations.Field; import org.hibernate.search.annotations.Fields; -import org.hibernate.search.annotations.FieldBridge; import org.hibernate.search.annotations.Indexed; import org.hibernate.search.annotations.Store; import org.hibernate.search.testsupport.AnalysisNames; @@ -57,9 +55,8 @@ public class Car { private String make; - @Field(name = CUBIC_CAPACITY_STRING, analyze = Analyze.NO, bridge = @FieldBridge(impl = IntegerBridge.class)) - @Facet(name = CUBIC_CAPACITY_STRING_FACET_STRING_ENCODING, forField = CUBIC_CAPACITY_STRING, encoding = FacetEncodingType.STRING) - @Facet(name = CUBIC_CAPACITY_STRING_FACET_NUMERIC_ENCODING, forField = CUBIC_CAPACITY_STRING, encoding = FacetEncodingType.LONG) + @Field + @Facet(name = CUBIC_CAPACITY_STRING_FACET_NUMERIC_ENCODING) private Integer cubicCapacity; public Car() { @@ -79,6 +76,12 @@ public Integer getCubicCapacity() { return cubicCapacity; } + @Field(name = CUBIC_CAPACITY_STRING, analyze = Analyze.NO) + @Facet(name = CUBIC_CAPACITY_STRING_FACET_STRING_ENCODING, forField = CUBIC_CAPACITY_STRING) + public String getCubicCapacityString() { + return cubicCapacity == null ? null : cubicCapacity.toString(); + } + public int getId() { return id; } diff --git a/v5migrationhelper/engine/src/main/java/org/hibernate/search/annotations/Facet.java b/v5migrationhelper/engine/src/main/java/org/hibernate/search/annotations/Facet.java index 754c9b4b37a..e5226ffa168 100644 --- a/v5migrationhelper/engine/src/main/java/org/hibernate/search/annotations/Facet.java +++ b/v5migrationhelper/engine/src/main/java/org/hibernate/search/annotations/Facet.java @@ -36,9 +36,4 @@ */ String forField() default ""; - /** - * @return the encoding type to use for this facet. Per default the encoding type is chosen based on the type of the - * entity property. - */ - FacetEncodingType encoding() default FacetEncodingType.AUTO; } diff --git a/v5migrationhelper/engine/src/main/java/org/hibernate/search/annotations/FacetEncodingType.java b/v5migrationhelper/engine/src/main/java/org/hibernate/search/annotations/FacetEncodingType.java deleted file mode 100644 index aaafc342db8..00000000000 --- a/v5migrationhelper/engine/src/main/java/org/hibernate/search/annotations/FacetEncodingType.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.annotations; - -/** - * Determines how to encode the indexed value. - * - * @author Hardy Ferentschik - */ -public enum FacetEncodingType { - /** - * Facet values are stored as strings using {@code SortedSetDocValuesFacetField} - */ - STRING, - - /** - * Facet values are stored as long values using {@code NumericDocValuesField} - */ - LONG, - - /** - * Facet values are stored as double values using {@code DoubleDocValuesField} - */ - DOUBLE, - - /** - * The encoding type for the facet is determined by the type of the entity property - */ - AUTO -}