We're updating the issue view to help you get more done. 

Incorrect mapping for 'java.lang.Short and java.lang.Byte' fields with Elasticsearch.

Description

Hi,

I recently came across the following case, some of my attributes are not being converted correctly, specific cases of type byte and short.

Maybe because lucene does not have these types, but in elasticsearch we have.

It would be nice as these fields, because are optimized compared to a text / keyword.

I created a test case to be documented here, and maybe in elasticsearch 6.x or before, we'll be able to use these types.

Example class:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 @Entity @Indexed(index = "my-index") public class MyTestEntity { @Id @DocumentId private Long id; @Field(analyze = Analyze.YES) private String stringWithAnalyze; @Field(analyze = Analyze.NO) private String stringWithoutAnalyze; @Field(analyze = Analyze.YES) private Boolean booleanWrapWithAnalyze; @Field(analyze = Analyze.NO) private Boolean booleanWrapWithoutAnalyze; @Field(analyze = Analyze.YES) private boolean booleanPrimitiveWithAnalyze; @Field(analyze = Analyze.NO) private boolean booleanPrimitiveWithoutAnalyze; @Field(analyze = Analyze.YES) private Byte byteWrapWithAnalyze; @Field(analyze = Analyze.NO) private Byte byteWrapWithoutAnalyze; @Field(analyze = Analyze.YES) private byte bytePrimitiveWithAnalyze; @Field(analyze = Analyze.NO) private byte bytePrimitiveWithoutAnalyze; @Field(analyze = Analyze.YES) private Integer integerWrapWithAnalyze; @Field(analyze = Analyze.NO) private Integer integerWrapWithoutAnalyze; @Field(analyze = Analyze.YES) private int integerPrimitiveWithAnalyze; @Field(analyze = Analyze.NO) private int integerPrimitiveWithoutAnalyze; @Field(analyze = Analyze.YES) private Long longWrapWithAnalyze; @Field(analyze = Analyze.NO) private Long longWrapWithoutAnalyze; @Field(analyze = Analyze.YES) private long longPrimitiveWithAnalyze; @Field(analyze = Analyze.NO) private long longPrimitiveWithoutAnalyze; @Field(analyze = Analyze.YES) private Float floatWrapWithAnalyze; @Field(analyze = Analyze.NO) private Float floatWrapWithoutAnalyze; @Field(analyze = Analyze.YES) private float floatPrimitiveWithAnalyze; @Field(analyze = Analyze.NO) private float floatPrimitiveWithoutAnalyze; @Field(analyze = Analyze.YES) private Double doubleWrapWithAnalyze; @Field(analyze = Analyze.NO) private Double doubleWrapWithoutAnalyze; @Field(analyze = Analyze.YES) private double doublePrimitiveWithAnalyze; @Field(analyze = Analyze.NO) private double doublePrimitiveWithoutAnalyze; @Field(analyze = Analyze.YES) private Short shortWrapWithAnalyze; @Field(analyze = Analyze.NO) private Short shortWrapWithoutAnalyze; @Field(analyze = Analyze.YES) private short shortPrimitiveWithAnalyze; @Field(analyze = Analyze.NO) private short shortPrimitiveWithoutAnalyze; protected MyTestEntity() { } .......

The following mapping is created:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 { "my-index" : { "mappings" : { "org.hibernate.search.bugs.MyTestEntity" : { "dynamic" : "strict", "properties" : { "booleanPrimitiveWithAnalyze" : { "type" : "boolean" }, "booleanPrimitiveWithoutAnalyze" : { "type" : "boolean" }, "booleanWrapWithAnalyze" : { "type" : "boolean" }, "booleanWrapWithoutAnalyze" : { "type" : "boolean" }, "bytePrimitiveWithAnalyze" : { "type" : "text" }, "bytePrimitiveWithoutAnalyze" : { "type" : "keyword", "norms" : true }, "byteWrapWithAnalyze" : { "type" : "text" }, "byteWrapWithoutAnalyze" : { "type" : "keyword", "norms" : true }, "doublePrimitiveWithAnalyze" : { "type" : "double" }, "doublePrimitiveWithoutAnalyze" : { "type" : "double" }, "doubleWrapWithAnalyze" : { "type" : "double" }, "doubleWrapWithoutAnalyze" : { "type" : "double" }, "floatPrimitiveWithAnalyze" : { "type" : "float" }, "floatPrimitiveWithoutAnalyze" : { "type" : "float" }, "floatWrapWithAnalyze" : { "type" : "float" }, "floatWrapWithoutAnalyze" : { "type" : "float" }, "id" : { "type" : "keyword", "store" : true }, "integerPrimitiveWithAnalyze" : { "type" : "integer" }, "integerPrimitiveWithoutAnalyze" : { "type" : "integer" }, "integerWrapWithAnalyze" : { "type" : "integer" }, "integerWrapWithoutAnalyze" : { "type" : "integer" }, "longPrimitiveWithAnalyze" : { "type" : "long" }, "longPrimitiveWithoutAnalyze" : { "type" : "long" }, "longWrapWithAnalyze" : { "type" : "long" }, "longWrapWithoutAnalyze" : { "type" : "long" }, "shortPrimitiveWithAnalyze" : { "type" : "text" }, "shortPrimitiveWithoutAnalyze" : { "type" : "keyword", "norms" : true }, "shortWrapWithAnalyze" : { "type" : "text" }, "shortWrapWithoutAnalyze" : { "type" : "keyword", "norms" : true }, "stringWithAnalyze" : { "type" : "text" }, "stringWithoutAnalyze" : { "type" : "keyword", "norms" : true } } } } } }

Test Case: https://github.com/frekele/hibernate-search-elasticsearch-test-case/tree/HSEARCH-2908
Travis CI log: https://travis-ci.org/frekele/hibernate-search-elasticsearch-test-case

Environment

None

Status

Assignee

Fabio Massimo Ercoli

Reporter

Leandro Kersting de Freitas

Labels

None

Suitable for new contributors

None

Feedback Requested

None

Components

Fix versions

Affects versions

5.8.1.Final

Priority

Major